You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't really worked with SOLID much in javascript, but I thought it would be nice to kick off a conversation around it since it's something I really enjoy!
Let's use the listener class as an example. This class is violating SRP. It has loads of reasons to change. Usually this means there is a high chance of new bugs being introduced. Developers coming onto the project would most likely just add another event to this class. After time it could get pretty long. The thinking is:
A class should have one and only one reason to change, meaning that a class should have only one job.
The code also doesn't follow the open-close responsibility. Which means
Objects or entities should be open for extension, but closed for modification.
It would be great if all a developer needed to do was add another file which is the event and this would dynamically be picked up via the listener.js.
So your directory structure would look something like
I haven't really worked with SOLID much in javascript, but I thought it would be nice to kick off a conversation around it since it's something I really enjoy!
Let's use the listener class as an example. This class is violating SRP. It has loads of reasons to change. Usually this means there is a high chance of new bugs being introduced. Developers coming onto the project would most likely just add another event to this class. After time it could get pretty long. The thinking is:
The code also doesn't follow the open-close responsibility. Which means
It would be great if all a developer needed to do was add another file which is the event and this would dynamically be picked up via the
listener.js
.So your directory structure would look something like
I can go on, but it's something I would dig to chat about! I love learning and trying to improve my coding style.
The text was updated successfully, but these errors were encountered: