educative.io

Can you please explain the difference between Abstract vs Encapsulation in other ways?

  1. Why don’t we use regular class in place of abstract class and override the methods?
  2. What exactly do you mean by “hides unnecessary data to simplify the structure.” ?
  3. even using a regular class we can define a common behaviour. why do we need abstract class? for e.g partial method implementation still can be achieved using regular classes and overriding concept

Course: Grokking the Low Level Design Interview Using OOD Principles - Learn Interactively
Lesson: Abstraction

Hello @Ashok_Murthy,

  1. While regular classes and method overriding can achieve similar results, abstract classes offer a more formal and structured approach, particularly beneficial when designing a framework or a set of related classes with shared behaviors.

Happy Learning :slight_smile:

Hello @Ashok_Murthy,

  1. “hiding unnecessary data to simplify the structure” means encapsulating the implementation details within a class, presenting a clean and straightforward interface to the outside world. This promotes code simplicity, and maintainability, and reduces the likelihood of errors.

Happy Learning :slight_smile:

Hello @Ashok_Murthy,

  1. Regular classes with method overriding can achieve common behavior, abstract classes offer a more structured and explicit way to design class hierarchies, particularly when you want to enforce a specific structure or behavior across a group of related classes. It’s about choosing the right tool for the job based on the design requirements.

Happy Learning :slight_smile: