What Workplace Coding Practices Do You Use? 682
Agent_9191 asks: "Recently I've been promoted to what essentially amounts to a project lead role for every project we do, in house. Since my company has run for the past 35+ years with no form of central IT department, there has been no standards put into place for developers to abide by. One of my tasks is to set up standards in how projects will be implemented and produced. Right now I'm more concerned about trying to set up coding standards, so that any developer can jump into any part of a project and be able to figure out what's going on, without wasting a couple hours just to figure out the code. I've come across some documents in this area from a few sources (of course can't remember them off the top of my head). What practices/standards do you use in your workplace?"
My boss doesn't care (Score:4, Funny)
Standards (Score:2, Funny)
For every loop, you chug a beer.
And, of course, for every save, you do a shot of tequila.
Standardize on a good language. (Score:2, Funny)
One Solution (Score:1, Funny)
WHAT Standards? (Score:3, Funny)
Standards (Score:4, Funny)
-Chris
Re:Standards (Score:2, Funny)
while(beersOnTheWall>0) {
me.chugBeer();
beersOnTheWall--;
System.out.println(beersOnTheWall + " bottles of beer on the wall...");
}
Dilbert (Score:2, Funny)
Never comment! (Score:5, Funny)
-USe tons and tons of goto statements.
-Make sure you use particular letters capped for variables of different types to make them more confusing for the losers who can't read the code and remember what each one was.
- always make calls by reference using pointers as arguments. Don't use call by values.
- Hell user other pointers that use other pointers to make things more interesting. Reassign them all over the place
- Never use a three tier model when developing client/server apps. This only creates redundancy and gets in the way of solving the problem.
- When linking to a database always use vendor specific extensions and avoid a database layer using something like odbc. It makes use of the advanced feature set by the particular RDBMS.
- Be a man! Show how much you know perl. Alot of one linners can save tons of time with exotic line switches
Oh last... make tons of money and gain job security because no one in Earth will be able to understand or work on your projects after doing all of these things. Enjoy
Re:What a question! (Score:3, Funny)
Perhaps someone broke in and fixed the code.
Even better: CPAMAP (Score:2, Funny)
Re:Comments (Score:5, Funny)
if x==456 then
That way, there's less chance for confusion if the code gets modified in the future.
Re:Comments (Score:3, Funny)
Magic Numbers (Score:1, Funny)
Re:Comments (Score:1, Funny)
or is there some spot in the universe where x==456 will check to see if x is equal to 256?
Re:Comments (Score:4, Funny)
Re:Comments (Score:5, Funny)
That line still contains an example of one of my biggest pet peeves... the use of magic numbers. Okay, so the comment explains what 456 is, but not why and makes no provision for managing changes. What if a new design had a stepper motor whose final position was 256?
Magic numbers are a reality, of course, especially when dealing with hardware. But if there's no way for the code to dynamically determine the values, the very least you can do is to define a symbolic constant, and collect the constant definitions together in one place. For example:
See how much better that is? And if the value changed to, say 100, all you have to do is modify the constant definition in one place, like:
Really, a little extra work up front goes a long way.
Re:Comments (Score:1, Funny)
Re:Comments (Score:5, Funny)
You're right - how could it be possible not to know what that code is doing? (The rule is, the only magic numbers allowed are -1, 0, and 1. 456 is right out.)
Okay, but that's going to get really hard to debug!
if (x == (1+1)*(1+1+1+1)*((1+1+1+1)*(1+1+1+1)*(1+1+1+1)-(1
Our process (Score:2, Funny)
Repeat until app becomes unmaintainable. Repeat furthur. Repeat.
I will be giving seminars on how to implement Sisyphusian Unified Process throughout the year down at the bar. If I happen to be unconcious, please leave me be - that's my "comp time".
Coding standards (Score:5, Funny)
As someone with 20+ years of professional programming under my belt, a lot of it doing maintenance and enhancement of existing code, I'll say this: most of what's considered "coding standards" doesn't much matter. Indentation, brace positioning, type prefixes on variables, underlines vs. StudlyCaps, capitalization in general, most competent programmers can pick up on any variation quickly. The few things that count are more general:
Re:Comments (Score:4, Funny)
Documents... There is no documents. Who needs those anyways? It's much more fun to code something when you really don't have any idea what its supposed to do.
Test plans? Nah, waste of time I say!
Testing? Well, somebody runs it and if it doesn't crash, it works.
I must say I'm in the best damn work place ever! And now if you please, I'll go and find some ethernet cabel to strangle myself.
Re:#defun is sooo 70s... (Score:4, Funny)
Re:Comments lie (Score:3, Funny)
the only truely trustworthy code is code hand compiled to run on a tube CPU which you have personally blown the glass and formed every tube.
Re:Comments (Score:2, Funny)
-- FORTRAN manual for Xerox Computers
Re:Code cleanly and remove comment (Score:3, Funny)
Re:#defun is sooo 70s... (Score:3, Funny)
(Yes, that's compiler implementation specific, I know...)
Alan
Re:Comments lie (Score:3, Funny)
No sign of a variable named j anywhere...