How much architecture is enough?
Join the DZone community and get the full member experience.Join For Free
software architecture is hard. creating a simple, consistent, flexible environment in which we can solve the customer’s ever-changing problems is no easy task. keeping it that way is harder still. striking the right balance between all the competing demands takes real skill – so what does it take to create a good architecture? how much architecture is enough?
first, i’m drawing a distinction between software architecture and enterprise architecture . by software architecture i mean the largest patterns and structures in the code you write – the highest level of design detail. i do not mean what is often called enterprise architecture: what messaging middleware to use, how are services clustered, what database platforms to support. software architecture is the stuff we write that forms the building blocks of our solution.
the over architect
i’m sure we’ve all worked with him: the guy who could over think hello world. when faced with a customer requirement his immediate response is:
we need to build a framework
obviously the customer’s problem is too simple for this genius. instead, we can solve this whole class of problems. once we’ve built the framework, we just need to plug the right values into the simple 400 line xml configuration file and hey presto! customer problem solved.
sure, we’ve only been asked to do a one-time csv import of some customer data. but think of the long-term, what will they ask for next? what about the next customer? we should write a generic data import framework that could take data in csv, xml or json; communicating over http, ftp or email. we can build rich, configurable validation logic. we can write the data to any number of database platforms using a variety of standard orm frameworks. man, this is awesome, we could be busy for months with this!
whatever. y ou a in’t g onna n eed i t!
but sometimes, the lure of solving a problem where you’re the customer , is much more intellectually stimulating than solving the boring old customer’s problems. you know, the guy who’s paying the bills.
the over architect generalises from a sample size of one. every problem is an opportunity to build a more general solution, despite having no evidence for what other cases might need to be solved. every problem is an opportunity to bring in the latest and greatest technology – whether or not its a good fit, whether or not the company’s going to be left supporting some byzantine third party library that’s over kill for their simple use. an architect fully versed in cv++
the under architect
on the other hand, the under architect looks at every customer problem and thinks:
we could re-use what we did for feature x
where by “re-use” he means copy & paste, change as necessary. there’s no real architecture, just patterns repeated ad infinitum. every new requirement is an opportunity to write more, new code. heaven forbid we go back and change any of that crufty old shit. no, we’ll just build shiny, brand new legacy code.
we’re building a web application: so we’ll need some controllers, some views and some models. there we go, mvc – that counts as an architecture, right? oh, we need a bit more. well, we’ve got some daos here for interacting with the database. and the business logic? well, the stuff that’s not wrapped up in the controllers we can put in foo manager classes. sure, these things look like monolithic god classes – but its the best way to aggregate all the related functionality together.
lather, rinse, repeat and before you know it you have a massive application with minimal structure. the trouble is, these patterns become self-perpetuating. it’s hard to start pulling out an architecture when all you have is a naming convention .
the many architects
the challenge in many software teams is everyone thinks it’s their job to come up with new architecture or start building a new framework. the code ends up littered with half-finished, half-forgotten frameworks. changing anything becomes a nightmare: was all this functionality used ? we have three different ways of importing data, via three different hand-rolled frameworks – which ones are used? how much of each one is used? can i refactor them down into one? two? what about the incompatibilities and subtle differences?
without a clear vision changing the code becomes like archeology. as you delve down through the layers you uncover increasingly crufty old code that nobody dares touch any more. it becomes less of a software architecture and more of a taxonomy problem – like darwin trying to identify a million different species by their class structure.
what’s the answer? well i’m sorry, but i just don’t buy this agile bullshit about ”emergent architecture” . architecture doesn’t emerge, it has to be imposed, often onto unwilling code.
architecture requires a vision : somebody needs to have a clear idea about where the software is headed. architecture needs patience : as we learn more about the problem and the solution, the architecture will have to adapt. architecture needs consistency : if the guy calling the shots changes every year or two, you’ll be back to the many architects problem.
above all, i think good architecture needs a dictator . some, single person – taking responsibility for the architecture. they don’t need to be right, they just need to have a clear vision of where the architecture should head. if the team are on board with that vision then the whole team are pulling in the same direction, guided by one individual taking the long view.
central architecture group
this sounds like i’m advocating a central architecture group? hell no . the architect needs to be involved in the code, hands-on, day-to-day, so he can see the consequences of his decisions. he needs the feedback from how the product evolves and how our understanding of the problem evolves. the last thing you need is a group of ivory tower architects pontificating about whether an enterprise service bus is going to solve all our problems. hint: it won’t, but firing the central architecture group might.
getting software architecture right is a hard problem. if you keep your code dry and solid , you’re heading in the right direction. if someone has the vision for where the code should head and the team work towards that, relentlessly cleaning up old code – then maybe, just maybe you’ve got a chance.
Opinions expressed by DZone contributors are their own.