software = build a house
build different purpose: apartment, hotel, business, etc.
goal: build house, and make customer happy.
TDD = possible to optimize parts of codes, not full redo.
inheritance, encapsulation, polymorphism
mixin = multiple inheritance
put common methods, attributes to ancestor
restricting direct access to some
class Base {
public:
int publicMember;
protected:
int protectedMember;
private:
int privateMember;
};
Everything that is aware of Base is also aware that Base contains publicMember.
Only the children (and their children) are aware that Base contains protectedMember.
No one but Base is aware of privateMember.
Different vendors design chips base on the same interface.
interface = every animal has eat() method, no matter it is mammal or insect.
Overload & override
overload = same scope, run-time-polymorphism
override = inheritance, same signature, compile-time-polymorphism
pure function, declarative, higher order function
immutable variable = no variable lock, and you will not encounter deadlock. = No wife, no divorce.
declarative = what to do, not how to do.
hof = input fn as params and output params, and wrap more properties.
Single Responsibility Principle
Open-Closed Principle = report display and printing should be 2 classes.
Liskov Substitution Principle = when using parent class, use child class.
Interface Segregation Principle (ISP)
A rely on B, and B rely on C. A and B will be changed when changing C
Dependency Inversion Principle (DIP)
element-wise communications
rely on interface, not class. Classes changing a lot.