Search code examples
domain-driven-designdomain-data-modelling

best way to create domain design model?


UPDATE:

what i am looking is should i go create each classes seprately instead of adding getter/setter prop in the class, what i mean by that is:

so in order to create a Visit i should have the following prop in VISIT

VisitName, Purpose, StartDate, EndDate, HostId, HostName, RequesterId, RequeserName

or should i have this:

VisitName, Purpose, StartDate, EndDate, IPerson Host, IPerson Requester

END UPDATE

i need advice/feedback if i am going on the right direction below is the domain model (part of the project not entirly).

i have class called "Visit" in that Visit model i will have basic of visit like name,purpose,start,end date etc... and in that class i also have who will be hosting the visit and who request the visit.

what do you think of the below class?

enter image description here

 //aggreate class
public class Visit
{
    IVisitBasic _visitBasic;
    IPerson _host;
    IPerson _requester;

public IVisitBasic VisitBasic
{
    get { return _visitBasic; }
    set { _visitBasic = value; }
}

public IPerson Host
{
    get { return _host; }
    set { _host = value; }
}

public IPerson Requester
{
    get { return _requester; }
    set { _requester = value; }
}

public Visit(IVisitBasic visitBasic, IPerson host, IPerson requester)
{
    _visitBasic = visitBasic;
    _host = host;
    _requester = requester;
}

public Visit() { }

}


Solution

  • It looks ok as a start, but I wouldn't make a hard and fast domain model until you have actually started coding and testing the initial domain model as you will probably find that things don't quite work as expected or there is something that you have missed, or the requirements change, etc.

    Other points from a quick look.

    • What is the purpose of VisitBasic, should it be an abstract base class or the name made clearer?
    • You may want to make the host into it's own class, it may have information not relevant to the person class, so possibly a sub class of person. But as stated above it may be better to develop it iteratively. And possibly requester as well but probably less likely.

    UPDATE RESPONSE: The standard design now for most things is to add a service layer, i.e. VisitService with a createVisit method, and the properties on the visit object should just link to the host and requester without having any business logic in them. (Hope that answers your question?)