Have any one used the SOLID programming principle (or any of it's parts) while developing JavaScript?
I've just started up on reading on it but can't seem to find anyone that used it for JS. The only part I find easy to implement/use is the "Single responsibility principle".
What I'm looking for is articles or example where these principles are used. And are there any argument's why one shouldn't use some parts?
For example the "Interface segregation principle" says that "the notion that many client specific interfaces are better than one general purpose interface."
But from my knowledge there's no such thing as interfaces in JS (nice if it would be).
The single responsibility principle is one of five object-oriented design (OOD) guidelines that comprise the SOLID design principles.
SOLID stands for. S: Single Responsibility Principle. O: Open-Closed Principle. L: Liskov-Substitution Principle. I: Interface Segregation Principle.
Are the SOLID principles applicable to Functional Programming? Of course. Functional programmers want to separate their code to avoid crosstalk between responsibilities and users. They want to minimize the number of modules affected by a change.
It looks like Derek Greer is attempting to take a stab at this with his article series on SOLID JavaScript at Fresh Brewed Code:
JavaScript sometimes gets a bad rap as being sub-par to those such as C++, C#, and Java, when in fact it's a very powerful functional programming language that also has object oriented capabilities (although it's not really classified as object oriented)
Perhaps many developers look down on it because so many of them are used to seeing poor programming practices and consequently, buggy behavior in JavaScript. For some unknown reason, it seems more acceptable to be sloppy on the client side. This is something I would like to change.
I believe these SOLID principles are solid. (No pun intended). If you follow these conventions, you will be less likely to accumulate technical debt created by sloppy code, shortcuts, and no architecture. Your code will be more maintainable, more reusable, more modular, less tightly coupled, and scalable and extensible. You'll also be contributing to demonstrating the full power of JavaScript when your product is engineered instead of just recklessly slapped together.
This document describes the fundamentals of SOLID. The same rules apply whether you're referring to C++, Java, JavaScript, or any other object-oriented language.
Code Project - The SOLID Object Oriented Programming Principles
Here is some more information on JavaScript concepts on colourcoding.net.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With