Jump to content
xisto Community
kleinman

Do You Write Sloppy Code?

Recommended Posts

My codes sloppy but usually short, because I try to get everything as short as possible so there's less lines of code to comment to. :) ;)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 ;) ). But after a few weeks/days/certain period of time, when you look at it again, without comment it'll take a bit more time to understand it again (which isn't really a problem for me since I usually never look into written code again :P )

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. :huh: I remember I did not like using tabs, but now I can't live without them, especially when the code is 400 and more lines.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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:
/*****************************************	function  do_something()	 ***************************************Function to do something ..more details.Accepts 2 arguments to change somethingand enable something  1.)$argument1 : is some kind of flag  2.)$argument2 : displays a menu or somethingThis 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. =/
Edited by minnieadkins (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.