Your task is to create a Project Plan class library that supports task tracking (similar to how MS Project works). This class library has a Task object (among others).
The Task object has the properties EstimatedHours ( Double ), StartDate ( DateTime ), and EndDate ( DateTime ). A Task object can have one parent Task element and several child Task objects. The properties of EstimatedHours , StartDate and EndDate a Task , which have children (parent), depend on the properties of its immediate children. Parent Task StartDate is the earliest StartDate its children. Parent Task EndDate is the last EndDate its children. The parent of the Task EstimatedHours is the sum of its children of EstimatedHours . Therefore, it is not valid to change these properties to a Task that has children.
How would you handle the use case when the values ββof EstimatedHours, StartDate, or EndDate were changed to a job with a parent? (parent properties are a reflection of its children, so any changes to children may require that the parent properties be adjusted to reflect the corresponding changes)
One option is to have an event when each property changes. The parent Task will listen for these events on its child Task objects and make appropriate changes to its own properties when these events occur. Is this a good approach, or is there a better way? How would you do that?
Here is the basic idea of ββwhat the Task object might look like:
Public Class Task Private mChildren As List(Of Task) Private mEndDate As DateTime = DateTime.MinVlue Public Property EndDate() As DateTime Get Return mEndDate End Get Set(ByVal value As DateTime) mEndDate = value 'What to do here? End Set End Property Private mEstimatedHours As Double = 0.0 Public Property EstimatedHours() As Double Get Return mEstimatedHours End Get Set(ByVal value As Double) mEstimatedHours = value 'What to do here? End Set End Property Private mStartDate As DateTime = DateTime.MinVlue Public Property StartDate() As DateTime Get Return mStartDate End Get Set(ByVal value As DateTime) mStartDate = value 'What to do here? End Set End Property End Class
source share