Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Coming up with code design

by bikeNomad (Priest)
on Jun 23, 2001 at 19:55 UTC ( #90968=note: print w/replies, xml ) Need Help??

in reply to Coming up with code design

The way I (try to) work has been inspired a lot by the XP (eXtreme Programming) folks, who insist that code that doesn't directly help your program do something it has to do is code better left unwritten.

The principle is that you start with a description of what the program does for the user (well, its interaction with the outside world, anyway), as described in "stories". You then proceed to describe your system from the point of view of making only the program artifacts (objects and classes) that are needed to accomplish the tasks described in the story. You don't write any code that isn't used.

And you start by writing test cases, before you write code (so that you'll know when you get the code right). You elaborate the tests and the code until you've met the requirements in the stories.

And you continuously refactor. Don't worry about making the right architectural decisions on your first page of code. Just change the structure as you go along to meet your new discoveries.

As far as reusability, well, a great quote that I heard (sorry I can't attribute it right now) is this:

Nothing is really reusable until it's been reused three times.

Why three times? Because it usually takes at least that long to get a feel for what other users of the code might need. Don't start out by writing a framework; start out by writing an application that works. If you find that you need to reuse some pieces of it, refactor as necessary to do so. Repeat. Don't be afraid to totally change the structure of your software.

Some links to XP resources:

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://90968]
[Corion]: marto: Oh, I'm jealous. I'm going to see DM in Frankfurt, but it's a stadium full of people, so, rather a big thing where you mostly get to see the band on screens ;)
[marto]: yes, the last time I saw them was in Berlin a few years ago, at the old Olympic stadium
[marto]: After Sunday I don't think I'll go see them again :)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2017-03-24 11:34 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (301 votes). Check out past polls.