Hi everyone, I wanted to start this thread because I don’t know what kind of programming practices are considered good or bad(performance wise). So what kind of programming practices would you guys consider bad or good and that I should try to use or avoid?
Using neither the tab nor return key: bad.
http://forum.unity3d.com/threads/139901-Newbie-question-about-best-practice-for-C-syntax
It may help to start googling these kinds of things.
I think this looks good… http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
The absolute best coding practice is learning how to comment properly. I see lots of code on here without comments. To me this says that the person generating the code does not know what it means and it makes it hard for us to help. Effective communication is the key to success. If you can’t make comments in your code at least before posting it then you strip the community of this communication. Not only does it help us communicate with you but the script you wrote as well.
Though I agree that comments are definitely a good thing.
I don’t agree that a lack of comments says the coder doesn’t know what they’re doing. It could also mean they don’t like comments, or that they’re too lazy to write comments, or that they think their organization and method names are descriptive enough.
I comment, but I don’t comment nearly everything. I only comment those things that I don’t think can explain themselves easily to a moderately skilled programmer. (essentially anything that I know if I were reading it I’d have to re-read it a couple times to fully consume what’s going on)
wierd that you mention commenting code.
we practise this thing called “self-documenting” code. It makes you think “if i need to put a comment somewhere, does the code not explain what it’s doing?”
The easiest way to determine that is if the comment that explains what something is doing can be read based on function names, parameters, or other coding syntax, then its self-documenting and doesn’t need comments.
InstantiateShadowSprite(out shadowSprite);
Helper.DefaultSpriteSetup(out shadowSprite);
shadowSprite.gameObject.AddComponent<AccelerometerOffset>();
public static readonly int MAX_WIDTH = 8;
public static readonly int MAX_HEIGHT = 8;
It helps to know a standard as well: http://udn.epicgames.com/Three/CodingStandard.html.
One of the best libraries of code i’ve ever witnessed has almost no comments in it, but only a documentation site. Its terrible to debug into, but it has always worked for me. boost!!
If you want to code for speed and efficiently. look up Effective C# book. Although nother is better than benchmarking things yourself.