https://github.com/medunes/gof-php
A playground of GoF, in PHP!
https://github.com/medunes/gof-php
Last synced: 4 months ago
JSON representation
A playground of GoF, in PHP!
- Host: GitHub
- URL: https://github.com/medunes/gof-php
- Owner: MedUnes
- License: mit
- Created: 2021-03-20T20:51:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-20T20:54:31.000Z (over 4 years ago)
- Last Synced: 2025-04-06T09:29:48.690Z (6 months ago)
- Language: PHP
- Size: 305 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
![]()
A GoF playbook in PHP
[](https://github.com/MedUnes/gof-php/actions?query=workflow%3A%22build%22)
[](https://twitter.com/medunes2)
[](https://shields.io/#/)
[](https://shields.io/#/)
## ℹ️ So what is this?
A [GoF](https://www.amazon.de/Patterns-Elements-Reusable-Object-Oriented-Software/dp/0201633612/) playbook in PHP
## ℹ️ Some Learnings/quotes from the book
* The point of learning design patterns is to prime your toolkit with solution ideas,
not to follow dogma when solving problems for a test.
* There's rarely a perfect choice in real-world scenarios. You have to balance trade-offs and decide what approach is best for the situation at hand.
* Strategy pattern and Visitor Pattern: two sides of the same coin?
> OOP are made up of objects. An object packages both data and the procedures that operate on that data.
> The procedures are typically called methods or operations.
> An object performs an operation when it receives a request (or message) from a client.> Requests are the only way to get an object to execute an operation.
> Operations are the only way to change an object's internal data.
> Because of these restrictions, the only way to change an object's internal state is said to be encapsulated;
> it cannot be accessed directly> Program to an interface, not to an implementation
* The latter should be delegated to creation design patterns.> "Inheritance breaks encapsulation" - Alan Snyder (1986)
> Favoring object composition over class inheritance helps you keep each class encapsulated and focused on the task
* Seems like Delegation as explained in GoF is the basis of the Interface Segregation in SOLID, right ?
> In general, the runtime structures aren't clear from the code until you understand the patterns
> If applications are hard to design, and toolkits [packages] are harder, then frameworks are hardest of all
* Abstract Factories: On demand generic interacting **families** of interfaces!
#### Where to contribute?
[CONTRIBUTING](https://github.com/medunes/gof-php/blob/master/CONTRIBUTING.md)