in reply to Re: Re: why is this code bad under -w option?
in thread why is this code bad under -w option?

ok two things, first are you refering to my code, or the "improved code". I did store the amount the user wants to work with and the code works just fine. It may not be the best code ever and that's why I brought it here...constructive criticism...

secondly.. no I didn't write a spec for this code, because it had to be done quick.. sue me

Some of the things you said make sense and are good practice. There are nicer ways to say some of the other things you said. If I wanted lashings about code, I would have trolled a C++ board.
  • Comment on Re: Re: Re: why is this code bad under -w option?

Replies are listed 'Best First'.
Re4: why is this code bad under -w option?
by dragonchild (Archbishop) on Jul 28, 2003 at 17:52 UTC
    There are nicer ways to say some of the other things you said.

    You're right. But, if you wanted me to say everything nicely, you need to pay me. If you want my advice for free, then take it the way I say it.

    I have no idea which code I'm working with. Both versions, however, use a flag to indicate that a valid type has been entered. Both versions don't store how many of that type the block should be. The former is a style mistake and the latter is a programming error.

    As for specs ... had you written a spec, you would have realized that you're not storing the 20 of 20KB. You would also have realized that you have no way of parsing "20 KB " or "1.3GB ". Those are serious mistakes that were commented upon by no-one else.

    This also ties back in to the tone I used - I found a serious design flaw. You can either complain that I didn't sugar-coat it or you can take it and make your program be the best it can be. I don't expect effusive thanks, but I can and do expect a little humility. You were the one who posted your code asking for constructive criticism, so expect constructive criticism. Don't expect me to hold your hand. (Again, that's what you get when you pay me, not when you get your advice for free.) I tend to follow the merlyn school of thought when it comes to this. :-)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      if($block_size =~ m{(^[0-9]+)}) { $block_quantity = $1; }

      i reposted my code with this in it and it must be below your node depth or something because its right there. My code as I posted it does accept spaces between the amount and the type. I also didn't claim this(the original) to be finished code.