Junior
What design patterns are you familiar with?
sobes.tech AI
Answer from AI
-
Creational
- Factory Method (creating objects through a factory method rather than directly through a constructor)
- Abstract Factory (an interface for creating families of related objects without specifying their concrete classes)
- Builder (step-by-step creation of complex objects, allowing different variants of the object to be obtained using the same construction code)
- Prototype (creating new objects by copying an existing sample)
- Singleton (ensures only one instance of a class exists and provides a global point of access to it)
-
Structural
- Adapter (allows objects with incompatible interfaces to work together)
- Bridge (separates abstraction and implementation, allowing them to vary independently)
- Composite (treats individual objects and groups of objects uniformly)
- Decorator (dynamically adds responsibilities to objects)
- Facade (provides a unified interface to a set of interfaces in a subsystem)
- Flyweight (efficiently manages a large number of small objects)
- Proxy (provides a surrogate object controlling access to another object)
-
Behavioral
- Chain of Responsibility (passes requests along a chain of handlers)
- Command (encapsulates a request as an object, allowing parameterization of clients, queuing of requests, logging, and undo operations)
- Iterator (provides a way to access elements of a collection sequentially without exposing its underlying representation)
- Mediator (simplifies communication between multiple objects by introducing a mediator object)
- Memento (allows saving and restoring an object's internal state without violating encapsulation)
- Observer (defines a dependency between objects so that when one changes, dependents are notified and updated automatically)
- State (allows an object to alter its behavior when its internal state changes)
- Strategy (defines a family of algorithms, encapsulates each one, and makes them interchangeable)
- Template Method (defines the skeleton of an algorithm in a base class, allowing subclasses to override certain steps without changing the overall structure)
- Visitor (adds new operations to a class hierarchy without modifying the classes)
In Android development, MVx patterns (MVP, MVVM) are often used, as well as patterns from the Android Architecture Components library (Room, ViewModel, LiveData, Navigation).