7

What exactly is Component Oriented Programming, and how is it different from Object Oriented Programming?

Thanks

user3150201
  • 1,217
  • 2
  • 10
  • 9
  • The wiki gives a quite nice description: http://en.wikipedia.org/wiki/Component-based_software_engineering – Pieter B Feb 07 '14 at 09:17
  • Sounds the same, since a component or a system or a sub-system can be looked at as an object. – BЈовић Feb 07 '14 at 09:46
  • 1
    **Unclear what help you need.** Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it’s hard to tell what problem you are trying to solve or what aspect of your approach needs to be corrected or explained. See the [ask] page for help clarifying this question – gnat Feb 07 '14 at 10:07
  • 3
    @gnat The question seems clear to me. The OP has run into a methodology they think might be one they know by another name and is asking us to disambiguate it for them. I'm failing to understand why you think it's unclear. – Racheet Feb 07 '14 at 10:47
  • 3
    @Racheet I think the OP should read the wiki and then post a question about what's unclear to him. An answer here would basically be a verbatim copy of the wikipedia page. – Pieter B Feb 07 '14 at 11:41
  • @PieterB: Having read the wiki's section on the differences between the two, I still don't know the difference. I'm not sure the description of how OO programmers think isn't a strawman (I've seen OOP programmers claim that objects need not correspond to real world objects). I can't tell whether COP always uses objects, or whether it is just a codeword for "modular libraries". – Michael Shaw Feb 07 '14 at 15:44

2 Answers2

5

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.

John R. Strohm
  • 18,043
  • 5
  • 46
  • 56
3

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.

Gillespie
  • 177
  • 3
  • 2
    This is unclear. Are you saying that they're the same thing with a slightly different focus? I've heard OOP people talk a lot about objects working independently and other objects not needing to know how they work. – Michael Shaw Feb 07 '14 at 15:49