Guest User

08.Висококачествени класове

a guest
Jan 7th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. Висококачествени класове
  2. Classes as well as methods should have strong cohesion and loose coupling
  3. Loose coupling – тогава може лесно да подменим едно нещо с друго. Няма смесване на отговорности.
  4. Tight coupling – дадено нещо (напр. UI) не може да се замени с друг UI. Има смесване на отговорности.
  5.  
  6. Един начин да намалим dependency- то между класовете е вместо един клас да наследява друг клас, да има интерфейс, който се наследява от 2-та класа
  7.  
  8. Polymorphism – the ability to handle the objects of a specific class as instances of its parent class
  9. - It is a tool to enable code reuse
  10. - Common logic is taken to the base class
  11. - Specific logic is implemented in the derived class
  12.  
  13. Енкапсулация
  14. - Трябва да правим нещата в класа колкото се може по- малко видими
  15. Minimize the visibility of classes and members (in C# start from private and move to internal, protected and public)
  16. Anything which is not part of the class interface should be declared private!
  17.  
  18. Be suspicious of base classes of which there is only one derived class
  19. - Do you really need this additional level of inheritance?
  20.  
  21. Когато един клас е static, то този клас не е предназначен за наследяванe
  22.  
  23. Добре е всички мембъри да се инициализират в конструкторите
  24.  
  25. Един клас не трябва да знае за своите наследници
  26.  
  27. Use design patterns for common design situations:
  28. - Creational patterns
  29. - Structural patterns
  30. - Behavioral patterns
Add Comment
Please, Sign In to add comment