Jump to content

  • Log In with Google      Sign In   
  • Create Account


Share your wisdom! Sage thoughts related to programming you've discovered over the years


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
43 replies to this topic

#21 phantom   Moderators   -  Reputation: 7154

Posted 22 January 2013 - 05:42 PM

That "quick temporary hack" WILL end up in the final game...



Sponsor:

#22 Stormynature   Crossbones+   -  Reputation: 3213

Posted 22 January 2013 - 05:46 PM

It will be fixed in the patch is an empty promissory note


Edited by Stormynature, 22 January 2013 - 05:48 PM.


#23 tstrimple   Prime Members   -  Reputation: 1718

Posted 22 January 2013 - 06:10 PM

"Always document your code."

 

- alnite, 2013

 

 

If you don't understand why, you will sooner or later.

 

Code documentation is overrated and violates DRY. If your code needs documentation, it's not simplified enough. ;)



#24 Oberon_Command   Crossbones+   -  Reputation: 1871

Posted 22 January 2013 - 06:20 PM



"Always document your code."


- alnite, 2013

 
 
If you don't understand why, you will sooner or later.


 
Code documentation is overrated and violates DRY. If your code needs documentation, it's not simplified enough. ;)
 



Code shouldn't need documentation in order to make what the code does understood. Code very often does need documentation of why a particular approach was taken instead of other, competing approaches.

#25 Sik_the_hedgehog   Crossbones+   -  Reputation: 1636

Posted 22 January 2013 - 06:43 PM

That "quick temporary hack" WILL end up in the final game...

 

Even better, "no hack is temporary".

 

Ironically lately I've been trumping this whenever something starts annoying me (like how I rewrote a whole object from scratch just so I could have more of them without losing framerate on older systems), but then again I can get away with it because I'm the only programmer and probably my game's code isn't anywhere as big as most projects (I had to touch only a handful of files here, for instance, and only some lines).


Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

#26 alnite   Crossbones+   -  Reputation: 2086

Posted 22 January 2013 - 08:35 PM


 

"Always document your code."

 

- alnite, 2013

 
 
If you don't understand why, you will sooner or later.

 

 
Code documentation is overrated and violates DRY. If your code needs documentation, it's not simplified enough. ;)
 

 


Code shouldn't need documentation in order to make what the code does understood. Code very often does need documentation of why a particular approach was taken instead of other, competing approaches.

 

Keep in mind, I'm not talking about commenting code, which is a whole different thing.

 

If I have to read code line by line to know what it does, then I know I have failed in writing a reusable code.



#27 HostileExpanse   Members   -  Reputation: 112

Posted 23 January 2013 - 05:19 AM


"If you're going to be writing cryptographic code, and you're not sure what you're doing,

just put the keyboard away and ask someone qualified to write it for you. For all our sakes."

 

                                                                                                 - Bacterius, 2013

 

Or, really, the more general statement - if your code is going to be used in situations where it failing could have very real consequences, don't write the code if you cannot assume said consequences. Seriously, the Dunning-Kruger effect is omnipresent in the field of programming, and not taking it into account is a recipe for disaster. See the recent utter failure of the Mega file sharing website's launch - the developer had no clue what he was doing, and the result is painfully obvious and predictable.

I'm writing cryptographic code and I'm not 100% sure what I'm doing. Should be interesting LOL

#28 Net Gnome   Members   -  Reputation: 769

Posted 23 January 2013 - 05:21 AM

If I have to read code line by line to know what it does, then I know I have failed in writing a reusable code.

 

Agreed. What code does is different than how code does it smile.png



#29 way2lazy2care   Members   -  Reputation: 782

Posted 24 January 2013 - 10:27 AM

Use descriptive variable names. Seriously, this is one thing I don't understand. Probably 3/4s of my job is reading code and 1/4 writing; prioritize making code easy to read.



#30 ChaosEngine   Crossbones+   -  Reputation: 2297

Posted 24 January 2013 - 02:47 PM

Use descriptive variable names. Seriously, this is one thing I don't understand. Probably 3/4s of my job is reading code and 1/4 writing; prioritize making code easy to read.

QFT.

 

Have previously worked on a code base where the original programmer didn't like typing so everything is named using 3 letter abbreviations strung together.

Want to calculate the distance between two points? Call the ClcDstBtw2Pts method! Need to know the value of the taxable amount on account balance? It's in the txAmtAccBal variable. And that's not a typo, the 'a' in tax was felt to be superfluous. sad.png


if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

#31 BCullis   Crossbones+   -  Reputation: 1813

Posted 24 January 2013 - 04:24 PM

Use descriptive variable names. Seriously, this is one thing I don't understand. Probably 3/4s of my job is reading code and 1/4 writing; prioritize making code easy to read.

GODS YES.  QFT again!

 

The codebase I work on currently (dayjob-wise) is so utterly illegible thanks to shortened function names and variables that I spend 5x longer than I should have to referring back to headers for commented struct fields.  It's a joy afterwards to dive back into my own project and actually read my code instead of translate it.

 

I can't add anything new, all my favorites and "amen" moments are already in the list.


Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#32 TheChubu   Crossbones+   -  Reputation: 4186

Posted 24 January 2013 - 09:40 PM

Use descriptive variable names. Seriously, this is one thing I don't understand. Probably 3/4s of my job is reading code and 1/4 writing; prioritize making code easy to read.

QFT.

 

Have previously worked on a code base where the original programmer didn't like typing so everything is named using 3 letter abbreviations strung together.

Want to calculate the distance between two points? Call the ClcDstBtw2Pts method! Need to know the value of the taxable amount on account balance? It's in the txAmtAccBal variable. And that's not a typo, the 'a' in tax was felt to be superfluous. sad.png

 

Looks like he was texting the compiler...

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

 

My journals: dustArtemis ECS framework and Making a Terrain Generator


#33 Sik_the_hedgehog   Crossbones+   -  Reputation: 1636

Posted 24 January 2013 - 11:00 PM

Have previously worked on a code base where the original programmer didn't like typing so everything is named using 3 letter abbreviations strung together.
Want to calculate the distance between two points? Call the ClcDstBtw2Pts method! Need to know the value of the taxable amount on account balance? It's in the txAmtAccBal variable. And that's not a typo, the 'a' in tax was felt to be superfluous. 

What the—

 

I do sometimes use abbreviations, but only those that are pretty much well-known in programming anyway (like ptr for pointer or len for length). Otherwise I don't use abbreviations. I still aim for short names, though (just because you have a huge monitor doesn't mean you have to make function names longer, it eventually becomes too hard to read just because it's too long). I noticed that a lot of long function names involve either them being too overly descriptive (whatever happened to context?) or are functions that are doing multiple tasks at the same time (which usually means there's a problem in the design).

 

If your "long" function name is something like draw_level_background, that's probably OK - concise but makes very clear what it does. If your function name is something along the lines of this (and I've seen some APIs do that) then we have problems =P


Edited by Sik_the_hedgehog, 24 January 2013 - 11:00 PM.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

#34 szecs   Members   -  Reputation: 2119

Posted 24 January 2013 - 11:20 PM

Have previously worked on a code base where the original programmer didn't like typing so everything is named using 3 letter abbreviations strung together.
Want to calculate the distance between two points? Call the ClcDstBtw2Pts method! Need to know the value of the taxable amount on account balance? It's in the txAmtAccBal variable. And that's not a typo, the 'a' in tax was felt to be superfluous. 


 

If your "long" function name is something like draw_level_background, that's probably OK - concise but makes very clear what it does. If your function name is something along the lines of this (and I've seen some APIs do that) then we have problems =P

 

I'm beginning to think that I'm actually not a bad code writer.



#35 irreversible   Crossbones+   -  Reputation: 1315

Posted 25 January 2013 - 04:20 AM

Have previously worked on a code base where the original programmer didn't like typing so everything is named using 3 letter abbreviations strung together.
Want to calculate the distance between two points? Call the ClcDstBtw2Pts method! Need to know the value of the taxable amount on account balance? It's in the txAmtAccBal variable. And that's not a typo, the 'a' in tax was felt to be superfluous. 

 

This. Never looked back.



#36 SeraphLance   Members   -  Reputation: 1323

Posted 25 January 2013 - 07:52 AM

This has come up a couple times very recently when helping others fix their code, so I'm going to say it here.

 

If your API functions return error codes, check them.

 

and for the exception-related corollary:

 

putting "throws exception" everywhere in your code is like throwing a psychotic mass murderer in jail and forgetting to lock the cell.



#37 way2lazy2care   Members   -  Reputation: 782

Posted 25 January 2013 - 10:37 AM

Have previously worked on a code base where the original programmer didn't like typing so everything is named using 3 letter abbreviations strung together.
Want to calculate the distance between two points? Call the ClcDstBtw2Pts method! Need to know the value of the taxable amount on account balance? It's in the txAmtAccBal variable. And that's not a typo, the 'a' in tax was felt to be superfluous. 

 

This. Never looked back.

That only solves the writing code problem, not the reading code problem.



#38 irreversible   Crossbones+   -  Reputation: 1315

Posted 26 January 2013 - 11:25 AM

 

Have previously worked on a code base where the original programmer didn't like typing so everything is named using 3 letter abbreviations strung together.
Want to calculate the distance between two points? Call the ClcDstBtw2Pts method! Need to know the value of the taxable amount on account balance? It's in the txAmtAccBal variable. And that's not a typo, the 'a' in tax was felt to be superfluous. 

 

This. Never looked back.

That only solves the writing code problem, not the reading code problem.

By that description it solves the problem, doesn't it?



#39 ChaosEngine   Crossbones+   -  Reputation: 2297

Posted 27 January 2013 - 03:15 AM


This. Never looked back.


Believe me, the hideous naming scheme was the least of the problems...
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight

#40 Sik_the_hedgehog   Crossbones+   -  Reputation: 1636

Posted 27 January 2013 - 03:56 AM

 

 

Have previously worked on a code base where the original programmer didn't like typing so everything is named using 3 letter abbreviations strung together.
Want to calculate the distance between two points? Call the ClcDstBtw2Pts method! Need to know the value of the taxable amount on account balance? It's in the txAmtAccBal variable. And that's not a typo, the 'a' in tax was felt to be superfluous. 

 

This. Never looked back.

That only solves the writing code problem, not the reading code problem.

By that description it solves the problem, doesn't it?

 

It requires rewriting the code to achieve that. Good luck doing that in a huge project... You're guaranteed you will break something, and you're guaranteed you will upset everybody else working with you (and especially your boss).


Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS