Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


how to use composition correctly using -'c#,design-patterns'


how to use composition correctly  using -'c#,design-patterns'

[DataContract(Name = "jobDateTimeFilterRequest", Namespace = Constants.ManagementNamespace)]
public class JobDateTimeFilterRequest : TimeFrame
{
    [DataMember(Name = "jobType")]
    public BackgroundJobType JobType { get; set; }
}

[DataContract(Name = "timeFrame", Namespace = Constants.ManagementNamespace)]
public class TimeFrame
{
    [DataMember(Name = "from")]
    public DateTime From { get; set; }

    [DataMember(Name = "to")]
    public DateTime To { get; set; }
}


I would like to use composition instead of inheritance.
To do this I will need to create:

[DataContract(Name = "jobFilterRequest", Namespace = Constants.ManagementNamespace)]
public class JobFilterRequest
{
    [DataMember(Name = "jobType")]
    public BackgroundJobType JobType { get; set; }
}


And JobDateTimeFilterRequest will be like this:

[DataContract(Name = "jobDateTimeFilterRequest", Namespace = Constants.ManagementNamespace)]
public class JobDateTimeFilterRequest
{
    [DataMember(Name = "jobType")]
    public JobFilterRequest JobFilter { get; set; }

    [DataMember(Name = "timeFrame")]
    public TimeFrame TimeFrame{ get; set; }
}


I'm I right? Or it's incorrect understanding of composition?
    

asked Sep 7, 2015 by rajesh
0 votes
5 views



Related Hot Questions



Walkin Jobs Opening



Government Jobs Opening


...