Complat software training 101
  • Introduction
  • Day 1
  • Day 2
  • TODO
  • Linear regression
  • Tmux
  • quick link
  • CLI more - 1
  • Vim more - 1
  • MQ
  • iv - 1
  • iv - 2
  • iv - 3
  • clear Arch
  • lv - array
  • INTERVIEW - JS
  • RDKit - read/write
  • RDKit - process
  • RDKit - transform
  • RDKit - rxn
  • SYSTEM DESIGN - Question
  • SYSTEM DESIGN - EX1
  • SYSTEM DESIGN - EX2
  • SYSTEM DESIGN - EX3
  • SYSTEM DESIGN - EX99
Powered by GitBook
On this page
  • Clean Code
  • software = build a house
  • OOP
  • Overload & override
  • FP
  • SOLID

Was this helpful?

iv - 3

Clean Code

software = build a house

  1. basic = building plan.

  2. build different purpose: apartment, hotel, business, etc.

  3. goal: build house, and make customer happy.

TDD = possible to optimize parts of codes, not full redo.

OOP

inheritance, encapsulation, polymorphism

Inheritance

mixin = multiple inheritance

put common methods, attributes to ancestor

Encapsulation

  1. 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.

Polymorphism

  • 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

FP

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.

SOLID

Single Responsibility Principle

  1. one module one role

  2. separate data & logic

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)

  1. separate data & logic

  2. A rely on B, and B rely on C. A and B will be changed when changing C

Dependency Inversion Principle (DIP)

  1. element-wise communications

  2. rely on interface, not class. Classes changing a lot.

Previousiv - 2Nextclear Arch

Last updated 5 years ago

Was this helpful?