3

I have been trying to understand componentization(contrasting to the OOP concepts and also called component oriented programming), in relation to C++.

I have researched regarding this on internet but there were very little structured information available. The windows COM object seems pretty componentized. I have found http://c2.com/cgi/wiki?ComponentDefinition useful.

What could be the best and simple C++ code example, to illustrate the componentization concept?

I have a few high level ideas,like:

  1. I have an English word. A word is made up of several symbols or characters. Now, each character can be of several types like alphabetic, numeric, punctuation, whitespace, etc. So, each alphabet,number,etc. represent the fundamental components, based on which, a word will be formed and will come into existence. The word becomes an aggregate component(of symbols), based on which a sentence will be formed and so on.

  2. The protons, neutrons and electrons are individual agrregate components which form an atom.

Then, how is composite design pattern different from the componentization concept?

Please guide me. Thanks.

askmish
  • 6,464
  • 23
  • 42
  • Concepts (the C++ idea of restricted templates) have nothing to do with this. – Xeo Aug 01 '12 at 11:00
  • @Xeo: the word "concept" has a meaning separate from the C++ notion. C++ type Concepts were not mentioned in the OP. – Rook Aug 01 '12 at 11:04
  • @Rook: Look at my edit, I removed a specific tag. ;) – Xeo Aug 01 '12 at 11:06
  • 1
    Ahh, right. Bit of a namespace collsion, really! – Rook Aug 01 '12 at 11:12
  • I've never heard of componentization, but if what you mean is component based programming (as often implemented by RAD IDEs), then I've been living with it for quite some time and I can give some information about it :) – LeleDumbo Aug 01 '12 at 11:42
  • @LeleDumbo yes, componentization is a term based on component oriented programming, itself. – askmish Aug 01 '12 at 12:05
  • C++ doesn't support this well. Every platform has its own way of doing this, often multiple ways. You do therefore have to mention what platform you are targeting to get a usable answer. – Hans Passant Aug 01 '12 at 12:35
  • @HansPassant I do not think the C++ example implementation for componentization, would be restricted by platform restrictions. Then, reusability(one of the benefits of using components) of the code is also affected by platform. Anyways, I will be writing, on Linux i686/i386/powerPC. Let me know, if I need to edit the question for this. – askmish Aug 01 '12 at 12:46

1 Answers1

1

'Composite' as you mentioned is a design pattern. A design pattern is a problem-solution pair applicable during the design of a piece of software.

If I understand your interpretation of the term 'componentization' correctly, it is an architectural princicple which is followed in a higher abstraction level than the design to define the structure of the SW.

(If you are interested in precisely what I mean by architecture, please refer this paper which tries to define the terms design/architecture formally.)

If you get slightly more deep, 'Composite' helps to treat the container and the contents with the same interface. e.g, if you apply 'composite' pattern in your example, you could define an interface 'particle' and then can treat atom/electron/proton/neutron as particles and at the same time the container/content relationship is also maintained. This is a very specific problem-solution pair which can arise only in certain situations.

However, 'Componentization' can be applicable in more broader situations and you are not bothered if there is any container-content relationship in the first place. Even if there is such a relationship between the components, you don't care to treat them with the same interface.

PermanentGuest
  • 5,213
  • 2
  • 27
  • 36