I know it's one of these questions that come back endlessly, but I really need your advices :)
I'd like to hear from you about the design and programming methodology you follow...

Until recently, when I started a new application project I first drew a sketch of the application, then I started coding by the "main", adding subs as needed.
Unfortunately this tend to give spaghetti code; I had too often various unrelated code blocks stuffed into the "main" routine, and I had quite a hard time splitting the program into files/ librairies/ components.

Then I tried to start the other way around; first, I draw the general application schema, but I start first by programming the first components I need. Then I write a "main" program which actually does pretty much nothing by itself, but uses the librairies or objects already done, so I can test them.

Here I am now. The second approach seems much cleaner and better to me; but it comes at a price of longer time spent and harder work, because I have to build very clean objects from the start, instead of throwing together some dirty code that just "does the trick".

I can imagine another way, of course: I may try my first method, but keep refactoring as needed the "ugly bits" while working, instead of having the code working first...

What do you think?


In reply to How do you program (again)? by wazoox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.