← Back to archive

Java Fundamentals: object orientation

Introduction to the object-oriented paradigm and the idea of representing problems through entities, objects, classes, and interactions.

Object orientation is a way of thinking about problems using entities, objects, and interactions between them.

Programming paradigms

A programming paradigm is a way of organizing reasoning to solve problems with code.

Rather than being just a syntax rule, a paradigm influences how we think about the solution: which parts the system will have, how those parts relate to each other, and how behavior will be organized.

There are several programming paradigms. One of the best known is Object-Oriented Programming, also called OOP.

What object orientation is

In object orientation, we don’t think of the system merely as a sequence of tasks.

We think in terms of entities that are part of the problem and how those entities interact with each other.

These entities can represent real-world elements or important system concepts, such as:

  • customer;
  • product;
  • order;
  • user;
  • payment;
  • tax.

From these entities, we create classes and objects to organize the code.

Representing real-world problems

OOP helps turn parts of a real problem into structures inside the code.

For example, in a customer management system, the real customer can be represented in the system by a Cliente class.

That class can concentrate customer-related information and behavior, such as name, email, document, and actions that make sense in that context.

This makes reading and maintenance easier, because the code is divided into smaller parts with clearer responsibilities.

Practical example

Imagine a system needs to calculate a specific tax.

Instead of leaving that rule scattered across several points in the code, it can be placed in its own class, with a name that makes clear which tax is being calculated.

That way, when the rule needs to change, it is easier to find where the logic lives and to understand the impact of the change.

Code reuse

An important benefit of object orientation is the possibility of reusing code in a more organized way.

The idea is not to copy and paste code snippets in several places.

The idea is to create reusable structures, with well-defined responsibilities, that can be used in different parts of the system when it makes sense.

Summary

Object-Oriented Programming is a paradigm that organizes code around entities, objects, and relationships.

It helps create systems that are easier to understand, maintain, and evolve, especially when the problem has several parts that interact with each other.

↑↓ to navigate · Enter to open 8 items in the index