locked
Is a ViewModel a Domain Model? RRS feed

  • Question

  • User-305496339 posted

    Hi Friends,

    I was wondering is a ViewModel synonymous with a Domain Model. If not then how do they differ. I was also wanting some clarity involving what is domain driven design. 
    Thanks !

    Monday, March 18, 2019 8:40 PM

Answers

  • User1120430333 posted

    Hi Friends,

    I was wondering is a ViewModel synonymous with a Domain Model. If not then how do they differ. I was also wanting some clarity involving what is domain driven design. 
    Thanks !

    IMO, a VM can be considered a domain model, since business rules can be applied to it via data annotations, and also, a  model object in the Models folder in the MVC UI design pattern can act upon the VM with business rules. A VM can use other VM(s) to complete the view that is used in MVC.

    https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/overview/understanding-models-views-and-controllers-cs

    <copied>

    An MVC model contains all of your application logic that is not contained in a view or a controller. The model should contain all of your application business logic, validation logic, and database access logic.

    <end>

    DDD as I look at is about the complex  core business needs of the application such as business rules and how objects in the domain interact with each other based on business needs, like purchase order domain object interacting with inventory domain object that in turn interacts with the shipping domain object etc. and etc.

    In a complex application based business needs, DDD is about how domains of business the application needs to interact with other to meet the needs required  by a business requirement.  The domains are identified and placed on a chart and actions are implemented on the chart with  code programming and unit testing to achieve the business requirement or need.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 18, 2019 10:04 PM