What To Do Right As a New Programmer?
globeadue writes "My company just tagged me for full time App Dev — I've essentially never coded for money, but the last 3 years of support desk gives me the business sense to know the environment I'll be coding for. Now my company will be training me, so I think the technical side of things will be covered, what I'm looking for is best practices, habits I should/shouldn't develop, etc as I take on my new craft."
Well, I think you'll probably pick up those best practices as part of your "training".
Every shop does things differently.. from simple stuff like naming conventions right up to core design methodologies and team management.
My advice would be to just spend as much time as possible listening and observing. Read through existing code.. pay close attention in meetings to how the brainstorming and final solution tends to evolve.
Some companies take a "we are paying you for your intellegence.. part of your job is to argue your design and beliefs" attitude whilst others take more of a "we are paying you.. so shut up and do it the way we want" approach.
As a side note.. check out the book "Beautiful Code"... It's good mind food. "Pragmatic Progammer" is also good.
Probably the most important thing you can keep in mind when writing new code is to think about the poor sap who has to maintain that code somewhere down the line. Especially because in a lot of cases, that poor sap will be you. Pretty much everything else follows naturally from there.
Game! - Where the stick is mightier than the sword!
Get out, now, for the love of God, while you still can.
Tab out everything in a code block. This should be obvious, but you'd be surprised how bad some stuff is out there. And try not to put in too many one-line ifs without brackets delimiting the code block... you can easily make the mistake of thinking something should be in the if's scope but isn't becuase there are no delimiters.
Comment. Comments are incredibly, incredibly important. They kinda go along with an overarching "don't be a douche" rule; while you may know what's going on in your own code, if it's at all complicated, tell the reader what it's doing. If you don't, someone is going to be very pissed at you later. If you want to go above and beyond, do Javadoc (or other style appropriate to your language) comments where appropriate; a lot of IDEs actually hook into them so you can highlight a method and see what it's doing.
And try looking at / working on some open source stuff as well. The big apps usually have a coding style they follow throughout and aren't that bad for a reference.
It's better to vote for what you want and not get it than to vote for what you don't want and get it.
- E. Debs
Hey, I like the ? : construct. You leave it alone!!!
"16MB (fuck off, MiB fascists)" - The Mighty Buzzard
Eat healthy and exercise. Pack your lunch or buy real food instead of the overpriced over-caffeinated junk in the vending machine. You'll save money and feel better.
Don't stick to just one language (the one they expect you to use). Learn how to do some basic things in several languages. This will help you understand "programming" rather than just knowing a language. Many of the same semantics apply in many languages with only the exact syntax changing. Learn the concepts not the implementations. This doesn't mean that you should try to code in many languages for your job, but as you are presented with problems do a general "how to do x" web search before you do a "how to do x using y language". The best coders I know see a particular language as a tool rather than a mandate. If you only stick to one language, you are imposing an artificial limit to your thought process and ability to problem solve.
US Democracy:The best person for the job (among These pre-selected choices...)
Comment removed based on user account deletion
I'm far from a master programmer myself, but this much I know.
http://imgs.xkcd.com/comics/goto.png
Moral of the story: Even when you think a goto is OK, you will still get eaten by a dinosaur.
"When life gives you lemons, don't make lemonade. Make life take the lemons back!" -- Cave Johnson
1. Read The Daily WTF. 2. Don't do that.
Repton.
They say that only an experienced wizard can do the tengu shuffle.
I strongly agree. Self-describing code is much better than comments. Comments are only useful, IMHO, when you need to describe a complex situation. If it can be expressed in one sentence or less, it should probably be part of the code itself. I.e., instead of:
std::string mkdec(std::string x) // Converts x, a string representing a hexidecimal number, to a decimal string.
std::string convert_hex_string_to_decimal_string(std::string hex_string)
The latter says the exact same thing, but is far likelier to be maintained properly. Also, if you get in the habit of coding like that, you never have to worry about forgetting to comment. Furthermore, the "comment" is effectively replicated every time the function is used. Hence,
instead of:
hex = "0x" + number_str;
return mkdec(hex);
you see:
hex = "0x" + number_str;
return convert_hex_string_to_decimal_string(hex);
Now, if you had a function that implements a complex algorithm that can't be summed up in short order, then sure, use a comment. But in my experience, 95% of comments in code are like the above "mkdec" comment, and would be better expressed just by using a more descriptive function or variable name. I think a lot of coders are just lazy and don't want to have to type in longer, more descriptive variable and function names.
You don't exist. Go away.
Here are a few tips off the top of my head.
* Learn how to use your company's version control system.. and *use* it
* Comment your code and be smart about it.
That is... Keep the signal/noise ratio of your commenting as high as possible.
Comment the big picture and a description of what tricky bits of code are supposed to be doing (and why). Not commenting trivial things.
* Avoid putting tricky bits in your code :-)
* Never assume that some code you write is temporary. Lots of mission-critical systems started off as a "temporary" project.
* Always try to write the best code you can, even if it's just a little one-off (see above point)
So, that means making sure your function names, variables, etc all have intelligent names. Each block of code does one thing. Each block of code is small (try to keep it on a single printed page, including all whitespace and comments)
Avoid using global variables, gotos, tightly coupled code, code that messes with the internals of objects/data-structures, etc.
* Set up a little svn server on your workstation for all those little snippets of test code you write. You never know when you're going to want to go back and look at that stuff again.
* Read other people's code. Try to figure out if it does what it's supposed to do.
* Get a good IDE and learn how to use it really well. Use the same one as the majority of your dev team (unless it really sucks).
* Make yourself as FAST as possible. If you're really fast/efficient then you have more time to think and solve problems:
- Learn how to type. seriously. get a typing tutor program and do 30 minutes a day until you can touch type as fast as you can speak.
- Learn the hot-key combos for your programming environment. You won't believe how much faster you'll be.
- Stop using your mouse for common tasks.
- Use code templates everywhere you can get away with it. Every time you start a new file, every time you write a new function
- Learn the idioms of whatever language they have you using. You should never have to stop and think about common constructs in your code
* Keep a spellbook. If you learn anything cool, interesting, or elegant. WRITE IT DOWN. By HAND I know it sounds stupid, but it really helps
* Learn how to accurately estimate your time. For everything you're asked to do. Write down how long you think it will take (in hours). At the end of the task, or the end of the workday, track how much time you've currently put in, and how much more you think you'll need. (Never modify your original estimate). Then, when people start asking you to estimate how long a project will take you'll have some historical data to help you come up with a realistic number.
Pro tip... when you're starting out. Multiply all your estimates by 3. Newbies are usually way too optimistic
* Read. lots
Read books on the language your company expects you to learn. Try to also read general books on programming, design, project management, etc. Try to understand the big picture of your project as well as the nitty-gritty of the part you're working on.
Some good books to get you started
- Code Complete
- Pragmatic Programmer: from journeyman to Master
- Programming Pearls
- Joel on Software book
- Mythical man month
- Getting Things Done
* At the end of each project, keep a log of what the project was called, what it was for, who it was for, and what you did to contribute. You can also jot down what language you used, what gotchas sprung on you, your estimate accuracy ratio, etc.
Come play free flash games on Kongregate!