Architecture:MediaWiki/Pattern language
This page is under construction Please help review and edit this page. |
Classes in the MediaWiki code base use the pattern language outlined below. As per version 1.35, the pattern language is aspirational. That is, the patterns described here do not describe current reality, but are intended as a guide for creating new code and for improving existing code.
Patterns, in no specific order:
- entry point pattern
- wiring pattern (including hook handlers)
- view pattern
- cursor pattern (iterators, etc)
- batch pattern
- pager pattern
- input form pattern
- service object pattern
- handler pattern
- content handler pattern
- API module pattern
- action pattern
- special page pattern
- media handler pattern
- page pattern (page types?)
- provider pattern (vague, could be a factory)
- codec pattern (serializer/deserializer)
- command pattern (aka business action)
- validator pattern
- formatter pattern
- skin pattern
- renderer pattern
- localizer pattern
- builder pattern
- event pattern
- listener pattern
- job pattern
- data update pattern
- output aggregator pattern
- data object pattern
- record pattern (has ID)
- immutable value pattern
- active record anti-pattern
- content pattern (deprecate?)
- parser pattern (?)
- cache pattern
- writer pattern
- hook handler pattern
- client object pattern
- adapter pattern
- maintenance script pattern
Patterns
editThese patterns serve as reusable solutions to common problems encountered in software architecture and design. While some patterns are specific to certain technical layers, others can be applied across multiple layers, enhancing the flexibility and maintainability of the codebase. This overview categorizes and describes each pattern, offering insights into their applications and potential restrictions.
Entry Point Pattern
editDefines a clear entry point for application execution, ensuring that the application starts predictably.
Wiring Pattern
editInvolves the configuration of components and their dependencies, often utilizing hook handlers to manage events and interactions.
View Pattern
editSeparates the presentation layer from the business logic, allowing for a clean and maintainable user interface.
Cursor Pattern
editUtilizes iterators to traverse collections of data, providing a consistent way to access elements without exposing the underlying structure.
Batch Pattern
editProcesses a group of items together, optimizing performance and resource usage by minimizing the number of transactions.
Pager Pattern
editFacilitates the navigation of large datasets by dividing them into manageable pages, improving user experience and performance.
Input Form Pattern
editStandardizes the creation and validation of input forms, ensuring consistent data collection and user interaction.
Service Object Pattern
editEncapsulates business logic within service objects, promoting separation of concerns and enhancing testability.
Stateless Service Pattern
editDesigns services that do not maintain state between requests, allowing for scalability and easier management.
Service Container Pattern
editManages the instantiation and lifecycle of service objects, providing a centralized location for dependency injection.
Data Access Object Pattern
editAbstracts the data access layer, providing a consistent interface for interacting with data sources.
Lookup Pattern
editFacilitates the retrieval of objects or services based on a key, promoting loose coupling and flexibility.
Factory Pattern
editCreates objects without specifying the exact class of the object being created, promoting encapsulation and flexibility.
Registry Pattern
editMaintains a centralized registry of objects, allowing for easy access and management of shared resources.
Handler Pattern
editDefines a mechanism for processing requests or events, often used in conjunction with other patterns.
Content Handler Pattern
editManages the processing and rendering of content, ensuring that the correct format and structure are applied.
API Module Pattern
editEncapsulates the functionality of an API, providing a clear interface for interaction with external systems.
Action Pattern
editDefines a specific action or command that can be executed, often associated with user interactions.
Special Page Pattern
editHandles unique or specialized pages within an application, providing tailored functionality and presentation.
Media Handler Pattern
editManages the processing and delivery of media content, ensuring compatibility and performance.
Page Pattern
editDefines various types of pages within an application, promoting consistency in structure and behavior.
Provider Pattern
editOffers a way to supply dependencies or services, often acting as a factory for creating instances.
Codec Pattern
editHandles the serialization and deserialization of data, ensuring compatibility between different formats.
Command Pattern
editEncapsulates a request as an object, allowing for parameterization and queuing of requests.
Validator Pattern
editStandardizes the validation of input data, ensuring that it meets specified criteria before processing.
Formatter Pattern
editHandles the formatting of data for presentation, ensuring consistency and adherence to standards.
Skin Pattern
editAllows for the customization of the user interface, enabling different visual styles without altering functionality.
Renderer Pattern
editManages the rendering of content, separating the logic of content generation from its presentation.
Localizer Pattern
editFacilitates the translation and localization of content, ensuring that applications can support multiple languages.
Builder Pattern
editEncapsulates the construction of complex objects, allowing for step-by-step creation and configuration.
Event Pattern
editDefines a mechanism for event-driven programming, allowing components to communicate through events.
Listener Pattern
editHandles the subscription and response to events, promoting decoupling between event producers and consumers.
Job Pattern
editEncapsulates a unit of work that can be executed asynchronously, promoting scalability and responsiveness.
Data Update Pattern
editManages the process of updating data, ensuring consistency and integrity throughout the application.
Output Aggregator Pattern
editCombines multiple outputs into a single response, optimizing performance and resource usage.
Data Object Pattern
editRepresents a data structure, often used to transfer data between layers of an application.
Record Pattern
editDefines a data structure with a unique identifier, facilitating easy retrieval and management.
Immutable Value Pattern
editCreates objects that cannot be modified after creation, promoting safety and predictability.
Exception Pattern
editConsistently handles error conditions, promoting robustness and maintainability.
Active Record Anti-Pattern
editIdentifies the pitfalls of using an active record pattern, where business logic and data access are tightly coupled.
Content Pattern
editManages the representation and processing of content, though its relevance may be diminishing.
Parser Pattern
editFacilitates the interpretation and processing of structured data, ensuring that it can be transformed into usable formats.
Cache Pattern
editImproves performance by storing frequently accessed data in memory, reducing the need for repeated data retrieval.
Writer Pattern
editHandles the output of data, ensuring that it is formatted and delivered correctly.
Hook Handler Pattern
editManages hooks within the application, allowing for extensibility and customization.
Client Object Pattern
editEncapsulates the interaction with external services or APIs, promoting separation of concerns.
Adapter Pattern
editFacilitates compatibility between incompatible interfaces, allowing for seamless integration.
Maintenance Script Pattern
editDefines scripts for performing maintenance tasks, ensuring that they are executed consistently and reliably.
Conclusion
editWhile some patterns may be confined to specific technical layers, others can be leveraged across multiple layers, providing flexibility and promoting best practices in software design.
Some patterns may be confined to technical layers, but others may be applicable on all layers. Some layers may have restrictions on what other patterns they can make use of.