csaki

progtech gyak 2.

Feb 20th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. Mani principle: Source codes is always changing. (inserting, updating, delete code is allowed)
  2. Agile programming: the requests are always changing. We accept it, we propose it.
  3. We try to write reusable code -> design patterns.
  4.  
  5. OCP:
  6. Open-closed principle: Program should be open for extension, closed for modification.
  7. Conflicts the main principle! (updating is forbidden)
  8. override keyword is forbidden (2 expections: abstract methods, hook methods (virtual method with empty implementation))
  9.  
  10. GOF1:
  11. Gang of Four: Program to an interface, not an implementation. --> we should not expose the inner state of the class!
  12. We have method that accesses the fields, but we do NOT return the reference (because it may change the content).
  13. We break GOF1 if you know the implementation, AND you can use the knowledge.
  14. Implementation dependency: 2 classes are in ~, if we change the one of them, then we have to change the other.
  15. Tightly/loosely coupled program:
  16. Tightly: a lot of implementation dependencies.
  17. Loosely: very few implementation dependencies.
  18.  
  19. (SRP:
  20. Single responsibility principle: A class should only have one responsiblity, not less, not more (it has to take all the responsibilites, though!). It should only have one reason to change.)
  21.  
  22. How to follow GOF1?
  23. - Use use abstract classes and interfaces.
  24. On the top of the class hierarchy there should be an abstract class or an interface. And the client type should be the abstract parent class. Client: the other parts of the source code (not the class or the hierarchy we are speaking about, eg. Main method).
  25.  
  26.  
  27. A program:
  28. It should accept a number in different base.
  29. Create a method which translates this number to any other bases.
Advertisement
Add Comment
Please, Sign In to add comment