Trainer / Instructor UNIX C++ / C Senior-Hands On Programmer-WSI
WSI Nationwide, Inc.
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

A Test To See If You Write Sloppy Software
As a freelance programmer, I have built quite a few web applications over the years, some pretty and some not-so-pretty. Before I got involved in PHP, I had worked mostly in Java, with its rigid and forced programming style. With PHP, of course, it's easy to get lazy and write sloppy code, and PHP will always perform well no matter what. Recently, however, I took over maintenance of a web application which set new lows for maintainability, quality, and structure. As I set about cleaning up this application, I took a few notes on what its most glaring problems were, and have devised a little quiz for you to take.
Most of this -- 99% of it - is old hat, or common sense, to many programmers. For others who are just starting, it may be useful. Certainly for the person who wrote the web application I took over, this would have been a valuable quiz.
The Barest Basics of Writing Decent Software:
  • Code Structure: Creating a directory structure, config file, naming standard, commenting, and formatting.
  • Error Handling: Checking every database query and properly displaying errors to the user.
  • Database Structure: Using a relational database properly.
Configuration and Directory Structure
One of the most outrageous problems I encountered in this application was the hard-coding of database username/passwords on every page throughout the site. If you ever need to change your database password, you would have to change every page. The simple solution, of course is to have a config file, which is included on every page. Give yourself 1 point if you have a proper config file.
In my applications, I create an "include" directory (it can be anywhere), and in that include directory, I place a file called "pre.php" that includes a config file, a database abstraction layer, and the template for page header/footer. It's then a simple matter to include "pre.php" on every page and inherit its functions.
Logical sub-sections of your application should be in their own directories. If you ever have more than 10-15 files in one directory, it's a sign you need to improve your directory structure. Give yourself 1 point if you have fewer than 15 files in each directory.
[ Next Page ]


Comments:
PLEASE HELP ME!!!!!Mitch0702/10/05 04:41
Ä«/µå/µ¹·Á¸·±â·Î/¸Á°¡Áö½ÅºÐ/²À º¸¼¼¿ä!ÀÌÇýÁø12/07/04 03:05
¡á¡á572¸í°ú S.E.X ½Å±â·ÏÀ» ¼¼¿î ¿©.ÀÚ °ø°³¡á¡á ½Å±â·Ï12/07/04 00:54
¡á¡á È­»ó äÆÃÁß XX¸¦ ´Ù º¸¿© Áֳ׿ä.¡á¡á ±èÀº°æ12/06/04 09:32
¹«·á¼ºÀÎ,¿µÈ­,¸¸È­,À¯¸Ó,¿î¼¼ º¸·¯¿À¼¼¿ä¹«·á¸Ç12/05/04 21:04
½Å.¿ë.ºÒ.·®.ÀÚ/´çÀÏ500/´ë.Ãâ.ºñ.¹ýÀÌÈñÁø12/05/04 06:39
¡á¡áÀý.´ë ¼º.ÀÎ.¸¸ Ŭ¸¯Çϼ¼¿ä.¡á¡á ÀÌÀºÈñ12/04/04 20:31
´ë'Ãâ'°Å'Àý'½Ã'100%µÇ'°Ô'ÇÏ'´Â'¹æ'¹ýÇѰæ¿í12/04/04 11:31
¡á¡á¡á Çö±ÝÀ» ÁÖ´Â °í½ºÅé Æ÷Ä¿ »çÀÌÆ®¡á¡á¡á °ÔÀÓ12/04/04 00:32
¡á¡á¡á¸ÅÀÏ Çö±ÝÀ» ÁÖ´Â °í½ºÅé Æ÷Ä¿ »çÀÌÆ®¡á¡á¡á ÀÓ°æÀº12/03/04 08:50
### °í½ºÅé Æ÷Ä¿ °ÔÀÓ Çϸé Çö±ÝÀ» µå·Á¿ä ### ÀÌÀº°æ12/02/04 01:16
¢Î¢Ï¢Î¾ß.µ¿.Àá.½Ã.ÈÄ.¿¡ ©.¸³.´Ï´Ù.¢Ï¢Î¢ÏÀÌÀº°æ12/01/04 20:06
¢Î¢Ï¢Î¼º.ÀÎ.¸¸ Ŭ.¸¯ ÇÏ.¼¼¿ä.¢Ï¢Î¢ÏÀÌÀº¹Ì11/30/04 15:48
½Å.¿ë.ºÒ.·®.ÀÚ/´çÀÏ500/´ë.Ãâ.ºñ.¹ýÀÌÈñÁø11/27/04 07:11
##°í½ºÅé Æ÷Ä¿ °ÔÀÓ ÇÏ½Ã¸é ¸ÅÀÏ Çö±ÝÀ» µå¸³´Ï´Ù..##À̼±Èñ11/26/04 12:56
@@¸ÅÀÏ Çö±ÝÀ» ÁÖ´Â °í½ºÅé Æ÷Ä¿ °ÔÀÓ Çϼ¼¿ä.@@¼­ºñ½º11/25/04 18:20
½Å.¿ë.ºÒ.·®.ÀÚ/´çÀÏ500/´ë.Ãâ.ºñ.¹ýÀÌÈñÁø11/24/04 07:07
½Å.¿ë.ºÒ.·®/Ä«.µå.¿¬.ü/´ë.Ãâ/È¥ÀÚ/ÇØ.°áÇÏ´Â/¹æ.¹ý±èÇö¼­11/24/04 01:24
¡Ú¡Ú´ëÇѹα¹ ¿©°í»ý 60%°¡ ÀÚÀ§¸¦ ÇѴٴٳ׿ä¡Ú¡ÚÃæ°Ý11/23/04 11:12
´ë'Ãâ'°Å'Àý'½Ã'100%µÇ'°Ô'ÇÏ'´Â'¹æ'¹ýÇѰæ¹Î11/23/04 07:02
¡Ú¡Ú¹«.·á.¾ß.µ¿¡Ú¡ÚÀÌÀº°æ11/22/04 18:32
½Å.¿ëºÒ.·®ÀÚ°¡ ¾Ë¾Æ¾ßÇÒ Á¤.º¸ ´ë.°ø.°³ ÀÌ´ÙÁø11/21/04 22:05
¡Ú¡Ú¹«.·á.¾ß.µ¿..Àá½ÃÈÄ¿¡ ©¸³´Ï´Ù..¡Ú¡Ú°øÂ¥11/21/04 20:37
¡Ú¡Ú¡ÚºÎ.ºÎ ½º.¿Í.ÇÎ µ¿.¿µ.»ó °ø.°³¡Ú¡Ú¡ÚÇöÀå°ø°³11/21/04 06:21
¡Ú¡Ú¡ÚºÎ.ºÎ ½º.¿Í.ÇÎ µ¿.¿µ.»ó °ø.°³¡Ú¡Ú¡ÚÇöÀå°ø°³11/20/04 05:57
¡Ú¡Ú¡Ú½ÇÁ¦»ðÀÔ Çѱ¹ ºüX¸® µ¿¿µ»ó!!¡Ú¡Ú¡Ú¼îÅ·11/18/04 12:54
Ä«/µå/µ¹·Á¸·±â·Î/¸Á°¡Áö½ÅºÐ/²À º¸¼¼¿ä!ÀÌÁ¤¿¬11/18/04 10:12
$$$ °í½ºÅé Æ÷Ä¿ »çÀÌÆ®¿¡¼­ ¸ÅÀÏ Çö±Ý Áö±Þ $$$À̹̰æ11/17/04 17:07
$$$ ¸ÅÀÏ Çö±ÝÀ» ÁÖ´Â °í½ºÅé Æ÷Ä¿..$$$´ë¹Ú°ÔÀÓ11/16/04 13:30
$$$ °ÔÀÓ Çϸé Çö±ÝÀ» Áֳ׿ä..$$$´ë¹Ú°ÔÀÓ11/15/04 13:22
<¼ºÀÎ ±¤°í>¹«·á Æ÷¸£³ë ½ÎÀÌÆ®±¤°í¸Ç11/15/04 03:13
Ä«.µå °ª.¿ø.±Ý.¸¸.°±.´Â.¹æ.¹ý(°­.Ãß)Áö¿µÈñ11/14/04 20:30
$$$°í½ºÅé Æ÷Ä¿ °ÔÀÓ Çϸé Çö±ÝÀ» Áֳ׿ä..$$$´ë¹Ú°ÔÀÓ11/14/04 01:44
+++++ Çѱ¹ Æ÷¸£³ë ¸ôÄ« ´Ù¿î·Îµå+++++¼­Àαâ11/13/04 02:01
RE: Using an ini-filerobert01/19/04 20:00
½Å¿ëºÒ·®/Ä«µå¿¬Ã¼/È¥ÀÚ ÇØ°áÇÏ´Â ¹æ¹ý!!(Çʵ¶)ÀÌÁö¿µ12/26/03 23:51
Directory = GoodnessMarcleo12/11/03 18:07
¢Ï ³ë·¡¹æ ¾ÆÁܸ¶~ ¢Ï»ç»çŰ11/28/03 22:56
Why create lots of dirsfinley_it11/23/03 20:42
Meaningful names of variablesfelix zaslavskiy11/18/03 14:16
No one indents?!?[N]11/03/03 00:05
RE: Formatting of braces in subsectionsHexed10/15/03 11:29
** °æ°í⠽ʸ¸¹ø ¶ç¿ì±â **¼Ò½º¸¶´ç09/24/03 13:29
½Å¿ëºÒ·®/Ä«µå¿¬Ã¼/È¥ÀÚÇØ°áÇÏ´Â ¹æ¹ý!!(Çʵ¶) µµ¿ì¹Ì09/23/03 14:12
Sloppy CodeJason Renaud09/02/03 08:01
Using an ini-fileIntel400408/25/03 14:40
RE: An even better way to write codeJeremiah07/15/03 16:09
Yes! (RE: An even better way to write code)Dinger06/18/03 12:00
RE: A handy tip (probably!)Alam Ben05/20/03 09:48
RE: Normalized codeAlam Ben05/20/03 09:45
What About Templates?John Cleary05/08/03 06:23
RE: Sloppy SoftwareMarjolein Katsma05/08/03 04:53
FormattingBrett05/07/03 13:03
Yes! (RE: An even better way to write code)Graham Bevins05/07/03 08:05
Tips for newbies6ix4our04/24/03 20:09
Cool quiz, if only ...negora04/24/03 08:24
RE: more pre.php examplesBinary Star04/21/03 22:58
Yes! (RE: An even better way to write code)Guess Who04/11/03 04:49
Yes! (RE: An even better way to write code)Michael Kristopeit04/09/03 19:51
A handy tip (probably!)dotbob04/09/03 12:37
Brace yourself for white space!Cakkafracle04/04/03 20:13
Yes! (RE: An even better way to write code)Jason04/04/03 09:40
Formatting of braces in subsectionsMichael Blankenship04/03/03 11:46
more pre.php examplesMartin Kudia04/03/03 02:48
Yes! (RE: An even better way to write code)Mike Mitterer04/01/03 02:53
Yes! (RE: An even better way to write code)Eugene Wee03/31/03 05:02
Yes! (RE: An even better way to write code)Benjamin Smith03/27/03 17:26
An even better way to write codeJosh Petrovich03/23/03 20:26
RE: Sloppy SoftwareDasher03/20/03 03:44
PHPDoc?Kris03/18/03 13:42
so cool...alman03/15/03 07:04
Normalized codeSam Barnum03/13/03 15:53
RE: Sloppy SoftwareJakL03/13/03 00:14
RE: Sloppy SoftwareBergen03/12/03 16:33
just commentsRob03/12/03 08:19
Sloppy SoftwareMikael Holmqvist03/12/03 08:10
Sloppy Softwaresrobertson03/11/03 22:55
RE: Sloppy SoftwareChristophe Banal03/11/03 19:58
RE: Sloppy SoftwareMatt03/11/03 19:47
RE: Sloppy SoftwareAnonymoose03/11/03 18:49
Use OOPCSN203/11/03 15:33
More on error handlingJeremy Lounds03/11/03 14:26
config vs. class functionRothchild03/11/03 10:09
oop vs config fileRothchild03/11/03 10:01
Good thesisSurjit03/11/03 01:29
Sloppy SoftwaretAz03/10/03 18:17
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.