Explore tens of thousands of sets crafted by our community.
Common Design Patterns in Mobile Apps
25
Flashcards
0/25
Bridge
Decouples an abstraction from its implementation so that the two can vary independently. The bridge pattern is quite common in mobile apps when you have to support different types of devices or operating systems.
MVP (Model-View-Presenter)
A derivative of the MVC. The presenter handles most of the business logic, manipulating data and updating the view (which is more passive). Used to create scalable and maintainable code in mobile apps.
Iterator
Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation. Useful in mobile apps to traverse data structures without exposing details.
Prototype
Allows copying existing objects without the code needing to be tied to their classes. Useful in mobile apps when creating instances of a class is more expensive than copying an existing instance.
State
Allows an object to alter its behavior when its internal state changes. The object will appear to change its class. This is particularly handy in mobile apps for managing state transitions in a clean way.
Mediator
Defines an object that encapsulates how a set of objects interact. The Mediator promotes loose coupling by keeping objects from referring to each other explicitly. In mobile apps, it can be used to facilitate communication between various components or services without them being aware of each other.
Template Method
Defines the skeleton of an algorithm in a method, deferring some steps to subclasses. The template method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure. In mobile development, it's used for frameworks or libraries extending base classes.
Flyweight
Minimizes memory usage or computational expenses by sharing as much as possible with similar objects. It's especially useful in mobile apps where memory and resource management is critical, like when handling large numbers of similar UI components.
Visitor
Lets you add further operations to objects without having to modify them. The visitor pattern is used when an external class implements operations to be performed on elements of an object structure. Mobile developers use it when applying operations over a set of objects with different classes.
Strategy
Enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, code receives run-time instructions as to which in a family of algorithms to use. Mobile apps use it for interchangeable behaviors within an object context.
Decorator
Attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. In mobile apps, it's often used for adding features to UI components without subclassing.
Observer
Defines a dependency between objects so that whenever one object changes state, all its dependents are notified and updated automatically. Useful in mobile apps for implementing event handling systems, such as refreshing UI components when underlying data changes.
MVC (Model-View-Controller)
Separates an application into three main logical components: the model (data), the view (UI), and the controller (business logic and data manipulation). A common architecture for mobile apps, enhancing maintainability.
Factory Method
Defines an interface for creating objects, but lets subclasses alter the type of objects that will be created. Used in mobile development to delegate product creation in class hierarchies.
Adapter
Allows objects with incompatible interfaces to collaborate. The adapter pattern is used in mobile apps when dealing with legacy or external systems and APIs where the provided interface doesn't match the one needed.
Chain of Responsibility
Passes request along a chain of handlers. Upon receiving a request, each handler decides either to process the request or to pass it to the next handler in the chain. Used in mobile apps for scenarios like event handling or logging where multiple objects may handle a request.
Abstract Factory
Provides an interface for creating families of related or dependent objects without specifying their concrete classes. Used in mobile apps to abstract complex object creation.
Builder
Allows constructing complex objects step by step. The Builder pattern separates the construction of a complex object from its representation, so the same construction process can create different representations. Useful for creating an intricate object with multiple options in mobile apps.
Command
Converts requests or simple operations into objects. This allows parameterization of methods with different requests, delay or queue a request's execution, and support undoable operations. Used in mobile apps for operations like undo/redo or to queue network requests.
Singleton
Ensures a class has only one instance and provides a global point of access to it. Used for managing shared resources or services in mobile apps like configuration managers.
Memento
Provides the ability to restore an object to its previous state. The memento pattern captures and externalizes an object's internal state without violating encapsulation. This is used in mobile apps when implementing features like save states, undo or redo functionality.
Facade
Provides a simplified interface to a complex subsystem. It's a higher-level interface that makes the subsystem easier to use. Mobile apps benefit from facades by having a simple interface for complex systems like a media playback engine.
Composite
Composes objects into tree structures to represent part-whole hierarchies. The Composite pattern lets clients treat individual objects and compositions uniformly. Mobile apps use this pattern for UI components and views that may contain nested elements.
MVVM (Model-View-ViewModel)
The ViewModel acts as an intermediary between the model and the view, using data bindings. MVVM facilitates separate development of the model and the UI, simplifying unit testing in mobile apps.
Proxy
Provides a placeholder or surrogate for another object to control access to it, either to enhance performance (lazy load) or to control the resource. In mobile development, it can be used for managing resource-intensive objects like images.
© Hypatia.Tech. 2024 All rights reserved.