Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Do You Write Sloppy Code?
kleinman
post Nov 22 2005, 08:47 PM
Post #1


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 5
Joined: 22-November 05
Member No.: 9,767



Interesting thought to ponder... And here is an article on it, that might get you thinking... http://www.phpbuilder.com/columns/perdue20030310.php3

--Katie
Go to the top of the page
 
+Quote Post
jipman
post Nov 23 2005, 07:53 PM
Post #2


Pretty please?
Group Icon

Group: Members
Posts: 733
Joined: 28-November 04
From: Holland
Member No.: 1,552



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. tongue.gif smile.gif

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 wink.gif ). 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 tongue.gif )
Go to the top of the page
 
+Quote Post
Vyoma
post Dec 12 2005, 02:30 PM
Post #3


Cosmic Overlord
Group Icon

Group: Members
Posts: 550
Joined: 26-November 05
From: Chennai, India
Member No.: 9,811



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.
Go to the top of the page
 
+Quote Post
Quatrux
post Dec 12 2005, 03:28 PM
Post #4


the Q
Group Icon

Group: [HOSTED]
Posts: 1,022
Joined: 13-July 05
From: Lithuania, Vilnius
Member No.: 7,059



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. wink.gif 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.
Go to the top of the page
 
+Quote Post
yordan
post Dec 12 2005, 08:09 PM
Post #5


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 1,980
Joined: 16-August 05
Member No.: 7,896



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.
Go to the top of the page
 
+Quote Post
minnieadkins
post Mar 27 2006, 11:28 PM
Post #6


Premium Member
Group Icon

Group: Members
Posts: 292
Joined: 15-December 04
Member No.: 1,768



QUOTE(yordan @ Dec 12 2005, 03:09 PM) *

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. =/

This post has been edited by minnieadkins: Mar 27 2006, 11:30 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Basic css code(2)
  2. Code To Send An Email From A Form(7)
  3. Rapid HTML code generation using simple PHP(8)
  4. Do You Program/code Your Own Games(11)
  5. How Do I Create And Write To Files?(4)
  6. VB.NET: Howto Add And Delete Files(8)
  7. How To: Connect, Read, Write, Close A Database(3)
  8. VB.NET: Rotating Label & Angled Text Control(8)
  9. Does Anyone Code Using Turing(2)
  10. Myspace Code Changing(10)
  11. Free Shoutbox? HTML, Flash or PHP Code(24)
  12. How To Write A Virus ?(36)
  13. Uploading Image File Through JSP Code To Server(9)
  14. Dynamically Change The Background Image On Mouse Effects!(3)
  15. How To Add Adsense Code In SMF(4)
  1. Disable Task Manager 1 Line Code![vb6](32)
  2. Tips For Modifying Wordpress Code(1)
  3. Decompile An Exe To Source Code(10)
  4. Whats The Ascii Code Of Your Name?(4)
  5. Sandisk Memory Card Write Protection(12)
  6. Domain.com Coupon Code(1)
  7. Where Are You From ?(9)
  8. Dynamic Php Image And Better Php Code Question(10)
  9. Need Help With Code For Battle Calculator For An Mmorpg I Am Planning(0)
  10. Code To Text Ratio Tool(0)
  11. Php Random Selector(2)
  12. Activation Code(7)
  13. Instant Replay Code?(0)


 



- Lo-Fi Version Time is now: 5th September 2008 - 01:42 PM