DEV Community

Discussion on: Solid Principles in Javascript

Collapse
 
dimpiax profile image
Dmytro Pylypenko • Edited

Hey, in your example of S, good to see clear example of responsibilities conjunction, where you follow also D principle:

// process
validateRequest = (req) => isValidForm(req) && createUser(req)

//Call an external function to validate the user form
isValidForm = (req) => testForm(req.name, req.password, req.email)

//Only Create User in the Database
createUser = (req) => User.Create(req.name, req.password, req.email)

What is the purpose of example in I:

initiateUser() {
  this.username = this.username; // this?
  this.password = this.password; // this?
  this.validateUser(this.username, this.password);
}
Collapse
 
francescoxx profile image
Francesco Ciulla

Dear Dmytro,
Thank you for noticing, the example in "I" has been revised.
But the intent was to just show the purpose of the principle, not the concrete implementation, which is lacking of course! As the validation method is just loggining a string :)