[Mono-list] Component vs. Class

A Rafael D Teixeira rafaelteixeirabr@hotmail.com
Thu, 15 Jan 2004 17:59:14 -0200

Well, mainly, any subclass of Component can be easily (for example, just by 
dragging and dropping in the Visual Studio.NET Form Designers) inserted in a 
container (like a Form, a Control, or any other Component), and manipulated 
by the editing environment (like having properties exposed for editing in 
the Properties Window).  All of this is currently of  little use for Linux 
developers using Mono as we are still creating the equivalent tools.

Functionality already in the Component superclass, facilitate orchestrating 
some functions like serialization/deserialization/disposal/etc.. over a 
whole tree of containers of containers of ... components.

Another piece of information: Component is also a superclass for class 
Control, because although not all Components need to be Visual Widgets, all 
Visual Controls have to be Components.

Let's see some examples of commonly used classes that are Components but 
aren't Controls : ADO.Net Datasets, DataAdapters and Connections derive from 
Component and they can be dragged to a form so that DataBinding can be all 
set up, just by setting properties.

In some of my previous designs, I've architected the front-controllers to my 
business objects as Components to make for easier integration in the UI 
Layer, but only when effective reuse paid for the extra effort.

If you want to go deeper: Component-Oriented Analisys, Design and 
Programming, is nowadays a field of study slowly coming to mainstream use 
(book: UML Components - John Cheesman & John Daniels, also: UML 2.0 Spec).  
But it goes beyond what class Component offers because if one needs to have 
real flexibility about plugging/unplugging or swapping parts of his 
solutions, one need to work around Interfaces (contracts) instead of 
inheritance.  When a design revolves around factories and interfaces, we 
probably are looking at a Component-Based solution.

Hope it helps,

Rafael Teixeira
Brazilian Polymath
Mono Hacker since 16 Jul 2001
MonoBrasil Founding Member - Membro Fundador do MonoBrasil
English Blog: http://monoblog.blogspot.com/
Brazilian Portuguese Blog: http://monoblog.weblogger.terra.com.br/

MSN Messenger: instale grátis e converse com seus amigos.