Principles Blog Posts

Design Principles Java

The Object-Oriented Design Principles are the core of OOP programming.They will help you to create a clean and modular design, which would be easy to test, debug, and maintain.
Object Oriented and SOLID Design Principles :
1. DRY (Don't repeat yourself) :
Our first object-oriented design principle is DRY, as the name suggests DRY (don't repeat yourself) means don't write duplicate code, instead use Abstraction to abstract common things in one place. If you have a block of code in more than two places consider making it a separate method, or if you use a hard-coded value more than one time make them public final constant.
The benefit of this Object oriented design principle is in maintenance. It's important not to abuse it, duplication is not for code, but for functionality. It means if you used common code to validate OrderID and SSN it doesn’t mean they are the same or they will remain the same in future.
By using common code for two different functionality or thing you closely couple them forever and when your OrderId changes its format, your SSN validation code will break. So beware of such coupling and don’t combine anything which uses similar code.
Don’t repeat yourself design principle is about abstracting out common code and putting it in a single location.

0 Likes 904 Views