Typical .NET DDD architecture vs Django/Rails practices Typical .NET DDD architecture vs Django/Rails practices ruby-on-rails ruby-on-rails

Typical .NET DDD architecture vs Django/Rails practices


Nice, a lot of discussion already. Here's my opinion on the matter:

Usually it's far easier to access the domain model straight for your forms. It's one of those things that give coding in Rails (I don't know Django, but I'm guessing it's the same) a huge productivity boost. There is hardly any coding need: have a database table, build some html and a simple controller in the middle and you're done. Because there is hardly any code involved, you can change faster, that's why it works well in Agile environments.

But, there is a time when this falls short. Sometimes, your application is too complex to make this work properly. That's when you can add ViewModels, Presenters, Facades, or whatever you want to call them. There is nothing stopping you from doing this in Rails or Django. In fact, Rails 3 introduced ActiveModel as a set of mixins to make every object work as easy with forms as when dealing with ActiveRecord.

So the question isn't why are Rails and Django not doing it, but when should I use it? Calling DDD overengineering isn't true either. It's about doing "just enough" to solve the problem that you have. Keep the amount of code and complexity as low as possible, and you will be easier to maintain.

I would agree that there are certainly lessons to be learned from Java/.NET. Usually they have gotten the design pattern thing worked out nicely. But saying that Rubyists and Pythonistas didn't do enough big projects is not true. The power comes in recognizing when you can get away with a simple solution.

I do think Java programmers (I have no experience with .NET programmers) tend to overengineer things. Maybe it's the frameworks they use. It seems to try to force the programmer to do it "The Right Way", thus making it overly complex.


Perhaps this is your opportunity to explain the advantages of a viewmodel, as I personally see it as a complete waste of time and space. While most of my MVC work has been in Rails, I'm currently working in Spring and have so far always interacted directly with the models stored in my relational database.

If you intend to make certain attributes of a model inaccessible, then don't expose them. You can give them further protection in your before_save method or elsewhere if you wish, but is that even necessary, given the likelihood that a user knows the names of the attributes that you've chosen not to expose?

If there are some other reasons why a viewmodel is beneficial, then I'm all ears (or eyes, as the case may be).