r/learnprogramming • • Apr 05 '22

Name one programming/comp sci concept you never understood and if you understand it, try to explain it to them

Name a programming concept such as virtual functions, pointers, certain algorithms, etc that you always had a hard time understanding and why.

Someone else who reads yours and does understand it, try to explain it to them to help them learn

1.6k Upvotes

738 comments sorted by

View all comments

15

u/rhett21 Apr 05 '22

OOP. Currently taking DSA in C++, always confused what's an object, and when does an object get promoted to OODesign.

1

u/[deleted] Apr 06 '22

OOP is a paradigm that attempts to communicate in code the concepts that exist in an application (e.g. Order, etc.). There should be a mapping (ideally anyway) between the real world and its representation in software. That's it really.

To understand how to apply it for business concerns, IMO, you need some background in business analysis - specifically how business entities are defined and how business processes are modeled. Business analysis is not a software development discipline, it's different altogether, you can do business analysis to improve the processes in a company without involving software. But it is useful to know of its modeling tools, because then you'd see how business objects can be represented as classes, or how certain business processes can be represented as classes.

Of course there's a different way of applying OOP for technical concerns (e.g. creating a database adapter, a wrapper for a REST API). Although most of the techniques in this area is laid out in common design patterns.

They key to applying OOP effectively is to make sure you are distinguishing from business concerns and technical concerns. For business concerns, never force a design pattern to accomplish them, use plain objects and try to mirror the abstract model (e.g., DFD) for your business concerns when you can. While technical concerns are rigorously structured (e.g., rules for a database adapter), the real world from which business concerns derive from is chaotic and constantly change, so don't over-engineer with patterns on this end, use plain objects as much as possible.