A team with a unified mind is easy to lead instead! – Gu Ling

The introduction

  • Best Practices: Design patterns have evolved over a long period of time to summarize best practices.
  • Unified thinking: Design patterns provide a standard terminology system that is specific to a particular situation.

Seven principles of design patterns

  • Single responsibility principle: a class is responsible for one responsibility.
  • Open and close principle: extensible, not modifiable.
  • Richter’s substitution rule: define the base class, run the subclass.
  • Dependency inversion principle: Details depend on abstraction, interface oriented programming, dependencies generated through interfaces or abstract classes.
  • Demeter’s rule: Least know the rule and only communicate with immediate friends.
  • Interface isolation principle: The dependency of one class on another class should be based on the smallest interface.
  • Principle of composite reuse: composition/aggregation is better than inheritance.

Classification of design patterns

  • Creation pattern: Creation of key objects.

· Singleton, factory method, Abstract factory, Builder, prototype.

  • Structural patterns: Focus on a combination of objects.

· Adapter, decoration, agent, appearance, bridge, combination, share element.

  • Behavioral pattern: Focuses on the communication of objects.

· Policy, template method, observer, iterator, chain of responsibility, command, memo, status, visitor, mediator, interpreter.

Design pattern progression

Ladle package

(1) Singleton mode

(2) Factory mode (simple, factory, abstract)

Xiaobian blog series

The Android technology stack