
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
github.com/cnavas88/pattern_decorator
Project to practice and have an example of pattern decorator using golang and python.
Decorator is a structural design pattern it allows new behaviours to be added dynamically to objects by placing them inside special objects that wrap them (Wrappers).
By using decorators you can wrap objects many times. As the target of the objects and the decorators follow the same interface. The result object will get a stacking behaviour of all wrappers.
you are working in a coffee shop where they serve various products At first you only serve normal coffee and milk, but later you start to serve saccharine or sugar, with normal milk, semi milk, vanilla, chocolate, late, etc..
when we have to alter the funcionality of an object. The first it comes in my mind is extend a class. However, the inheritance has several important limitations.
The inheritance is static. We can't alter the funcionality of an exist object during execution time. Only can replace the whole object by other created from a different subclass.
Subclases just can have a father class. In the majority lenguages, the inheritance doesn't allow to a class inherit behaviours of several classes at the same time.
To solve this problem we can use the pattern decorator (Wrapper). The wrapper implements the same interface as the wrapped object. This is why, from the customer's perspective, these objects are identical.
The solution is in 2 languages: Golang and Python.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.