| | Interesting thought to ponder... And here is an article on it, that might get you thinking... http://www.phpbuilder.com/columns/perdue20030310.php3 --Katie |
|
|
Anyway, sloppy code is especially a problem when doing Object Oriented Programming where you have to keep things a separate as possible so you can re-use any classes you've already written. I kinda have the tendency while writing classes that I kinda weave everything together. (I just started learning OOP a very short while ago). The main problem's laziness, it's kinda boring to comment every single block of code when it's meaning is obvious (for now at least
Slopy code? Do I?
Well, that is a question that I have to answer two fold. The reason is that I code for my job and I code for my hobby. As it is my responsibility to code at my job, and as my company already has a lot of processes in place, I am driven to write clean code. Since I wirte the code with the team, I cannot afford to write sloppy code. Everything is properly designed, commented, documented and reviewed. And tested. That results in a clean code - or atleast is supposed to. Now, when it comes to my own creations, taking it as a hobby, I go wild. Because I am sure, what I write, I never will use again. I always move to greener pastures, and want to learn new things. I rarely need to revisit the same code. So, the result is, it tends to be sloppy. I just burst into it, test it, correct it and test it, and the cycle goes on until I get a satisfactory code - but the end result is a shabby code. But on the other note, the lastest project I am undertaking as I pursue this hobby of coding, I have decided that I will try to stick to the Software Development Life Cycle as far as possible. I do not have much faith in this though.
I used to code without any comments for myself, but now when my work needs to be seen by others, I try to comment and write everything clean, the variable names, and so on.. the names of the files, the mysql fields and etc. because the code which only you can understand is almost useless for others.
I see that, at school, students have to write code. And they have to comment their codes. So, I see the guys, they write down their program, they test it, and then they comment it before submitting the code to the teacher.
So, getting used with comments is very important. I see that, at school, students have to write code. And they have to comment their codes. So, I see the guys, they write down their program, they test it, and then they comment it before submitting the code to the teacher. So, getting used with comments is very important. I'm a CIS major and one of my professors emphasized this a lot. Commenting closing brackets, functions, variables, etc. I think it helped me a lot. Now he hired me as a independent contractor to help develop his software written in php. I found it very useful when dabbling in someone elses' code to have comments. As far as coding myself, I use comments, but not a lot. Tabbing is a must, especially in web development areas. I can't imagine reading a piece of "spaghetti" code now days. Example: CODE /*********************************** ****** function do_something() **** *********************************** Function to do something ..more details. Accepts 2 arguments to change something and enable something 1.)$argument1 : is some kind of flag 2.)$argument2 : displays a menu or something This function returns something as an int ***********************************/ function do_something($arg1, $arg2){/*Beginning of function do_something--i usually don't add this but helps for if statements and loops...keep it short and to 1 line though*/ here are the contents to do something.... }//!End of function do_something The closing bracket helps a lot, and the function information helps a lot if you're modifying someone elses' code. If you're coding for yourself these simple things can help if you plan on revisiting your code. If you're coding within a team you'll have to document pretty much everything. It pays to practice on your own code. I'm still learning but that's my $.02. Oops posted on old topic. Sorry, didn't read the date until after I clicked it. I saw this topic toward the top and assumed it was rather new. Sorry mod's/admin's. Won't happen again, I'll check dates from now on. =/
Recent Queries:-
Keywords : sloppy code
|
|
![]() Do You Write Sloppy Code? |
| ADD REPLY / Got an Opinion! | a humble request :-) | RAPID SEARCH! | Free Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute your information that might help someone here. Ask your Doubts & Queries to get answers.. "Together, We enlight each other!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|