OOP读书散记

Mai. develope the software in steps:
   a> Make sure your software does what the customer wants it to do.
   b> Apply basic OO principle to add flexibility
   c> strive for a maintainable and reusable design

1. 使用delegate模式,可以降低不同的类之间和模块之间的耦合度
2. 在进行需求分析之时,请注意其中的名词
    the verbs in the use case are the methods of the object in your system.

 Use Case principles
 a. a good use case clearly and accurately explains what a system does,in language that's easy understood.
    With a good use case complete, textual analysis is a quick and easy way to figure out the classes in
 your system. 
 b. Think about the classes you do have if they support the behavour in the use case
 c. Each User case should focus on only one customer goal. If you have multiply customer goals,you should have multiple user case.

 编码设计的几点总结:
 1. 预测变化;然后进行设计,为将来的变化预留
 
 2. 组件化设计思想;在进行程序或者类包设计之时,尽量考虑自包含特性。
    特性描述:
     对外部无依赖,接收输入信息,向外部返回结果。
  
 3.  可重用组件类或者模块
    在完成的类中,有多少可以提取出来,以供将来重用的。

 4. Coding to the interface ,not the implementation
 5. encapsulation: protect your classes from unnessary changes, encapsulate what varies.
    实例说明:
    我们可以将不变部分做到一个类中去,而将可能会发生变更的部分提取出来单独做一个类。这个变更频繁的类可以按照自己的设想进行变更实现。
 6. each class has only one resonsibility and one reason to change.<职责单一>
    例如,一个类含有多个职责,则可以将这个类进行分解,分为若干个类。
    

The simple Process: Gather Features, Domain Analysis-> break the system into modules ->

 7. Domain Analysis
    representing a system with the language the customer understand.
 8. Architecture
   It is your design structure,and highlight the most important parts of your app and relationships between these parts.
   Another definition:
     Architecture is the organizational structure of your system, including the decomposition into the parts,their
  connectivity, interaction mechanism, and guiding principle/decision you used in the design of system.
 
  9. Great Software is built in three steps:
    a. make sure our software does what the customers want it do.
 b. Apply basic OO Principle to add flexibility
 c. strive for a maintainable and resuable design

  10. Architecture isn't only about the relationship between the parts of the system, but it is also about figuring out which parts are the most important and we had better start building those parts first.
  11. Three important questions you have to answer in the architecture
    a. Is it the part of essence of the system.
 b. Is there anything unclear in the feature list? please make it clear as early as possible.
 c. Is there anything really hard to implement? please figure it out first and get ready for it.
  12. The commonality ==> path to flexible software
  13. sometiemes,the best way to write great software is to hold off writing code as long as you can.
  5.   当程序返回空指针,如果这种情况基本不可能出现,则可以通过抛出异常来提醒使用者
       抛出的异常可以分为checked/unchecked.这个视具体情况而定,区别在于是否需要调用代码check这个异常

 OO Design Principle
  1. OCP: Classes should be open for extension, and closed for modification.
     implemented way: inheritance,composition
   
  2. DRY: dont' repeat yourself.
     avoid duplicate code by abstracting out the thing that are common and placing those thing in a single place.
  DRY is about having each piece of information and behaviour in a single and sensiable place.

  3. SRP: single responsibility principle
     Every Object in your system should have only a single responsibility, and all the object services should be
  focused on carrying out the single responsibility.
  The statement is equal with: each class only has one reason to change.
 
  4. LSP: The liskov substitute Principle
     SubTypes must substitute for their base type
   
   
     Composition: allows you to use behaviour from a family of classes, and to change the hehaviour at runtime
     if the owner object is destoryed ,the componsed is also destoryed.
 
     Aggregation: when one class is a part of another class, but still exists outside of the other class.
 
  5.  Programming By Contract:
     set up an agreement about how your software behaves that you and the users of your software abide by

  6. Defensive Programming:
     doesn't trust other software,and does extensive error and data checking to ensure the other software doesn't
give you bad or unsafe information.

Feature list:
   Your Feature Lists are all about understanding what your software are supposed to do.
 User Case Diagrame:
   let you think about how your software is used, without getting into a bunch of details.

你可能感兴趣的:(OOP读书散记)