Page 2 of 3
Posted: Fri Jul 27, 2007 3:49 pm
by Benjamin
This is generally what I do..
1. Create skeleton code to nail down the logic.
2. Add meat for validation, security and error handling.
3. Refactor
4. Optimize
Posted: Fri Jul 27, 2007 3:57 pm
by Chris Corbyn
I write a test case, write an empty skeleton of the class/method, then make the test pass by writing code. Now where have I seen people do that before?
Seriously though, test driven development just results in the cleanest and most flexible interfaces you can imagine.
I'd really like to give pair programming a chance too but the team at my workplace is too small to convince my boss it's a good idea. Maybe when I get to SitePoint... they're an agile bunch

Posted: Fri Jul 27, 2007 5:10 pm
by s.dot
I bought an arcade game script, *wont say from where*, and the php/html pages it came with were horrendous. I ended up just coding my own pages.
Posted: Fri Jul 27, 2007 7:46 pm
by Benjamin
Well I learned that this works today..
Code: Select all
if (false)
{
echo 'yo what\'s up';
}{
echo 'this actually works?';
}
Posted: Fri Jul 27, 2007 9:12 pm
by superdezign
Is that like... An invisible else??
Posted: Fri Jul 27, 2007 10:08 pm
by Chalks
superdezign wrote:
Is that like... An invisible else??
IT'S MAGIC!
Posted: Fri Jul 27, 2007 10:18 pm
by superdezign
I say we use the influence of DevNet to deprecate the word else!

Posted: Fri Jul 27, 2007 10:22 pm
by superdezign
Oh astions, you are such a liar!!
I looked at that code
just now and realized what's happening. This is perfectly valid code:
See what's happening?
Just like in C++, you can create blocks of code with no meaning simply for organizational purposes. That doesn't create an else, it just doesn't meet the if-statement condition. It'd print the second part regardless of the condition being true or false.
Posted: Fri Jul 27, 2007 10:31 pm
by Benjamin
Well there was supposed to be an else there..
See, this is the kind of stuff I am talking about.
Posted: Fri Jul 27, 2007 11:01 pm
by superdezign
astions wrote:Well there was supposed to be an else there..
See, this is the kind of stuff I am talking about.
Yes, I certainly see the nightmare of code you are dealing with. Ewww.
Posted: Fri Jul 27, 2007 11:16 pm
by Charles256
If you see if{ statement }{} in your code immediately kill the previous coder..or do something more politically correct to him

Posted: Fri Jul 27, 2007 11:41 pm
by Benjamin
It was something like..
Code: Select all
if ($thisvariable > $thatvariable && $somethingelse < $anothersomethingelse) { $ErrAry[$i]['index'] = "Really long error message"; $Errcnt++;}
{
// tons of code here..
}
Posted: Fri Jul 27, 2007 11:54 pm
by superdezign
Freaky. You'll need to find the coder and give him a dirty look. He'll know what he did.
If he doesn't, then he genuinely does suck and tried his best.
Posted: Sun Jul 29, 2007 9:37 am
by RobertGonzalez
That sucks.
Posted: Sun Jul 29, 2007 2:52 pm
by alex.barylski
I hate:
1) Functions longer than 80-100 lines
2) Classes with more than half a dozen (or dozen at most) functions
3) Stupid comments like (Initialize variable)
4) Non-existant conventions (MyClass mized with My_Class)
5) Complicated code
6) Inconsistent file naming conventions (Smarty.php, mysmarty.class.php, etc)
7) HTML mixed with PHP - excluding template specific logic

JavaScript mashed with PHP or AJAX hell
9) Cross frame scripting
10) Monolithic applications, poor separation of concerns, etc
11) Poor file structures
Although I usually get at least one thing (an 'oh good idea' moment) on every peice of code I work on, so I guess it's not a total loss.