DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Frameworks
  4. Is the Object-Oriented Paradigm a False Hope?

Is the Object-Oriented Paradigm a False Hope?

Does OOP live up to the hype?

Dmitry Egorov user avatar by
Dmitry Egorov
CORE ·
Sep. 30, 19 · Opinion
Like (13)
Save
Tweet
Share
33.72K Views

Join the DZone community and get the full member experience.

Join For Free

For the last 20 years, Java has become the most popular object-oriented language. It conquered the enterprise world and still has one of the biggest communities. Now industrial development exists only because of the object-oriented paradigm (OOP). But here, I want to bring up skepticism about its fundamental paradigm. First, let's return to the past when Java didn't exist.

You may also like:  Misunderstanding OO Programming

Historical Reference

Programming before Java

1985 — the is the year when C++ was released the first time. C++ supported an object-oriented model and even had generics. The object-oriented design was becoming more and more popular. In 1994, the most popular book about design patterns was published, called the "Gang of Four (GOF)." GOF is still one of the most famous and recognizable books on design patterns (with about 23 patterns total).

Later, in 1995, Java 1.0 was released. It was a significant milestone for OOP, being the first completely object-oriented language. Java established the idea that "everything" is an object, and thus helped spread the OOP idea around the world.

Ambiguity of Patterns

In theory, each pattern is represented by a simple structure that is transparent to anyone. But in reality, the situation is quite different:

  • Some patterns became anti-pattern or irrelevant (e.g. the strategy pattern lost all value after Java 8 due to the Supplier interface)

  • Many patterns are recognized differently by developers, especially in terms of pattern usage

  • Some patterns have no practical value and exist only as a museum piece

  • Only on Wiki does the number of patterns exceed more than 50. But, in actual Java, only 13 keywords are responsible for the object structure, and among them, only 10 are generally used.

Object-Oriented Pollution

Java Builder Contstructor

Unfortunately, the majority of enterprise projects become unsupportable quite rapidly. As a consequence, many enterprise projects are facing a constant migration process and unacceptable timelines. And sometimes, bug-fix estimation takes more time than simply re-writing from scratch.

In addition, the word "legacy" scares IT employees more than ever before. According to my experience (more than 30 enterprise projects), the key problem is the project's architecture, which looks like a mess of patterns than anything else.

Cargo CultOOP Cargo Cult

Some patterns are used inappropriately — called the OOP cargo cult.

Often, many patterns are used inappropriately or without any purpose, and this is all so that they can follow "modern OOP trends," sometimes referred to as the OOP cargo cult.

Procedural Style

In procedural development, the key logic is stored in functions. Functions "communicate" with each other by sending and receiving parameters, AKA "messages". The global status contains arrays, structs, or constants — pure data.

OOP Style

In the object-oriented world, the program is based on its structure (objects). Functions are playing a secondary role and just change the state of objects. And an objects' state orchestrates the application. Logic became distributed between functions and structures. 

Salary Calculator Program in Procedural Style

Image title

Everything is transparent. 4 parameters = input and 1 = output. Nothing to add.

Salary Calculator Program in OOP style

Image title

Looks easy, but we ignored the encapsulated part:

Image title

How to Avoid the OOP Curse? 

  • Use a pattern with a full understanding of its purpose — no cargo cult!
  • Do not shift logic in the object, if it's possible
  • Use functional features, Akka Streams, and method references to methods
  • Do not be afraid to write average size methods, e.g. 50 lines
  • Use pure methods without changing state inside (pass only by value and return value)
  • Do not spread one functionality between many layers. Maintain visibility. 

Further Reading

Misunderstanding OO Programming

A Systematic Approach to Write Better Code With OOP Concepts

10 Commandments of Object-Oriented Design

Object-oriented programming Object-oriented design

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 5 Factors When Selecting a Database
  • Key Considerations When Implementing Virtual Kubernetes Clusters
  • Load Balancing Pattern
  • Distributed SQL: An Alternative to Database Sharding

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: