Note: Also, the bellow exemples are not complete. They are only pseudo code and there could be improvements to that.

These are the solid principles

  • Single responsibility principle - a class should have only a single responsibility - One reason to change
  • Open/closed principle - software entities … should be open for extension, but closed for modification.
  • Liskov substitution principle - objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface segregation principle - many client-specific interfaces are better than one general-purpose interface.
  • Dependency inversion principle - one should “depend upon abstractions, [not] concretions.

Not a SOLID example.

Violations

  • Single responsibility
    • Connects to the DB
    • validates uniqueness of mail
    • validates email format
    • validates password format/strength
    • inserts record in the data base
    • sends email
  • Open Closed
    • What if we do not want to use Email? What if we want to use SMS? Push notification?
  • Liskov substitution principle
  • not yet
  • Interface segregation principle
  • not yet
  • Dependency inversion principle

After SOLID.