in reply to Writing general code: real world example - and doubts!

my question is: do I really need all this?

That's a good question! What seems like the most natural way for the code that uses this code to work?

The best way I've found to design an interface is to use it for a while, then to think really hard about what's easy and what's difficult and what might be clearer to read and to understand and to discourage bugs.

I suspect that this code is more complicated than it needs to be, and I suspect that if you went with your first inclination and stayed open to modifying it a bit as you use it more, you'll find the right design.

  • Comment on Re: Writing general code: real world example - and doubts!

Replies are listed 'Best First'.
Re^2: Writing general code: real world example - and doubts!
by polettix (Vicar) on Apr 05, 2005 at 09:10 UTC
    Not only your suggestion seems reasonable (Keep It Simple, Stupid is illuminating on the top of my current PerlMonks page!), but it also seems a good practice given all the answers below. I would also thank you for your practical advices - I'll try to solve problems in the most straightforward way, avoiding evident and immediate in-flexibilities and trying to remain flexible myself to future changes.

    About refactoring, I maybe missed the correct word - as a matter of fact, I was trying to pre-refactor just to be sure not to have to do later. I had to wait the moment in which this would have been really necessary!

    Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")

    Don't fool yourself.
      I had to wait the moment in which this would have been really necessary!

      I think that's the key point to take away. The whole idea of refactoring is to make your code simpler. If your code is getting more complicated to understand something is probably going wrong :-)

      The time to refactor is when the code let's you know that refactoring is necessary (through duplication, hard to understand code, etc.)