Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why object-oriented programming?

0
Posted

Why object-oriented programming?

0

Often we have to deal with several data structures (objects), that have to be treated similarly in some respects, but differently in others. Graphical objects are the textbook example: circles, triangles, dinosaurs, icons, and others, and we may want to add more during program development. We want to apply some operations to any graphical object, e.g., draw for displaying it on the screen. However, draw has to do something different for every kind of object. We could implement draw as a big CASE control structure that executes the appropriate code depending on the kind of object to be drawn. This would be not be very elegant, and, moreover, we would have to change draw every time we add a new kind of graphical object (say, a spaceship). What we would rather do is: When defining spaceships, we would tell the system: “Here’s how you draw a spaceship; you figure out the rest”. This is the problem that all systems solve that (rightfully) call themselves object-oriented; the object-oriented

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.