What exactly is Component Oriented Programming, and how is it different from Object Oriented Programming?
Thanks
What exactly is Component Oriented Programming, and how is it different from Object Oriented Programming?
Thanks
I'd call Component Oriented Programming a specialized descendant of Object-Oriented Programming, in that the goal is to produce easily-reusable generic objects.
In the late 1990s, I attended an Open House at the UT Austin Department of Computer Science. My goal was to talk to an old friend, a professor, to get some insight into a problem I'd encountered at work. (He gave me the exact pointer I needed, and also suggested I talk with another old friend, who also gave me very good help.) While I was there, I talked with some other people, one of them being Don Batory, who was working on building program generators that made it easy to construct and compose (fit together) component objects.
His comment was that object-oriented programming was not enough. It gave you objects with defined interfaces, but they weren't necessarily cleanly reusable. It takes an extra level of design effort to keep extraneous concerns from creeping into the object. Dr. Batory had come into this from the database world, trying to make it easier to build database systems. At one point, he'd heard about guys working a somewhat similar problem in operating systems construction, and was shocked to discover that the solution they were working was darned near identical to what he was doing, indicating that there was an underlying body of reusable knowledge.
Real Example: On a project I worked in the mid-1990s, there was a "business rule" that the laser rangefinder should not be fired unless the tracker was locked on a target. The object-oriented method allows passing the lock status into the rangefinder object, as a final interlock on the firing command. The component model says that the rangefinder object exports a Fire() method, and the business logic that uses the rangefinder checks the target lock status before pulling the trigger.
Whilst the OOP approach focuses on the relationship between classes, COP focuses more on interchangeable modules that work independently and don't require the need to know exactly how they work.
Edit - I don't think this is unclear, the question addresses the difference in approach, they are not entirely separate. In COP, a module can be considered a reusable, function-driven object (often a group of classes) that can be used and reused as is. OOP is more granular, focusing on the individual classes themselves which, likely require specific interaction with other classes to perform functionally.