menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Read This ...
source image

Dev

3w

read

358

img
dot

Image Credit: Dev

Read This Before OOP-ing Your Project : The Curse of Inheritance.

  • The writer shares their experience of how Object-Oriented Programming (OOP) almost derailed their project despite loving OOP initially.
  • The complexity arose when working on a UI framework in C++, where issues with polymorphism and inheritance in strongly typed OOP languages became apparent.
  • Polymorphism in OOP allows different classes to inherit from the same parent but can lead to limitations in accessing specific behaviors of subclasses.
  • Solutions proposed include bloating the base class with all possible behaviors, premonition design anticipating future behaviors, and downcasting for runtime identification.
  • However, these solutions introduce complexities and make maintenance challenging, leading to a refactoring nightmare.
  • The writer suggests considering alternatives like Entity-Component-System (ECS), Procedural programming with 'Dead Objects,' and using Unions or Algebraic Types over OOP Inheritance for future projects.
  • They highlight the pitfalls of OOP in practice, especially in languages like C++, urging caution before fully embracing OOP for large projects.

Read Full Article

like

21 Likes

For uninterrupted reading, download the app