Three types of
- There are five types of creation patterns: singleton pattern, Abstract Factory pattern, factory pattern, prototype pattern and Builder pattern
- Structural mode 7: adapter mode, bridge mode, decorative mode, combination mode, appearance mode, share mode, proxy mode.
- There are 11 behavioral modes: observer mode, mediator mode, visitor mode, interpreter mode, iterator mode, memo mode, responsibility chain mode, state mode, policy mode, command mode, template mode.
23 Design Patterns and Examples (in book order)
- Singleton mode -getSystemService () Obtains system services
- Builder mode – Creation of an AlertDialog box
- Prototype mode – Clone objects
- Factory method mode -getSystemService () gets the system Service, Service’s onBind
- Abstract factory pattern – Service’s onBind
- Strategy mode – Animation interpolator
- Status mode – wifi status
- Chain of Responsibility mode – Click event distribution
- Interpreter schema – Androidmanifest.xml file parsing
- Command mode – Click events to encapsulate commands
- Observer mode – Adapter notifyDataSetChanged(), click event listener, EventBus
- Memo mode – Activyti onSaveInstanceState
- Iterator mode – Java Iterator, SQLite retrieves cursor
- Template method pattern – activity lifecycle
- Visitor pattern – Compiler annotations?
- Intermediary pattern – ServiceManager and Binder drivers in Binder communication, C in MVC pattern, P in MVP
- Proxy mode – Binder proxy
- Combined mode – ViewGroup contains viewgroups and views
- Adapter mode – Adapter for Listview
- Decorator mode – ContextImpl
- Share mode – Thread pool, Message
- Appearance mode – startActivity()
- Bridge modes – Window and WindowManager
Remember 23 Design Pattern references from Android Code 2. Book “Android source code design pattern analysis and combat”