Solid Principles in java with examples
SOLID is one of the most popular sets of design principles when developing object-oriented software. It is a mnemonic acronym for the five design principles which follow: S ingle Responsibility Principle O pen- Close Principle L iskov Substitution Principle I nterface Segregation Principle D ependency Inversion Principle 1) Single Responsibility Principle (SRP) The Single Responsibility Principle (SRP) states that a class should only have one responsibility. Additionally, it should have just one reason to change. A lot of members can exist as long as they relate to the single responsibility. It could be that multiple class members may need modification when the one reason for change occurs. Multiple classes may need to be updated, too. Example: class Movie{ public String author(){...} public void displayDetails(){...} public void updateMovie(){...} } Here we have logic...