You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Unable to render {include} The included page could not be found.

In the first version of DelftShell the following approach was implemented to manage different data of the project and models:

public enum DataItemRole { Input, Output, InputOutput, Debug }

public interface IDataItem
{
   int Id { get; set; }

   string Name { get; set; }
   string Description { get; set; }

   DataItemRole Role { get; set; }

   object Value { get; set; }
   Type ValueType { get; set; }

   object Owner { get; set; }

   IDataItem Parent { get; set; }
   IDataItem[] Children { get; }

   bool CanLinkTo(IDataItem child);

   event EventHandler Changed;
}

This interface is used to wrap various data items (stored in the Value property) and to add the following aspects to them:

  • Linking - Parent / Children / CanLinkTo
  • Identifiable - Id
  • Namable - all data should have name when they are added to the model or project
  • Value Container - data item is composed with object of certain type
  • Sends event on changes - when data object inside data item has been changed - it will send an even
  • Role - defines how data supposed to be used
  • Owner - defines object containing this data item

However during implementation of HABITAT and Verkenner the following issues appeared:

  • We had to change interface to abstract class in order to XML serialize it
  • As result attributes had to be added to each property which made it less readable XmlElement(...), XmlAttribute(...).
  • All data objects were forced to implement IDataItem which made them a bit more complicated then they should be.
  • It becomes too complicated for new developers to use and implement all aspects listed above in all their data classes.

Data items are used mainly in the Model and Project. And also shared between different view and services for example while two data items are linked.

In order to improve architecture the following was proposed:

Instead of deriving new data types from IDataItem:

public class TimeSeries: IDataItem
{
   #region IDataItem Members
   ...
   #endregion

   #region TimeSeries Members
   ...
   #endregion
}

public TimeSeriesInterpolationModel: IModel
{
   private IList<IDataItem> data;

   public TimeSeriesInterpolationModel()
   {
      data = new List<IDataItem>();

      TimeSeries timeSeries = new TimeSeries();
      timeSeries.Name = "input time series;
      timeSeries.Role = DataItemRole.Input;

      data.Add(timeSeries);
   }
}

Use the following approach:

public class TimeSeries
{
   #region TimeSeries Members
   ...
   #endregion
}

public TimeSeriesInterpolationModel: IModel
{
   private IList<IDataItem> data;

   public TimeSeriesInterpolationModel()
   {
      data = new List<IDataItem>();

      TimeSeries timeSeries = new TimeSeries();

      DataItem timeSeriesDataItem = new DataItem("input time series", typeof(TimeSeries), DataItemRole.Input);

      data.Add(timeSeriesDataItem);
   }
}
  • No labels