Designing OO-systems with DDD
Digging through Domain Driven Design (Eric Evans, Addison-Wesley) I've come to think about what impact DDD (not just necessarily DDD, but that's the hype right now) has on the design and implementation of a system using object oriented languages.
One of the biggest problems I have with peoples code (including my own)is that it's almost always not as OO-ish as it could and should have been. I'm quite sure that the reason for this is that the code that I work with is written by people coming from non-OO languages/environments. Some come from PHP/ColdFusion/webish/scripting and others come from VB/ASP/VBScript/Microsoftish.
My perception is that these people mostly get the point of encapsulation quite fast, at first using classes as a construct to group related functions (not behaviour) eg; StringHelper.DoStuff, ArrayHelper.Join, etc. Sometimes only using statics or sometimes using instance methods, although the object itself has no state.
Later they find out that it's quite useful to have state although mostly their class still contains utility methods. To given an example in DotNet, the class contains a getter and setter for a DataSet and the methods in the class operates on that DataSet. Persistence is usually handled by some other class using something like:
user.SetPassword("new");
x.y.z.DataAccess.UserManager.Save(user.DataSet);
Sometimes the code is structured as:
LogicLayer.User.ChangePassword("old", "new");
DataLayer.User.Save(LogicLayer.User);
A tiny bit better than the first one, if you ask me.
And that's where it usually stops. Unless the person is constantly reading books/papers/articles about new techniques/architectures/etc and other peoples code. My impression is that most developers don't.
For a couple of years now I've gradually tried to explain to people around me (again, including myself) that they should try to model the "real world", the domain, the logical view, the clients view or watever you'd like to call it. In the beginning I really had no good way of explaining this and how it differs from the other ways (some of them mentioned above) and more importantly how it affects the result. Then I read Agile Software Development (Robert C. Martin, Prentice Hall) and started recommending that, now I'd have to say DDD instead or maybe, depending on the persons level of undestanding for/in OO, first ASD and then DDD.







