Sympathisant: 100 Signs that I May Be Writing Spaghetti Code - PART I

Beitrag lesen

Hai,

found on webmasterworld.com

100 Signs that I May Be Writing Spaghetti Code

100. I have no idea where this constant is defined.

99. I have echo stmts littered throughout my code.

98. There is an error but it isn't handled, and I can't find it to figure out what's wrong.

97. Spelling 'referer' wrong everywhere so it matches the PHP $HTTP_REFERER syntax and then adding a comment everywhere it's used so everyone knows you did it on purpose.

96. Passing variables directly to 635 functions and using 'global' on 453 functions.

95. I have to modify the same function 10 times because I have not moved it into an include script...yet.

94. Finding out that the 2 libraries you need to include also happen to include each other

93. trying to edit html content on the index page and not being able to find the template until you go through 10 scripts (gotta love horde).

92. No comments.

91. You lose track of what include to use for what functions.

90. You edit an include and realize you've already written that function or something very similar...somewhere.

89. Opening and closing tags for an element like <p>, <table>, etc are in different files.

88. Can't find the include file anywhere in the folder I am examining.

87. Includes? What are includes? (This is a corollary to 91).

86. Everything looks the same, as in:
Top of page:

include "include.php";  
include "include1.php":  
include "include2.php":

85. I find that rewriting is quicker and easier than modifying the original design.

84. You have a library of small functions that you wrote yourself, and will cut'n'paste them into almost every project you work on... Whether they're needed or not...

82. I'm at that precipice where I suddenly realize that the whole application would be a lot better if I made a certain change - a fundamental change - one that would allow me to streamline my code, perhaps combine functions, and save me time and hassle later on. But it requires me to dump a day's (or more) work and because of a lack of time - I press on and ignore it.

81. Every time you want to change a variable you have to use grep to find it ;)

80. you have so many "for" loops you've declared a variable for each letter in the alphabet.

79. Dreamweaver starts to lag when you open the file.

78. You realize there is no possible way to unwind your cross included files and in your great wisdom you used include and require. You now have to replace all of them with include_once and require_once just to stop the contamination.

77. there are enough "if" statements to make you scroll to the right.

76. Your GET query string is so long it can crash a browser.

75. Your class object includes are stored on a single server and aliased on all your webservers...but you don't know which server those files are REALLY on anymore.

74. You curse at your co-worker's terrible logic just before you realise you wrote that code last week.

73. You see comments in the code that read something like:
Your Name: Don't ask me how or why this works, I know it looks overly complex and it appears there IS a simpler solution, but this works, it fixed a bug from the 'simpler code'...just leave it be...don't touch it, I've hired a voodoo witch doctor to place a curse on anybody who alters this code...trust me, just leave it alone!

72. Following on from 81 - you know you're digging through a bowl of the stuff when, as a regular tool, you're using the windoz's search feature to find functions, variables and other bits of code.

71. Following of from 80 and 77 - having to "peel" your way through while/for loops and a chunks of IF and ELSE statements because the original author (probably in all his haste) couldn't be bothered to use brackets. The code works but not always for the right reasons.

70. out of the 50 arrays used 49 are 3 dimensional.

69. You crash your SQL server more then 5 times while testing your queries

68. After uploading your scripts to the server you find that you've exceded your allotted bandwidth for the month

67. I use every imaginable variation of the word "foobar" in variable names

66. My enter key doesn't work, so I just put everything on one line, it works anyways.

65. [editor note: This one is not so much a sign, as an example. See Message #35].

64. You're not using Python instead. ;)

63. Some functions work even though you know they shouldn't as you haven't finished them yet. Being unable to make them fail as expected, you are left with only one conclusion: your code has spontaneously become self-aware - and worse, it *knows* you want to shut it down...

62. You sit down, open your PHP script, and wonder where to begin with debugging... (ooh boy, I know the feeling of that!)

61. Your final page doesn't validate. You look at the HTML source and see the problem clearly, but you decide not to fix it because you have no idea where this output comes from.

60. When you have to grep for a var from / because you have no idea where in your directory structure the file is, all you know is it is above the root of the site. (I've had to do this a few times)

59 - When a simple HELLO WORLD takes up 40 lines of code...

58. Nothing like throwing in a hierarchy of javascripts that are all dependent on each other. Something along the lines of "this script must be defined after variables hd,hm and hy are defined".

57. You find comments like this in your code:
This code, while convoluted and apparantly redundant fixes a bug in a M$ dll/function/object/etc.

56. When every time the boss and artist come walking through the door, you know you are going to have to change 50 lines of code.

55. You wrap it up and realize that there are 20 funtions in the include files which are never called, although at some point, they were all required.

54. The project scope continues to creep, but the timeline scope continues to deminish (don't care who you are, if you are keeping up with that, you are hacking dough)

53. You are using database structure changes in the middle of the project

52. In an attempt to same time, you are making system calls for OS functions.

51. Changing database is (e.g MS SQL to MySQL) requires the rewrite of SQL statments.

50. There is HTML in your functions. (this is a little debatable, but it is a watch sign for me). [editor wants to change this to: 50. Your functions output HTML directly (either through switching out of PHP or via echo)].