Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you plan an application's architecture before writing any code? [closed]

One thing I struggle with is planning an application's architecture before writing any code.

I don't mean gathering requirements to narrow in on what the application needs to do, but rather effectively thinking about a good way to lay out the overall class, data and flow structures, and iterating those thoughts so that I have a credible plan of action in mind before even opening the IDE. At the moment it is all to easy to just open the IDE, create a blank project, start writing bits and bobs and let the design 'grow out' from there.

I gather UML is one way to do this but I have no experience with it so it seems kind of nebulous.

How do you plan an application's architecture before writing any code? If UML is the way to go, can you recommend a concise and practical introduction for a developer of smallish applications?

I appreciate your input.

like image 938
xyz Avatar asked Nov 15 '08 12:11

xyz


People also ask

Why is it essential to design an architecture before implementing the software?

A software architecture introduces constraints on implementation and restricts design choices. This reduces the complexity of a software system and prevents developers from making incorrect decisions.


5 Answers

I consider the following:

  1. what the system is supposed to do, that is, what is the problem that the system is trying to solve
  2. who is the customer and what are their wishes
  3. what the system has to integrate with
  4. are there any legacy aspects that need to be considered
  5. what are the user interractions
  6. etc...

Then I start looking at the system as a black box and:

  1. what are the interactions that need to happen with that black box
  2. what are the behaviours that need to happen inside the black box, i.e. what needs to happen to those interactions for the black box to exhibit the desired behaviour at a higher level, e.g. receive and process incoming messages from a reservation system, update a database etc.

Then this will start to give you a view of the system that consists of various internal black boxes, each of which can be broken down further in the same manner.

UML is very good to represent such behaviour. You can describe most systems just using two of the many components of UML, namely:

  • class diagrams, and
  • sequence diagrams.

You may need activity diagrams as well if there is any parallelism in the behaviour that needs to be described.

A good resource for learning UML is Martin Fowler's excellent book "UML Distilled" (Amazon link - sanitised for the script kiddie link nazis out there (-: ). This book gives you a quick look at the essential parts of each of the components of UML.

Oh. What I've described is pretty much Ivar Jacobson's approach. Jacobson is one of the Three Amigos of OO. In fact UML was initially developed by the other two persons that form the Three Amigos, Grady Booch and Jim Rumbaugh

like image 126
Rob Wells Avatar answered Nov 10 '22 19:11

Rob Wells


I really find that a first-off of writing on paper or whiteboard is really crucial. Then move to UML if you want, but nothing beats the flexibility of just drawing it by hand at first.

like image 36
Ali Afshar Avatar answered Nov 10 '22 20:11

Ali Afshar


You should definitely take a look at Steve McConnell's Code Complete- and especially at his giveaway chapter on "Design in Construction"

You can download it from his website:

http://cc2e.com/File.ashx?cid=336

like image 29
David Pike Avatar answered Nov 10 '22 20:11

David Pike


If you're developing for .NET, Microsoft have just published (as a free e-book!) the Application Architecture Guide 2.0b1. It provides loads of really good information about planning your architecture before writing any code.

If you were desperate I expect you could use large chunks of it for non-.NET-based architectures.

like image 9
Stewart Johnson Avatar answered Nov 10 '22 19:11

Stewart Johnson


I'll preface this by saying that I do mostly web development where much of the architecture is already decided in advance (WebForms, now MVC) and most of my projects are reasonably small, one-person efforts that take less than a year. I also know going in that I'll have an ORM and DAL to handle my business object and data interaction, respectively. Recently, I've switched to using LINQ for this, so much of the "design" becomes database design and mapping via the DBML designer.

Typically, I work in a TDD (test driven development) manner. I don't spend a lot of time up front working on architectural or design details. I do gather the overall interaction of the user with the application via stories. I use the stories to work out the interaction design and discover the major components of the application. I do a lot of whiteboarding during this process with the customer -- sometimes capturing details with a digital camera if they seem important enough to keep in diagram form. Mainly my stories get captured in story form in a wiki. Eventually, the stories get organized into releases and iterations.

By this time I usually have a pretty good idea of the architecture. If it's complicated or there are unusual bits -- things that differ from my normal practices -- or I'm working with someone else (not typical), I'll diagram things (again on a whiteboard). The same is true of complicated interactions -- I may design the page layout and flow on a whiteboard, keeping it (or capturing via camera) until I'm done with that section. Once I have a general idea of where I'm going and what needs to be done first, I'll start writing tests for the first stories. Usually, this goes like: "Okay, to do that I'll need these classes. I'll start with this one and it needs to do this." Then I start merrily TDDing along and the architecture/design grows from the needs of the application.

Periodically, I'll find myself wanting to write some bits of code over again or think "this really smells" and I'll refactor my design to remove duplication or replace the smelly bits with something more elegant. Mostly, I'm concerned with getting the functionality down while following good design principles. I find that using known patterns and paying attention to good principles as you go along works out pretty well.

like image 8
tvanfosson Avatar answered Nov 10 '22 19:11

tvanfosson