Pragmatic Design
Juten Tach,
i have discussed a topic a lot lately with friends and colleagues: “Using architectural frameworks”. I know some people, who use Cairngorm, pureMVC and the like in a lot of their projects and i know people (including me), who practice a solid scepticism about those frameworks. Let me explain.
For me, the very essence of object-oriented-software-development ist the fact, that it allows me to build my application according to objects and relationships from the real world. That means, i do not build my application based on algorithms or functions, but on concepts, that i directly take from the domain of the problem i am trying to solve.
Something, that is not intended in purely functional or procedural languages. So for example, if the domain, in which i am about to build a program, deals with “shopping carts”, “customers”, “products” and so on, i can model these entities in the requirements specification, in the detailed concept, in the system design and best of all, directly in my code, using classes, interfaces, instances of classes and so on. For me, this is the true power of object-oriented-design. Objects, that have been described in some detailed concept make their way directly in my code and thus make it very readable and understandable and also provide, that the implementation is not necessarily bound to the intended functionality only, which means, it is easier to extend the software later on.
And of course, it is not only about modeling those objects, it is also about modeling the relationships between those objects. What object should have connections to what other objects and what kind of connection would that be? How should the interface of a class look like, means how do i plan to ensure encapsulation, how do i make my classes cohesive and so on. I think, designing an applications basic structure upfront – not in its entirety and into every detail of course, but the big picture – is vital and serves as a solid ground for even the most agile process. It helps developers not loosing focus on where the project should be heading to. Having the possibility to design such a solid basis gives me a good feeling for my projects. Of course, designing an appllication from scratch is a hard and time-consuming job and often goes wrong. But as allways, the more you do it, the better you get.
Now, architectural frameworks aren’t bad. In fact, if in the design process, you come to the conclusion, that you want to build up your application on the MVC pattern, then it would be rather ineffective not to use something, that works out of the box, unless you have some good arguments against it. My argument here is, for letting object-orientation have its full effect, you should not start the design of your application with a sentence like “I will build this based on frameworkX”. But instead you should model the conceptual entities of your application and their relationships and let this model be your basis upon which you build your application. And if then you find, that ‘frameworkX’ would fit into this with acceptable efforts, then everything’s fine.
But i have the feeling – and please feel free to shout, if i am totally wrong here – that a lot of developers choose frameworks like Cairngorm or pureMVC not because the patterns fit good into their design, but because it slowly becomes common sense to use those frameworks. I hear sentences like: “Using Cairngorm means, developers instantly know the common structure of the project and thus can work together more effectively”. Or: “It is so handy. I put my controllers there, my model there. It’s easy.” Or the best one: “If you want to build software in todays RIA industry, you will not get around Cairngorm.”
What can i say? It’s true, it’s easy. It is a very pragmatic approach and a lot of projects seem to proof, that it just works. But still, i think it’s not right. Of course, using Cairngorm doesn’t mean, that you can’t build a good application structure. Of course you can still build up your domain model along the real-world entities. But you allways have to play their game, if you want the concept to be effective. You have to stick to MVC, even if in some cases you might think, it doesn’t make sense. OK, you don’t have to, but i feel, not sticking to the concept of Cairngorm or pureMVC, but still using it makes things even worse, because it means breaking conventions, that other developers count on.
The biggest concern though for me is, those frameworks might give some developers a delusive feeling of comfort about their application being well structured, only because they used such a framework. So, if you design your application and you come to the conclusion, that you want to build it up using a paradigm like MVC, then cool, go ahead. But if you find yourself using an architectural framework because you did so for last 10 projects, you should at least ask yourself, if there could be an alternative.


Hi Sven,
I agree with some of your points and that’s why I like the Swiz framework (http://code.google.com/p/swizframework/) so much. Swiz is more an IoC container framework and gives you total freedom how you organize you code. You do not rely on FrontControllers, ModelLocators or ServiceLocator singleton patterns but let’s you could with the speed of light using dependency injection. There are a few DI frameworks out there and the beautiful thing about Swiz is that you do not rely on an XML configuration but let’s you define your dependencies via metadata aka annotations.
Did you give Swiz a try yet? I am happy to help
Greetings from Brazil,
Sönke
Hey Söhnke, hope you are fine at your new location. Yes, i looked into Swiz and also the Spring Actionscript extension, by the way, also a very promising project. These IoC frameworks usually have the big feature, that they do not tell you, how to structure your application, means, they are non-invasive. So that’s why we don’t call them architectural frameworks, because they do not propose an architecture, they simply help you in keeping your modules loosely coupled. Great concept.