10 OOP Design Principles Every Programmer Should Know
Originally published by Javin Paul on May 5th 2019 The Object-Oriented Design Principles are the core of OOP programming, but I have seen most of the Java programmers chasing design patterns like Singleton pattern, Decorator pattern, or Observer pattern, and not putting enough attention on learning Object-oriented analysis and design. It’s important to learn the basics of Object-oriented programming like Abstraction, Encapsulation, Polymorphism, and Inheritance. But, at the same time, it’s equally important to know object-oriented design principles. They will help you to create a clean and modular design, which would be easy to test, debug, and maintain in the future. I have regularly seen Java programmers and developers of various experience level, who have either never heard about these OOP and SOLID design principle, or simply doesn’t know what benefits a particular design principle offers and how to apply these design principle in coding. To do my part, I have jotted down all important object-oriented design principles and putting it here for quick reference. These will at least give you some idea about what they are and what benefit they offer. I have not put examples, just to keep the article short but you can find a lot of examples of these design principles on the internet and even on my Java blog, just use the search bar at the top of the page. If you are not able to understand a design principle, you should try to do more than one example because sometimes we connect to another example or author better but you must understand these design principles and learn how to use it in your code. Another thing you can do is to join a comprehensive object-oriented design course like SOLID Principles of Object-Oriented Design by Steve Smith on Pluralsight. It has helped me a lot in my understanding and application of these principles. Btw, I have shared some relevant and useful courses and books here and there, both free and paid, and I will earn some money if you buy something which is not free. They are also some of the resources I have used to learn SOLID design principles and Programming in general and nice for learning some of these principles in depth. 10 Object Oriented and SOLID Desing Principles for Programmers Though the best way of learning any design principle or pattern is a real-world example and understanding the consequences of violating that design principle, subject of this article is Introducing Object-oriented design principles for Java Programmers, who are either not exposed to it or in the learning phase. I personally think each of these OOP and SOLID design principles needs an article to explain them clearly, and I will definitely try to do that here, but for now, just get yourself ready for a quick bike ride on design principle town 🙂 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, » Read More
Like to keep reading?
This article first appeared on hackernoon.com. If you'd like to keep reading, follow the white rabbit.