Design is the creation of a plan or convention for the construction of an object, system or measurable human interaction
A pattern is a discernible regularity in the world or in a manmade design. As such, the elements of a pattern repeat in a predictable manner.
A general reusable solution to a commonly occurring problem within a given context in software design.
It is not a finished design that can be transformed directly into source or machine code.
It is a description or template for how to solve a problem that can be used in many different situations.
User data is hard to ask for. Write a function that gets user data from lots of services and aggregates it
User data is sparse (some fields might not exist), and irregular. It is difficult to work with objects that might contain incomplete or missing data.
FakeBlock is extremely privacy focused, create a user object which contains a full birthdate, but only exposes the day and month.
Javascript doesn't have a concept of public and private data members, in fact it doesn't really even have a concept of classes
codepen demo
Add a comment feature to images
Repetitive work is hard to maintain, leads to copy-paste-errors, JavaScript inheritance patterns can be deceptive
Combining (composing) functionality can be difficult and hard to keep compatible.
Add a comment feature to ads
Add a like feature to posts
Combine comments and likes to create enhanced posts
AKA decorator or mixin pattern
codepen demo
HTTP://SLIDES.COM/CORYBROWN/CLASSICAL-INHERITANCE
We need a way to notify several services when someone comments: send to database, clear the cache, search for NSA keywords
Your comment feature only has one callback to be executed on completion, and you don't want to refactor it every time a new notification request comes in
Publish Subscribe
Codepen demo
https://addyosmani.com/resources/essentialjsdesignpatterns/book/