A bit of both. It depends on how many times I've done the solution to the problem at hand. And how familar I am with the problem domain. The more experience/familarity I have, the more time I spend trying to improve the code. I have to admit that I don't ever remember saying 'I need to decrease coupling' though—usually it's more along the line of 'This code sucks!' or 'What the hell was I doing there?'
When I start on something new, I spend most of my time doing research. Then when I have some slight clue, I proceed to implement my newly acquired vague notion. I tend to do this in a top down fashion and I iterate the code until I've achieved some minimal goal (i.e. like 'Ok, this works, now what?) One thing I do as I move (hopefully forward) along, is review the code that I've written. This is particularly handy if I'm stuck on some feature or solution, since I can switch to improving existing code as a break from pondering problems. Often a side effect of this disjoint approach is that my subconscious mind manages to come up with the needed answer/s.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link or
or How to display code and escape characters
are good places to start.