Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mani principle: Source codes is always changing. (inserting, updating, delete code is allowed)
- Agile programming: the requests are always changing. We accept it, we propose it.
- We try to write reusable code -> design patterns.
- OCP:
- Open-closed principle: Program should be open for extension, closed for modification.
- Conflicts the main principle! (updating is forbidden)
- override keyword is forbidden (2 expections: abstract methods, hook methods (virtual method with empty implementation))
- GOF1:
- Gang of Four: Program to an interface, not an implementation. --> we should not expose the inner state of the class!
- We have method that accesses the fields, but we do NOT return the reference (because it may change the content).
- We break GOF1 if you know the implementation, AND you can use the knowledge.
- Implementation dependency: 2 classes are in ~, if we change the one of them, then we have to change the other.
- Tightly/loosely coupled program:
- Tightly: a lot of implementation dependencies.
- Loosely: very few implementation dependencies.
- (SRP:
- 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.)
- How to follow GOF1?
- - Use use abstract classes and interfaces.
- 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).
- A program:
- It should accept a number in different base.
- Create a method which translates this number to any other bases.
Advertisement
Add Comment
Please, Sign In to add comment