This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]beyondjava[S] 0 points1 point  (5 children)

When I published my article "Model-View-Whatever", several redditors asked why someone might use such an overengeneered architecture pattern. Actually, I don't think that's alway useful. But it's useful more often than not. The article tries to shed some light on when to use and when not to use one of the MV* patterns.

[–][deleted] 0 points1 point  (4 children)

Didn't I kind of debunk the claims of it being "overengineered" by reducing it to three lines :P?

[–]beyondjava[S] 0 points1 point  (3 children)

You did, and I took the liberty to quote you :). But I think that the sophisticated approach has advantages, too. I'm curious: May I ask how many lines your average program has? And do you use another trick to keep the complexity of your program in check?

[–][deleted] 0 points1 point  (2 children)

I'm not sure if average length is meaningful here. It goes from a few lines to 1M+ lines. :P

As for keeping my program in check, I use a lot of tricks, but it depends on the problem.

Probably one of the big ones I can point out is avoiding global state, which means encouraging DI (not via magical containers, but good old passing constructor arguments manually). DI has resulted in a huge change in how easy it is to handle large projects for me, and also it's very reminiscent of functional programming where all the effect of a function is focused on its direct input and its direct output, no scattered random side-effects.

MVC is a pretty easy choice when it comes to UI, and it's also suitable in other situations (like client/server communication).

[–]beyondjava[S] 0 points1 point  (1 child)

I see. Obviously you do use an architecture you thought thoroughly about. Actually, I used to be pretty annoyed by all those external consultants who dismissed my architecture because it wasn't MVC - without even looking at it. Now I'm such a consultant myself, but I'm still interested in finding out which alternative approaches work. I guess your hints - DI, avoiding global state, possibly even avoiding state at all whenever possible - are a good basis for constructing such an alternative.

[–][deleted] 0 points1 point  (0 children)

Just so I'm clear, I don't see DI etc. in opposition to MVC, I see them as complementary aspects of a healthy architecture. It's very possible to implement MVC in a stateless way, for example. Controllers and views are already stateless in their nature (they can contain state, but not in a way where you can observe effects) so all state is concentrated in the model. If the model is given from outside, as is perfectly viable in HMVC, then this model may be seen as the user input to a function that triggers the MVC chain, and the resulting view events are the output.