PHP 8.4+ Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
CodeHydrater/docs/OOP_Design_Patterns.html

62 lines
6.4 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gang of Four Design Patterns</title>
</head>
<body>
<h1>23 Classic Gang of Four Design Patterns</h1>
<p style="font-size: small;">Generated by ChatGPT:</p>
<h2>Creational Patterns (deal with object creation)</h2>
<ol>
<li><strong>Singleton</strong> - Ensures a class has only one instance and provides a global point of access to it.</li>
<li><strong>Factory Method</strong> - Defines an interface for creating objects but lets subclasses decide which class to instantiate.</li>
<li><strong>Abstract Factory</strong> - Provides an interface for creating families of related objects without specifying their concrete classes.</li>
<li><strong>Builder</strong> - Separates the construction of a complex object from its representation, allowing the same construction process to create different representations.</li>
<li><strong>Prototype</strong> - Creates new objects by copying an existing object (prototype) rather than creating from scratch.</li>
</ol>
<h2>Structural Patterns (deal with object composition)</h2>
<ol start="6">
<li><strong>Adapter</strong> - Converts the interface of one class into another interface that clients expect, enabling incompatible classes to work together.</li>
<li><strong>Bridge</strong> - Decouples an abstraction from its implementation so they can vary independently, preventing a permanent binding between them.</li>
<li><strong>Composite</strong> - Composes objects into tree structures to represent part-whole hierarchies, letting clients treat individual objects and compositions uniformly.</li>
<li><strong>Decorator</strong> - Attaches additional responsibilities to an object dynamically, providing a flexible alternative to subclassing for extending functionality.</li>
<li><strong>Facade</strong> - Provides a unified, simplified interface to a complex subsystem, making it easier to use.</li>
<li><strong>Flyweight</strong> - Minimizes memory usage by sharing as much data as possible with similar objects; used when large numbers of objects are needed.</li>
<li><strong>Proxy</strong> - Provides a surrogate or placeholder for another object to control access to it, useful for lazy initialization, access control, or logging.</li>
</ol>
<h2>Behavioral Patterns (deal with object interaction and responsibility)</h2>
<ol start="13">
<li><strong>Chain of Responsibility</strong> - Passes a request along a chain of handlers, where each handler decides either to process the request or pass it to the next handler.</li>
<li><strong>Command</strong> - Encapsulates a request as an object, thereby allowing parameterization of clients with different requests and supporting undoable operations.</li>
<li><strong>Interpreter</strong> - Defines a grammatical representation for a language and an interpreter to evaluate sentences in that language.</li>
<li><strong>Iterator</strong> - Provides a way to access elements of an aggregate object sequentially without exposing its underlying representation.</li>
<li><strong>Mediator</strong> - Defines an object that encapsulates how a set of objects interact, promoting loose coupling by preventing objects from referring to each other explicitly.</li>
<li><strong>Memento</strong> - Captures and externalizes an object's internal state without violating encapsulation, so the object can be restored to this state later.</li>
<li><strong>Observer</strong> - Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.</li>
<li><strong>State</strong> - Allows an object to alter its behavior when its internal state changes, appearing to change its class.</li>
<li><strong>Strategy</strong> - Defines a family of algorithms, encapsulates each one, and makes them interchangeable, letting the algorithm vary independently from clients.</li>
<li><strong>Template Method</strong> - Defines the skeleton of an algorithm in a method, deferring some steps to subclasses, letting subclasses redefine certain steps without changing the algorithm's structure.</li>
<li><strong>Visitor</strong> - Represents an operation to be performed on elements of an object structure, letting you define new operations without changing the classes of the elements.</li>
</ol>
<p>These patterns provide proven solutions to common software design problems, promoting code reuse, flexibility, and maintainability in object-oriented systems.</p>
<h2>Links to more external resources not mine...</h2>
<blockquote style="position: relative; font-style: italic; margin: 10px 0 0; padding: 10px 12px; border-left: 3px solid #60a5fa; border-radius: 10px;">
<p>I'm not affiliated with nor profit from these Books, they are just here for your and my convenience.</p>
<p>Modern PHP 8 Design Patterns Online Version: <a href="https://designpatternsphp.readthedocs.io/en/latest/">https://designpatternsphp.readthedocs.io/en/latest/</a></p>
<p>PDF Version: <a href="https://designpatternsphp.readthedocs.io/_/downloads/en/latest/pdf/">https://designpatternsphp.readthedocs.io/_/downloads/en/latest/pdf/</a></p>
<p>Nice Book for sale: Buy Dive Into DESIGN PATTERNS An Ebook on design patterns and the principles behind them: <a href="https://refactoring.guru/design-patterns/book">https://refactoring.guru/design-patterns/book</a></p>
<p>PHP Code from the Book above: <a href="https://refactoring.guru/design-patterns/php">https://refactoring.guru/design-patterns/php</a>, If you liked it; Please support them by buying the book above...</p>
<p>"The Gang of 4 book" - Design Patterns: Elements of Reusable Object-Oriented Software By Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Published Oct 31, 1994. Buy here it: <a href="https://www.informit.com/store/design-patterns-elements-of-reusable-object-oriented-9780201633610">https://www.informit.com/store/design-patterns-elements-of-reusable-object-oriented-9780201633610</a></p>
<p><a href="https://www.informit.com/imprint/series_detail.aspx?st=61147">More on The Addison-Wesley Professional Computing Series</a></p>
</blockquote>
</body>
</html>