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

30,927

Solution 1

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.

Solution 2

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

Solution 3

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

Solution 4

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.

Solution 5

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.

Share:
30,927

Related videos on Youtube

xyz
Author by

xyz

Updated on March 06, 2020

Comments

  • xyz
    xyz about 4 years

    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.

  • MusiGenesis
    MusiGenesis over 15 years
    Make sure you put the super-secure "DO NOT ERASE" on the whiteboard. :)
  • Booji Boy
    Booji Boy over 15 years
    You really can't beat the whiteboard and paper for the initial design. It's easy, flexable and expressive.
  • Booji Boy
    Booji Boy over 15 years
    It's very good reading - lots of good information, advise and ideas. Not too long either.
  • MarkJ
    MarkJ about 15 years
    Buy the book and read chapter 6 too which is about the design of individual classes. Then read all the other chapters too - it's pure gold.
  • MarkJ
    MarkJ about 15 years
    Oh yes, chapter 4 is about application architecture
  • MarkJ
    MarkJ about 15 years
    There's a more recent version available now. Visit the homepage to download it apparchguide.codeplex.com
  • Chepech
    Chepech over 13 years
    Everyone pretending to do something serious in this industry should definitively read that book, no matter the role they will play.
  • Patrick
    Patrick almost 10 years
    You could just laminate the whiteboard after use... :P
  • steviesama
    steviesama almost 9 years
    I probably spent a little more than 15 minutes, but your answer vibes with me. I feel like I can't afford to be wrong about design, so I design in broad strokes that over time have been proven to work. Then I can handle any inconsistencies as I go.
  • Nick H
    Nick H about 8 years
    I see what you did there