Shall I use a domain model for each process?

Jan 13, 2013 at 12:34 AM
Edited Jan 13, 2013 at 12:35 AM

Hi Expert,

I am very love the silk's code and architecture. but there's one thing that I need to know.

Q : Shall I use one DomainModel for each Process or one DomainModel for multiple Process?

For example the DomainModel look like following code.

public class ProductDto

{

//Fields goes here

}

 

Or if the new process really need distinguished domainmodel so that we should create new?

Or create Interface or base DoamainModel or Abstract class?

 Which is the right choices?

Best Regards,

WP

Developer
Jan 15, 2013 at 5:19 PM

Hi,

I'm not sure if I fully understand your scenario, particularly it would be helpful to know what you mean with "multiple Process" and how do you want them to interact with your Domain Models, in order to have a better understanding about the scope of the application where the Domain Models are used.

On the other hand if your concern is related on how to implement the Domain Model and Data Transfer Object patterns in your application, I believe you could find Martin Fowler's Patterns of Enterprise Application Architecture useful regarding this topics, where these patterns are explained in further detailed.

Regards,

Agustin Adami
http://blogs.southworks.net/aadami

Jan 16, 2013 at 6:08 AM
Edited Jan 16, 2013 at 6:15 AM

Hi aadami,

Thanks, For example if I have 2 pages, 1 Page = 1 Process so that 2 pages = 2 process.

each page need the slightly different model.

e.g the Product page need ProductModel

public class ProductModel

{

public int ProductID { get; set;}

public string ProductName {get; set; }

public int ProductPice { get; set; }

}

e.g the Import Page need

public class ImportModel

{

public int ProductID { get; set;}

public string ProductName {get; set; }

public string Vendor { get; set; }

}

As you can see the Model is similar.

 Shall I have base abstract class for this or by using the interface?

E.G

public interface IBaseProduct

{

int ProductID { get; set;}

string ProductName { get; set; }

}

In some case the Process really need different dataModel, some are share model.

Thank for you understanding.

 

Best Regards,

Weera

Developer
Jan 16, 2013 at 3:52 PM

Hi,

In my opinion there is not only one way on how to implement your Domain Models, as far as I know there is no restriction on inheriting from abstract classes or implementing interfaces to define them. And it makes sense to use any of these approaches if they provide a benefit for your scenario.

For example in your case, I believe that due to the low complexity of the models you described using inheritance in this classes may not be of much help if the domain models contain only fields, as they don't have any shared logic that could be reused in them.

As another option, in cases where there is not much difference in the domain models like you mentioned, I believe that another possibility could also be to implement this two models in one domain model, and then consume only the required fields for each page.

Regards,

Agustin Adami
http://blogs.southworks.net/aadami

Jan 18, 2013 at 12:49 AM

Hi Agustin,

Thanks, for your response back. Actually, with the really it is really more complex than what you see above that is why I doubt.

Best Regards,

WP