Skip to main content

6 docs tagged with "oop"

View all tags

Access Modifiers & Visibility

In Java, access modifiers are keywords that set the accessibility (visibility) of classes, constructors, methods, and fields. They are a fundamental aspect of encapsulation, an object-oriented programming principle that allows you to hide internal implementation details and control how other parts of the code can interact with your classes and their members.

Composition Over Inheritance

"Composition over Inheritance" (also known as "favor composition over inheritance") is a design principle in object-oriented programming that suggests that classes should achieve new functionality by composing objects of existing classes (i.e., by containing instances of other classes) rather than by inheriting from them. This principle promotes greater flexibility, reduced coupling, and better code reusability.

Interfaces vs. Abstract Classes

In Java's object-oriented programming (OOP) paradigm, both interfaces and abstract classes provide mechanisms for achieving abstraction and polymorphism. While they share some similarities, their primary purposes, capabilities, and use cases differ significantly.

Java OOP Principles

Object-Oriented Programming (OOP) is a programming paradigm that organizes software design around data, or objects, rather than functions and logic. Java is a purely object-oriented language, meaning almost everything in Java revolves around classes and objects.

Object Equality - equals() and hashCode()

In Java, determining whether two objects are "equal" is a fundamental concept, especially when working with collections. Java provides two methods in the Object class that are crucial for defining and managing object equality: equals() and hashCode(). Understanding their contract and how to override them correctly is vital for robust applications.

SOLID Principles

The SOLID principles are a set of five design principles in object-oriented programming intended to make software designs more understandable, flexible, and maintainable. They were promoted by Robert C. Martin (Uncle Bob) and are widely considered best practices for writing clean, robust, and scalable code.