13 Sep
We learned about Design Patterns
□Flexible
change something that already exists
Desktop > Laptop
□Extensible
ability that adding one thing to current system
→Desktop
We can extend parts easily. For example, keyboard, software, screen, etc
□Destractors of Flexibility
- complex and uncreadable code
・bag name
ex) char * c ×
char * contact ○
We don't understand that what 'c' does mean.
- violation of single responsibility principle
ex) Fan has only the function of fan. So it should not have the function of
lighgt because it becomes complex in case of repair.
So one thing has one functionh.
- Repetition
example is below↓
Student class has the function of "sort()" and cource class also has the function of "sort()".
So to avoid repetion of "sort()", we make sorter class that has the function of "sort()". Then if we use the function of sort(), we refer sort from sorter class.
do not have to write sort() at student class and cource class.
□Design Decisions For Flexibility
- DRY
Do notrepeat yourself
- keep it simple
- loose coupling
・not tight nonnection
Car and Wheel are loosely coupled
Desktop is loosely coupled
Laptop is not loosely coupled
example is below↓
f1(sedan c){
c.turn();
}
f2(sports car c){
c.turn();
}
↓
f1(car c){
c.turn();
}
We can use "turn()" both at sprts car and sedan.
⇒Polymorphism
- separating thing that change
if we mix curry and rice, we cannot remove each thing.






