首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

面向对象的设计准则_单一职责原则

2012-12-20 
面向对象的设计原则_单一职责原则??//single responsibility principle - good exampleinterface IEmail {

面向对象的设计原则_单一职责原则
?面向对象的设计准则_单一职责原则面向对象的设计准则_单一职责原则

    ?面向对象的设计准则_单一职责原则面向对象的设计准则_单一职责原则
      //single responsibility principle - good exampleinterface IEmail {public void setSender(String sender);public void setReceiver(String receiver);public void setContent(IContent content);}interface IContent {public String getAsString(); // used for serialization}class Email implements IEmail {public void setSender(String sender) {// set sender; }public void setReceiver(String receiver) {// set receiver; }public void setContent(IContent content) {// set content; }}

      ?

      ?

      总结

      单一职责原则代表了设计应用程序时一种很好的识别类的方式,并且它提醒你思考一个类的所有演化方式。只有对应用程序的工作方式有了很好的理解,才能很好的分离职责。

热点排行