Kilimanjaro Warehouse

WEBとかゲーム開発のことについて書きます。

勉強メモ: オブジェクト指向とコンポーネント指向の違いについて

オブジェクト指向コンポーネント指向の違いがイマイチわからなかったので、
少し調べてみました。


個人的に一番しっくり来たのは、
こちらの質問記事のMike Dinescuさんの回答でした。
stackoverflow.com

I'm sure that others here will be able to give a better explanation of what component oriented languages are (and if they won't, a thorough search on the internet should) but the way I see it the component oriented paradigm can be viewed as an embodiment of object oriented programming.


That is to say that component oriented programming specializes Object Oriented Programming by strictly enforcing and implementing some OO concepts. Basically the whole idea is to create reusable code - in the form of components - that can be interchanged. So, component oriented programming heavily relies on: polymorphism, encapsulation, late binding, inheritance (through interfaces) and most importantly binary re-usability.


A component is a software package that encapsulates data and functionality - much like an object in OOP - but at a higher level.

以下、簡単に訳してみました。

コンポーネント指向言語が何かということについては、ここの人たちが良い感じの説明をしてくれるでしょう。
(そして、もししてくれなかったとしても、ネットで検索すれば出てくるでしょう)
私は、コンポーネント指向はオブジェクト指向プログラミングの強調版として見ることができると思っています。


つまり、コンポーネント指向プログラミングは
いくつかのオブジェクト指向のコンセプトを厳密に強制し、実践することによって、
オブジェクト指向を専門化させたものだということです。


コンポーネント指向の基本的なアイディアは、再利用可能なコードを交換可能なコンポーネントの形として作ること、それが全てです。
なので、コンポーネント指向プログラミングは、以下のものに強く依存しています。
それは、ポリモーフィズムカプセル化、遅延バインディング、 (インターフェースを通した)継承、そして最も重要なのはバイナリの形での再利用性です。


コンポーネントはデータや機能をカプセル化したソフトウェアのパッケージです。
それはオブジェクト指向プログラミングでいうところのオブジェクトに近いですが、より高いレベルにあるものです。

バイナリの形での再利用性については、以下の記事がわかりやすいかと思います。
1.2. Component-Oriented Versus Object-Oriented Programming - Programming .NET Components, 2nd Edition [Book]


結局どういうことかというと、
コンポーネント指向はオブジェクト指向の亜種みたいなもので、
焦点を当てている場所がより具体的で高いレベルにある...
という点に、オブジェクト指向との違いがあるのではないかという結論に至りました。