Fundamentals 6 min read

Reflections on Object‑Oriented Design, SOLID Principles, and Design Patterns

The author shares personal reflections on OOP, SOLID, composition versus inheritance, design patterns, and layered architecture while recounting a recent project refactoring experience and emphasizing practical insights over textbook theory.

Java Captain
Java Captain
Java Captain
Reflections on Object‑Oriented Design, SOLID Principles, and Design Patterns

Origin

Recently I was assigned a project refactoring with ample time and space, but the system is complex and involves many business teams, leading to many big and small requirements. I wanted to avoid writing bad code that would cause overtime fixes, so I decided to record some scattered thoughts without worrying about structure.

Object‑Oriented Is Still the Main Design Style

Understanding OOP is more important than memorizing encapsulation, inheritance, and polymorphism from textbooks. The real value lies in concepts such as Inversion of Control, Dependency Injection, and the SOLID principles, and how they can be applied in practice.

The World Is Stateful, So Our Code Is Full of States

Because the world has state, OOP’s class‑based encapsulation helps hide dirty states behind objects, limiting their impact.

Composition Over Inheritance

The phrase “composition over inheritance” often sounds like empty jargon similar to “high cohesion, low coupling”. The Decorator pattern is a classic example of composition, but the exact meaning of the phrase remains vague to many.

Inheritance Is Not Entirely Bad; Multiple Inheritance Should Be Avoided

Some authors pit composition against inheritance, but both are tools for different scenarios. In Java, excessive use of interfaces and deep inheritance hierarchies can lead to over‑engineering, reducing developer joy.

Design Patterns Are Useful

When forced to use design patterns without real need, they can be harmful. In my refactoring I employed the Factory Method and Template Method patterns, especially the latter, which made bug fixing much faster.

OOP vs. FP

I know a little about OOP and little about functional programming. Comparing the two often leads to biased conclusions; they are simply different techniques suitable for different problems, and a hybrid approach is usually best.

Layered Thinking

All software is layered, which reduces cognitive load and enables large‑scale design. However, layers should not become too fine‑grained; moderation and experience are key.

Books: “Refactoring” and “Clean Code”

Both books have profoundly influenced me; repeated readings reveal new insights and help internalize the authors’ tacit knowledge.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Design PatternsOOPSOLID
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.