Core Classes

The following diagram depicts the core classes of NCommet.

Entities.png
  • Item: Item is the base class. Using many items together results in ordered trees and directed graphs. An item may contain arbitrary content, but that content must be a class derived from ContentBase.
  • ContentBase: ContentBase is an abstract class that every content class must inherit, in order to be placed inside an item.
  • RelItem: A relItem expresses the relationship between two items in a graph. A relItem connects two items, starting from the subject item that owns the relationship and ending at the object item, also described as relative item. A relationship is annotated with a user defined string, the relation type. Using different relation types it is possible to support multiple graphs and distinguish among many relations between two items.
  • ChildrenCollection: ChildrenCollection is a container type that implements IList. A ChildrenCollection instance always belongs to a specific item and contains the items that are direct children of that item in the relevant ordered tree. The order of the items inside the ChildrenCollection is important and specified by the user.
  • RelItemCollection: RelItemCollection is also a container type implementing IList that is owned by an Item. The collection contains the RelItems where the subject item is the owner item of the collection.
As far as the implementation goes, ChildrenCollection could have been skipped in favor of putting all of those methods inside the Item class. For example instead of ChildrenCollection.Add we could have gone with Item.AddChild. That design would have lead to a huge Item class with an obscure API. Implementing a separate class for that functionality is concise with the standard practices of OOP regarding container types. Moreover, using an existing .NET container type such as List was not preferred because the methods of ChildrenCollection encapsulate business logic that is critical to be always executed, e.g. typed tree validation must always be performed on each Add method. That would leave the responsibility of enforcing extra business logic to the final user of NCommet which would be error prone and confusing. Therefore implementing a separate class provides a common API, since the class implements standard IList interface, keeps the Item class targeted to its purpose and encapsulates business logic that is critical to the framework. (The same apply to RelItemCollection)

Last edited Apr 11, 2008 at 11:24 AM by NikolaosGeorgiou, version 5

Comments

No comments yet.