Since I’m diving back into the world of Object-Oriented Programming, I figured it’s about time for a refresher on what it is all about. While javaScript is an Object-Oriented language, I don’t think I was utilizing its object-oriented nature very much, so coming to java has been a small learning curve.

Features of Object-Oriented Programming

  1. Objects and Classes: OOP revolves around the concept of objects, which are instances of classes. Classes define the blueprint for objects, encapsulating data and behavior.
  2. Encapsulation: This principle involves bundling the data (attributes) and methods (functions) that operate on the data into a single unit or class.
  3. Inheritance: Classes can inherit properties and behaviors from other classes, promoting code reuse and hierarchical relationships.
  4. Polymorphism: Objects can be treated as instances of their parent class rather than their actual class, allowing for flexibility and the ability to use a common interface.
  5. Abstraction: Hiding the complex implementation details and showing only the essential features of the object.

Features of Functional Programming

  1. Pure Functions: Functions have no side effects and return the same result given the same arguments, ensuring predictability.
  2. Immutability: Data is immutable, meaning it cannot be changed once created. This leads to more predictable and bug-free code.
  3. First-Class and Higher-Order Functions: Functions are treated as first-class citizens, meaning they can be assigned to variables, passed as arguments, and returned from other functions. Higher-order functions are functions that take other functions as arguments or return them.
  4. Declarative Approach: FP emphasizes describing what to do rather than how to do it, leading to more concise and readable code.
  5. Recursion: FP relies on recursion rather than iterative loops for repetition.