What's the difference between an Interface and a Component?

3 posts / 0 new
Last post
Rick
Offline
Joined: 12/07/2011
What's the difference between an Interface and a Component?

After reading the offending sections in the reference manual I'm not sure I understand the difference between the two.. From the reference manual, here is what I found :

 

  • In section I.4.2 I don't see any formal description of what an Interface is -- just this comment : "Since we are describing a generic interface (which may or may not turn to be an entity) we will use an Interface keyword."
  • In section I.4.6 I see the following description of a Component which makes sense : "A component is a data structure which is intended to be inlined in other components or entities. Like enti- ties and interfaces, you can define properties and behaviour in a component. A component cannot live by itself. It is an elegant mean to factor common data and behaviour into higher level model parts."

However, without a better understanding of what an interface really is and perhaps when it should be used over a Component, I'm not sure which I should use.. Can someone clue me in please?  Thx!!

 

P.S.  I'll update the docs with whatever I find out.. 

 

vvandens
Offline
Joined: 05/29/2008
What's the difference between an Interface and a Component?

Hi Rick,

Think of a component as a data-structure that is composable (even multiple times) into an Entity. Conceptually, it is not a 1st-level artifact, so it is not meant to be an entity by itself, but there is still a need for it to be factored (data and rules). For instance, in HRSample, there is the ContactInfo component that can be composed into various, unrelated entities; and for instance you could have 2 references of ContactInfo (personal, work) into the Employee entity. Since a Component is not an entity by itself, it won't have its own table, but its columns will be "added" to the owning entity table. The created component columns will be prefixed by the reference name (.g. 'work', 'personal'), so that multiple references are supported. Refer also to Hibernate components in their manual.

On the other hand, Interface is an inheritance concept (as opposed to a composition concept). One interface can only be inherited once and it is meant to factor a common state and/or behaviour among potentially unrelated entities. As for component, an Interface is not "important" enough to be mapped as an entity and introduce a stronger inheritance (that would be reflected by a new table in the DB). On the physical side, interface columns are also created and added to the implementing entities/components mapping tables.

Hope this is clearer now.

Don't hesitate to post back if you need a deeper explanation.

 

Best,

Vincent

 

Rick
Offline
Joined: 12/07/2011
Thanks Vincent!  Makes more

Thanks Vincent!  Makes more sense.. I think I'll try an example to add both an Interface and a component to an Entity and see how the resulting SQL differs to further clarify my question but I believe I understand what you're getting at now.  Thanks much!