Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLID principles #49

Open
ryannealmes opened this issue Apr 5, 2016 · 0 comments
Open

SOLID principles #49

ryannealmes opened this issue Apr 5, 2016 · 0 comments

Comments

@ryannealmes
Copy link
Collaborator

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

listener.js
listener (folder)
- hangout_joined.js
- participant_changed.js
- consent_changed.js
- new_event_to_come.js
.
.

I can go on, but it's something I would dig to chat about! I love learning and trying to improve my coding style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant