0

I have just stepped into the Domain Driven Design paradigm but I have one question:

How is an MVVM Model different from a DDD Entity? What are the differences between these two?

  • @RobertHarvey, do you mean both Model and Entity should be handled separately? The reason why i put up this question, I am using my entities as Model currently. Both are same. – Furqan Safdar Aug 16 '16 at 21:07
  • See my answer below. – Robert Harvey Aug 16 '16 at 21:08
4

Model–view–viewmodel (MVVM) is a software architectural pattern that separates the development of the graphical user interface from the development of the business logic or back-end logic.

A DDD Entity is something that has identity and type in a business context. For example, airline seats are entities; the airline treats them all the same way (subject to first-class, etc.) However, each seat is an instance with its own identity.

If you were to combine MVVM with Domain-Driven Design, the DDD Entities would become part of the MVVM's Model (but not the ViewModel). For example:

namespace Model
{
    public class AirlineSeat
    {
        // implementation of DDD Entity
    }

    public class FrequentFlyer: Flyer, Person
    {
        // Another DDD Entity
    }
}

Further Reading
Model–view–viewmodel
Domain-Driven Design: Building Blocks

  • "If you were to combine MVVM with Domain-Driven Design, the DDD Entities would become part of the MVVM's Model." Can you please explain it further with example. – Furqan Safdar Aug 16 '16 at 21:11
  • Added an example. – Robert Harvey Aug 16 '16 at 21:13
  • Is AirlineSeat is acting as an Entity and Model at the same time? My confusion is whether they are two different things or one thing with two different names? – Furqan Safdar Aug 16 '16 at 21:14
  • AirlineSeat is part of the model. Think of it this way: none of your DDD stuff is going to go into the View or Controller of MVVM, unless you're referring to it from the model, where it originates. – Robert Harvey Aug 16 '16 at 21:14
  • So you mean Model is the place where you can expose your DDD Entity? However both are two separate things, correct? – Furqan Safdar Aug 16 '16 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.