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.
Along with the ? : ternary opp.
Code that is hard to read means job security.
The IOCCC is a good place to learn style.
Sql Injection is a good thing. You don't need to escape user data before send it to the DB, users never do anything bad.
(Go ahead and mod me troll, I can take the hit. Note that this is actually a list of things NOT to do. Except goto is sometimes useful, for breaking out of a few layers of loops/blocks.)
If I have nothing to hide, don't search me
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
... http://stackoverflow.com/
Sometimes I wonder if the editors eyer bother checking the firehose tags for "tvpo" or "tvpoinsummarv".
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...)
- Listen to your end users. They're the reason you're writing the software. Even when they ask for something stupid, be sure to listen to their needs.
- Listen to other smart developers. Find the smartest experienced guy in your new team, or other similar teams, and pick up tips and feedback. There is a LOT that can easily be learned from other smart people's experiences. Ask questions, but don't be annoying. Following a few bloggers in your field can be helpful if you find the right ones, but an experienced person on your own team would be best.
- Read up on general best practices. Indent your code consistently, write comments, name variables and functions well, etc.
- Think about your code long term. Code is rarely used just once and never looked at again. Write it so it should last and be relatively easy for you to pick up a year later or for someone else to take over.
- Don't box yourself into one line of thinking. If you become religiously attached to one particular language, for example, you'll eventually stagnate. Learn the best traits of a variety of languages and systems. It'll make you a better all-around programmer.
Developers: We can use your help.
Don't read Slashdot at work. :)
Comment removed based on user account deletion
yeah, wheels suck. Instead create a circle that can be attached to a vehicle in such a manner that it allows the circle to roll while the vehicle moves in a straight line. And don't forget to give it descriptive name like
circleForVehicleToMoveBetterThanDraggingWouldNormallyAllow
Well.. maybe. Or Maybe not. But Definitely not sort of.
Read The Risks Digest -- it ought to be required reading for all software developers because it is fundamentally about how systems fail and if you don't have a good grasp of how the system you are building might fail, then you will probably build it in such a way that it will fail like a house of cards the first time a stiff breeze blows.
It is low volume with pretty high signal-to-noise ratio so it is not a burden to stay current, and when you have some dead time the back issues - going back for more than two decades now - make for great reading too.
When information is power, privacy is freedom.
1) Your employer will never give you sufficient time to finish what you need to do. Bend over and take it. It comes with the job
2) Never blame someone else directly, even if it is obviously someone else's fault
3) Don't expect overtime pay. You'll never get it. If you ask for it, things will conveniently become a "this isn't working out" situation 4) The salesmen will sell things that you probably can't provide without working 24/7 for the next 6 months. They will also likely make 4x what you make, plus commission. Bend over and take it. 5) Do NOT EVER NEVER EVER bring in personal code to work... even if it suits the situation/project. Not only will you be expected to then provide some more goodies in your off-time, you pretty much lose the right to it of any legal ambiguity occurs. 6) Get every promise in writing. Whether it a bonus, "comp time" for late/extra hours worked, whatever.
"When life gives you lemons, don't make lemonade. Make life take the lemons back!" -- Cave Johnson
I'm far from a master programmer myself, but this much I know.
Find and watch episodes of and old cop show called "Columbo".
Whenever you are unsure of anything, act like Peter Falk's character (Columbo). Whenever you are very sure of something, try even harder to act like that. If things don't make sense to you, ask questions, do experiments, use google, use your brain until they do make sense. And if you have a theory (or a plan, or a piece of code) that you are sure is right, put it to the test.
Don't be a know-it-all, don't blindly assume that you know anything. People sometimes get annoyed at developers who take nothing for granted, but that sort of attitude gets results, so they put up with it a lot longer than they put up with developers that assume they already know everything and project that assurance right up to the point where the project goes down in smoldering ruin.
--MarkusQ
There are a few advantages to starting with maintenance work:
1) The majority of the work is probably done for you.
2) You'll have a chance to force yourself to get used to working with someone else's code.
3) If you have good senior software engineers working with you, you'll have people who can show you how things ought to be done/have to be done.
I've been out of college for nearly three years, and most of my experience has been cleaning up the mess that others have made. Usually the projects have been ones written by cheap consultants who got the contract by bleeding themselves dry on their bidding. You'd be amazed at how obviously bad a lot of the work that these do, even though you're just getting out of college.
Try to right program code comments as much as possible as long as memory permits it (if you do have a memory cap).
It makes your job down the road a lot easier, as well as other people's job easier, too.
Try to have it make sense, too. Overall, doing this helps you in retaining how the code works step by step so that you will almost know it like the back of your hand.
Previewing comments are for sissies!
So far I like mr_mischief's reply best. Aside from that, here's what keeps me on track:
But much more importantly, get enough sleep. I'm at least x2 more productive when I have 8.5 hours of sleep than when I have <7 hours of sleep. That's 1.5 hours that makes the difference of +4 hours of useful work. It's worth it, if you care about your work at all.
- shazow
1. Read The Daily WTF. 2. Don't do that.
Repton.
They say that only an experienced wizard can do the tengu shuffle.
Lies. Exceptions are not meant for intentional flow control, they are for exceptions. Exceptions are (in almost all implementations) much slower and you would never want to use them in place of a goto in, say, a core loop where the goto case happens a significant portion of the time.
Same could go for software development.
Couldn't stand the weather
1) go buy code complete. read it a chapter a week. when you are done, reread it. if your understanding of the book has not changed completely, you need to go find a new career.
2) learn discipline now. code complete has some excellent examples (e.g. declaring variables only as you need them and initialize them immediately, put constants on the left hand sides of logical tests, etc.) and your coding standards should provide other guidance.
3) take dijkstra's words to heart: "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." corollary: "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." (kernigan)
4) get in the habit of maintaining engineering notebooks. over time you'll figure out how to keep useful notes and those notebooks will be worth their weight (or more!) in gold.
5) go find a senior dev that you have a solid personal relationship with and see if you can establish an informal mentor/mentee relationship.
6) ask questions. lots of them. keep on asking until you're satisfied with the answer.
7) understand that any task that requires more than 2 minutes worth of programming merits at least 10 minutes worth of putting a plan together / drawing pictures / planning and at least 30 minutes worth of testing (ideally by adding to an existing automated test suite, hint hint...)
When coding, look for patterns in the code - at the smallest level, anytime you find yourself copying and pasting code without modification, you've identified a pattern and will be better served by extracting that out into a reusable function/method.
You'll find that there are identifiable patterns in all aspects of programming. In the broadest sense, learning how to first identify them, then use them, then predict them is what differentiates a code monkey from a great programmer.
Finally: listen to what your users "mean" and not just what they say. When they try to explain a problem to you, avoid the "works fine for me" syndrome -- remember that they wouldn't be talking to you if /something/ wasn't broken. (Even if 'broken' only means they don't understand how it should work: that could be a sign that how it works is flawed...)
like ? leave_alone : ;
There, fixed it for you.
HA! I just wasted some of your bandwidth with a frivolous sig!
Actually, I've been told that assembler code ought to be commented in just that way. In well written high-level code, individual lines should have a self-evident purpose, but often this is just not possible in very low-level code. Can you really tell at a glance what "djnz" means? And even if the answer is "yes", can you reasonably expect everyone else to have it memorized?
I don't have enough experience with assembly language to render an opinion myself on whether this is really necessary in a development context, but in school I spent a semester programming ASM and the line-by-line commenting seemed indispensable.
(Or did you mean that the comment was somehow inaccurate? Like I said, who can look at "djnz" and remember what it means? I can't.)
Use a slow machine with little free memory to test your code. It teaches you to be efficient. That is why 1GB of ram is not enough for an office anymore.
Fight Spammers!
No matter what more politically-correct people like to think, all people are not born equal. The best software developers are born with a certain affinity for the mindset required. Education can build on it, but if you don't have it to start with you won't ever be good or as happy working as a software developer as whatever you're really cut out to be.
You need to make an analytical and honest decision with yourself as to whether this is a direction you want to be going in with your life and career. Unless you're absolutely sure you're the right person to be a software developer, then don't do it. The fact that you've apparently already been happy to do tech support rather than write software might itself be an indicator that this is not a good move for you.
OK now you've decided to go ahead anyway, the next stage is that you need to know what you are doing.
Contrary what most other posters here are suggesting, you're jnever going to be fully effective if you just try and learn on the job or learn from other software developers around you. There is a lot more to being a good software developer than being able to write a program that runs OK.
By limiting yourself to learmning on the job, at best you will only develop a tiny subset of very specific skills you need for your particular company/product/langauge/toolchain, and will not get a deeper understanding of some very important concepts. Also that approach will almost certainly start you off with some very bad programming habits (i.e. your colleagues).
Ask your company to allow you as much time as you can get to attend some Cumputer Science and Software Engineering courses at your local college or university.
If you need justification, tell them that your company will save way more than the time/money it costs them in terms of your increased knowledge, usefullness and code quality meaning much less rework required.
If they still say no, then make every effort yourself to at least do some evening courses and build points towards a Computer Science or other similar software related degree.
Assuming you don't want to work for the same company for ever, you need to understand that no matter how good you think you are, these days a Computer Science or other relevant degree is a basic requirement for many if not most software developer positions. You learn a lot of really useful fundamental concepts on a CS degree course that will be highly relevant, used and needed throughout your whole career. Ususally the only people who dont agree with the value of a CS degree for software engineers are those who don't have one, so don't know what they don't know.
If you want to grow up to be a great prolific coder, follow these two rules --
1) do anything that makes you want to write code
2) don't do anything that discourages you from writing code
Coders cease to be coders because they fail to follow these two rules, and many find themselves in marketing or customer support. Some even wind up in sales.
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!
No.. you are a fucking idiot. Please never write software again.
Exceptions are designed for HANDLING EXCEPTIONS. Hence why in all modern languages like C#/VB.NET other .NET languages, Java etc do a complete stack walk every time you throw an exception (extremely expensive).
I'm all for avoiding premature optimization, but you don't have to be a fucking idiot. If your code "needs" exceptions to break out of deeply nested logic it's because your code is shit.
Learn to code.
Always keep in mind that your job is to reduce and manage complexity - not to increase complexity or let it run wild.
Seek out ways to make your code simple and elegant.
A large part of complexity management is making sure that your code can be read easily, and that it's function is obvious from a quick scan.
Find good code (this may be difficult), and read it. You'll notice things including:
- short functions / methods
- each function / method does one thing, and it's name clearly tells you what it does.
- simplicity and understandibility is favored of 'trickiness'.
- in the words of the "Pragmatic Programmer" folks, the "Don't Repeat Yourself" (DRY) rule is followed.
One more thing - don't fall into the bad habit of "I'll do it this crappy / complex way now, and refactor it / comment it later". In practice, "later" rarely happens.
Your advice equates to "Broaden your background", so I support that thoroughly.
The most depressing thing about this whole thread for me is that nobody else (yet) has brought up computer science or software engineering. By implication, they're not relevant to a career in programming, and that's a disastrous indictment of the nature of this occupation currently.
The person in TFA will be getting some training in programming, probably focussed on gaining proficiency in one specific language, but will have no theoretical background whatsoever. And this is supposed to yield a good developer?
Computer programming is an engineering discipline, with a very extensive background and a deep theoretical foundation in CompSci. What that person will become, at best, is a hack mechanic, since he will have none of the foundation to become an engineer.
This is precisely why "bridges are falling down" all around us in software, daily.
Programming is currently in its deepest Dark Ages, and most practitioners don't even realize it. That person should at least read some simple background on algorithms.
"The question of whether machines can think is no more interesting than [] whether submarines can swim" - Dijkstra
No, hell no! I program in assembler (on zSeries). DJNZ and such are easy to find in the manual. Whoever reads the code is expected to know the instruction set.
I would recommend to comment on (almost) every line, but the comments have to be meaningful. For example, instead of saying "increment register AX" say "increment file array counter" or "point to next character", depending on what you are working with. It's extremely important for readability to constantly repeat what kind of data you have in registers. Or if you are testing a condition, write what condition means - is it error processing or normal program? Where do you jump? And so on.
Of course, you should also use comment blocks for larger algorithmic structure of the assembler program.
25 years ago I read a book called Software Tools in Pascal. This had a huge, beneficial impact on me.
The most important single thing I learned from that book is something they called "left-corner design". It goes like this:
Find some small part of your project, preferably something at the lowest design layer. Then code it up and implement it. Make it so brain-dead simple that you can spot all the bugs, and fix them. Now, consider some simple way to make it do something more, something else needed for the final product. Then make it do that, and fix it until the new feature is also working perfectly. Iterate.
As a real-life example, I once made an advanced audio DSP (digital signal processing) engine. It started out as a program that could open a wave audio file, read all the samples, and write them to another file. Then I added a function that could do some simple processing before writing the audio. And then I added some more stuff, and some more, and so on.
As much as possible, make early prototypes that actually do some useful subset of the problem you are trying to solve. If your program will have users, give them early prototypes and see what they say. The Software Tools book had an aphorism that 80% of the problem solved now is usually better than 100% solved later.
You may also find that, as the users try out your prototypes, they may discover surprising things. Perhaps what they originally asked for isn't what they really wanted, and you need to drastically redesign. Perhaps once they start using your prototype, they may invent new features that they really want more than some of the other stuff they asked for.
And perhaps you may get a surprise: "Yeah, we told you you could have 8 months to develop it, but now you only get 4." And three of those months are already used up. The left-corner design hopefully means you will deliver something. And it might just be enough.
The opposite school of design would be to think everything through and plan everything. Hold long rounds of meetings, draw diagrams, that sort of thing. That may actually be appropriate in some industries; if that's how they do things where you work, study it and try to figure out if they have a good reason for it. But even if so, you may need to knock out some sort of handy utility for your own convenience, and left-corner design is the way to do that.
steveha
lf(1): it's like ls(1) but sorts filenames by extension, tersely
Find the most authoritative reference manual you can find for every tool, every language you come in contact with. The question is not "how do I make it do such-and-so?", the questions are "what is it made to do?" and "what can I make it do?".
Do the onion-skin trick: read -- almost skim -- once, for fast comprehension, don't try to remember everything, just remember the new words and where to find them. Read it again, to remember which parts talk about which other parts. Read it again, to start understanding why those parts talk about those others. Only then should you even start thinking about asking yourself "how do I make this do X?".
Don't trust *anything* in any other book until you can tell what part of the authoritative reference it's talking about. Using C++? Pay the $18 or whatever it is now and read the ISO standard. Every book about C++ you read, tie what it's saying back to a section of the standard, and be sure you understand what both are saying. Using vim? Read the help. All of it. Do it again. Using MS Word? Hit F1 and start reading. Read everything. Using Python? Get the reference manuals and read them. Using TCP/IP? Read the RFCs.
Read The Fucking Manuals. Obsessively. Reread them again a month later. Then again a few months later. The questions are always: What is this made to do? What can I make it do?
Get used to it. I used to tell people I read manuals for a living. Classes are excuses to spend that much time reading the manuals. If you read the manuals, you won't need the classes. There is an *astonishing* amount of crap out there in the help books, useless "simplifications" that obfuscate the point of what they're supposedly explaining.
What worked for me every time I had or could steal the necessary time was, roughly, to overengineer the hell out of it, then boil out all the crap. Antoine de Saint-Exupery's maxim is absolutely dead-on: Perfection is achieved, not when there is nothing left to add, but when there is nothing left to remove.
With a little practice, most of the overengineering and boiling-out parts can be done in your head.
Particularly while you're new, reread your old code, constantly. Go find things you worked on before and read them again.
As always, all IMO. Insert "I think" everywhere grammatically possible.
OK this is just flame bait. There's no DJNZ instruction on the x86. Even if it were a macro, you don't put the colon on the reference to a label, only its definition. Which only goes to show: YOU ARE NOT AN ASSEMBLY PROGRAMMER. It's not your fault, you could have been, but you just aren't. I'm so sick of hearing people gripe about the supposed unreadability of assembly code only to find that they're totally unqualified to be touching it in the first place. I can't make head or tails of most Java code either but that's hardly surprising since I don't know Java. Whose fault is that?
Not to say that the code you were looking at wasn't crap code, but I think you're missing the point. Assembly language (as written by grown-ups anyway) typically has three levels of commenting. The line-by-line stuff is absolute nuts and bolts and sometimes does get a bit inane (it certainly shouldn't be explaining what the instruction names mean since assembly programmers already know that, but it's there to walk the reader through the math etc. and keep track of what's happening in the registers), anyway it's really just there to make sure the low-level logic is totally transparent when you're zeroing in on a modification or bug fix. Until that point you don't even look at the line-by-line comments.
Then there will usually be a line or two at the top of each code block saying what the next chunk of code does at a higher level. And then each subroutine has a block comment at the top that explains the whole thing and how to call it and what it returns and how it reports errors. Or if not, fire the programmer!
Typical C programmers tend to see assembly code as hopelessly overcluttered with comments but, don't get me started on typical C code. It's a cultural difference I guess. All the more reason to specialize.
as a "cowboy coder" (for the most part), I'd like to pipe in: ignore everything he just said.
The only way you will ever be any good at programming is by teaching yourself, writing code in your free time, learning everything you can outside of a classroom. AND outside of work.
Too many people think that programming is something they can pick up by taking a class. I've met the results and it's not pretty.
More importantly: You do NOT need to understand the implications of any low-level operation, because as a Jr. Programmer you should not be the one making those decisions. Premature optimization leads to bad code, and too many new programmers focus on things which they are not qualified to write, or have no business writing. (I have yet to encounter a real-world situation when I have needed to write my own sorting function, hash table, or non-basic tree structure)
Always remember that for all things, someone has already written exactly what you are trying to write. Simply because it already exists, it has had more time than what you are writing has had to work out the bugs. For the love of god, don't write your own "database abstraction layer". Always assume that for any task, someone else knows how to do it better- and collaborate with other people constantly to find out how that is.
People who "aren't trained in programming", but program in their spare time are ALWAYS going to be better at writing code than people who "are trained in programming", but have never written a line of code outside of school or work.
-- 'The' Lord and Master Bitman On High, Master Of All
Wouldn't have been the Millennium would it? :-)
Write functions that do what their names claim they do and NOTHING else. Then comment on non obvious things, pre conditions for algorithms etc but do not put comments in instead of better function names, decomposition etc! Yes, your could should be readable without comments. Oh and yes, pick up many different languages and perhaps most importantly - have fun!
If you are going to design and implement software components that have any UI in them, please FOR THE LOVE OF DOG do not assume yourself to be a competent GUI designer and expert, just because you know how to spell out language logic into your IDE or WYSIWYG editor. Even if it has a GUI editor, leave it alone and abstract your non-GUI logic so that you can connect it to a GUI later when someone competent in the area finishes one for you.
Awful GUIs as a result of mismanaging priorities and areas of competence are all around us, and I am sure you yourself pondered over few bad examples. Now is your chance to understand the issue and not make the same mistake again.
I presume of course that your are a software programmer, not both (which few people are). You are not your target audience, so if you think an OK button should be to the left, it does not make you an authority in the matter.
When it comes to the rest, most is already said. Observe, be careful in the beginning, design as much but not more than you can in advance, minimize the code writing phase (it will spare you your arms and brain). Do not overcomplicate neither the software, nor the tools you will use to create the product, tools like IDE, compiler, UML editor if any, etc. Do not overuse the abundance of choice you as a software developer have. The most useful software is very simple in the sense that it achieves its goal exactly, no less, no more. You will be thanked for that more than you will know. Read books, as much technical as wisdom-and-guidance sort. But reserve an opinion, it is what makes you an unique programmer, not just a typewriter monkey. Be skeptical meeting the type of programmers that try to convince you about some definite programming practices they sincerely think are best. Heed to their wisdom of experience, but reserve an opinion. Value practical code over theoretical approach, because it is the real products we use, not theories. But do not reinvent the wheel, most theories have been implemented in practice, and it is what makes your life easier.
Remember, the most probable goal of your company is to make money, so that you can get your salary and your boss may buy himself a new wristwatch for 2 grand and pay ails to his ex-wife. Combined with the fact that most folks that comprise the bulk of an IT company would not know half of what you will know about IT internals, they will ignorantly still push their own ignorant agenda when it comes to the style of product. It is your job to provide them with the necessary insight so that product is quality, not just a seller. Adobe Photoshop may sell well, but it is in absolute sense a mediocre product.
Thanks for reaching this far.
Don't go Overkill,
But if you have to copy/paste a section of code > about 6 lines, it should be put into a Function/Procedure that is globally accessible.
There's nothing worse than finding a bug in a section of code & realise it's in 10+ different places.
Name Functions/Procedures something suitable, readable code will help you & others. (same for variables, unless its obvious).
Rest is pretty much depending on what language ur coding for. I assume its OOP (of some sort).
Another pair of eyes (programmer) is sometimes good as well, another person may think of another approach etc.
And always if in doubt, use google... :)
It worked even for COBOL. If you don't know where you are going, it doesn't matter how you get there.
You'll have to upgrade your wardrobe if you're moving from tech support to programming. For example, your tennis shoes need to be thoroughly cleaned. Toss out the ripped AE jeans and get Levis. A little facial hair wouldn't hurt, just make sure it's a little shaggy around the edges. And don't forget to start wearing your hair longer. You'll also need a trademark, like suspenders or orange sneakers, or maybe chewing tobacco and always walking around with a cup in your hand. Use one drawer of your desk for late-night snacks. Toss out all the trail mix and stock up on twinkies (Hostess - not the generic ones). Ho-hos are okay on Fridays, but generally stick with the Twinkies. On a more serious note, don't try to reinvent the wheel. Find some similar code that someone else on the team has written and use that as a starting point. Never start from scratch.
Your code is probably going to be read a bazillion times more than edited. So take some more time to write it clearly.
Performance is hardly an issue for most business apps - and you should solve most performance issues by choosing the correct algo/method, rather than optimizing code. 80/20 rules applies, 80% of the time is spent in 20% of the code. And the performance critical parts of the code are probably 5% (for most people).
The compiler is not buggy. Even though gcc might spit insane amounts of errors for a single mistake in STL, the compiler is not buggy. Even though you read your code a hundred times and you can't find a mistake, the compiler is not buggy. It's infinitely more likely that you have screwed up than it is to have a tool error (unless you're doing Verilog/VHDL :)
Learn to use a debugger. Any debugger will make you appreciate what the code does better.
Read Code Complete, Pragmatic Programmer.
10 Learn how to learn better.
20 Keep learning and practicing.
30 Goto 10
All bow to his Noodliness!! His Noodle Appendage has touched me!
Learn C (need to understand the computer memory model), and that's it. All the rest is bullsh... and fashionable stuff.
... I'm still a new programmer. Stay adaptable, keep learning, never assume you know all you need to know. Learn from everyone including the new programmers who are just learning themselves. Take time at least once every few weeks to stop and ask:
Once a year I stop and spend some time thinking hard about:
So far this strategy has worked for me... of course it took most of the first decade to discover it. You are welcome to copy off of my notes. Asking Slashdot shows you are at least curious, that's good, take time to learn about and learn from leaders in your technology niche.
[signature]
Taking the question seriously for a minute -- something unusual for this venue --
Whatever rules you use, make sure they are the same as everyone else on the project. That includes the rules around comments, indenting, and bracket locations. I've seen huge arguments over placement of an enclosing bracket on the same line as a declaration or a new line.
Once you have a little comfort in a language, get on an open source team. They have to be very good about practices because they have hundreds of people working in different locations at different time zones around the world. You'll start with no real authority, being allowed to submit small changes specific to small branches of code. The owner of that small branch will be responsible for accepting your changes if they're good enough. Over time, you'll move up the chain. READ THEIR GUIDELINES. OSS teams have, of necessity, very rigid guidelines on code practices that allow hundreds of people to work on code together. They've had huge battles over those guidelines, and very smart people have said very smart things (you can find them hidden in the morass of garbage if you look hard enough) that have gone into those guidelines.
More Specifically:
If you're repeating the same code, put it in a sub or function (a method if you're using an object oriented language)
A subroutine or function should be as fine grained and generalized as you can possibly make it. It should accept as few parameters as it needs, and should return a single value (or perform a single action). Note: Some languages, like C, use the convention of returning a success/failure boolean as the return value, and the result of the function in a buffer passed as a parameter -- that's also a good strategy.
If your routine is longer than a single screen to read, give real thought to how you might break it out into distinct subroutines (or methods or functions)
Avoid overly complex rules for variable naming. I've seen insanely complex variable name rules that are painful to work with and attempt to encapsulate the the data type, scope, and purpose of each variable in its name. That's not necessary or helpful in modern language programming. Most programming environments let you mouse click a variable and instantly view its declaration and often even comments written by that declaration for explanation. If your variable name includes the type and scope, you'll have to refactor it if you change the type or scope (like from integer to long integer, or boolean to enumeration as is quite frequent)
Use an object oriented language where possible
REALLY learn how to use Overloading, Polymorphism, and inheritance in your object oriented language
Avoid global declarations and functions wherever possible. The smaller the scope of any variable or object, the less likely someone or something will step on it later.
draw out -- on paper -- your object model before you build it. Learn to start with an ER (Entity Relationship) diagram so you can understand the relationships between real world objects. Think in terms of "A" is always the parent of one or more instances of "B", "C", or "D", but may be either a parent or a child of "E". Figure that out using real world objects that your code object represents first, on paper. I personally do this on a whiteboard with colored pens first then transfer to software for mapping.
Trust nothing. Your methods, functions, and subroutines should stand on their own regardless of what crap someone else passes to them. In every method, sub, or function, VALIDATE all variable data, always. Check for overflows. Check to see if an object is instantiated (not null or nothing). Check to make sure values are within the expected ranges. These checks are very small in terms of system resources and program run time. Take the time.
Do your declarations, validity checking, and decision making outside your loops. Any loop you make should do as little as possible inside it. Everything you do in a loop ge
The problem with quotes on the internet, is that nobody bothers to check their veracity. -- Abraham Lincoln
Do some programming for fun. Invent a side project for yourself, something you want to do for its own sake. Have fun. Play.
Do you like games? Write a simple game. Do you like math? Write a program that models some mathematical principles.
-kgj
Based on my experience, here's what you should become proficient in:
- Updating monolithic systems with functionality they were never meant for.
- Having lots of meetings. Lots and lots of meetings.
- Looking busy without actually being busy.
- Adding dots, commas, buzzwords and excessively overengineered language to technical documents.
- Taking really long lunches without anybody noticing.
- Getting told that you can't certain technologies because they're too new, and instead using even newer technologies because they were paid for.
That's about all I got. No, what? Of course I love my job. Why do you say that?
- Approach the job the right way. The goal is not to solve the problem in whatever way possible, but rather to solve it in the cleanest and most easily maintainable/modifiable way. You're not coding to solve today's problem but rather to create code than can be easiliy maintained and modified for the next 10 years.
- Minimalism / clean design. Most often the best design is the one that results in the least amount of code. If you can redesign or recode to result in less code (without reducing the functionality or maintainability) then that is a good thing. You'll quickly learn to regognize clean design/code from that with unnecessary cruft/complexity.
- Push yourself to tackle projects that are at the edge of your capability. You won't learn much doing stuff that is too easy! If work doesn't offer enough challenges (or even if it does), do stuff that stretches you in your spare time.
- Learn new techniques whenever you can. Programming talent is like sharks - it needs to move to stay alive! Whatever language/domain you are working in, try to identity the state of the art tools that others are using, and use them yourself. If you are using C++, learn to use the STL right away (hardly cutting edge, but you'd be surprised how many don't use it).
- Ask questions from more experienced developers whenever they arise, or whenever you suspect there's an easier/better way do to something. You'll advance faster by leveraging the experience of others than by having to repeat all their learning errors yourself!
>> The technical part is easy
Not true. to hack some crappy code together is easy. To do an excellent job isn't.
Always remember, Code Reuse != Cut and Paste. Code Reuse should be done thru the use of public shared libraries. If the functionality you need exist somewhere else, but is not part of a common shared library set, look into making it so. Also, before doing this, or cutting and pasting into your code, make sure you understand what it is doing, and does it correctly. I can't tell you the amount of crap code I run into that is obvious cut and paste.
In general,
like all corporate jobs do as your managers tell you. It matters not if you are wrong or right, it matters not if they are wrong or right, it matters not if you are both wrong, it matters not if you are both right. It matters that they directly control how much you earn and how happy you will be in your role and there is not a damn thing you can do except resign to change things.
Do not publicly dis-agree with your management
Try and make your managers look good
Understand the business you are working in, not just the tech e.g. what is AP/AR/GL
Whatever language you are told to use is OK they all do pretty much the same things using different words. Learn concepts not implementations.
Make efforts to meet your users they are your clients and be respectful to them
The only book you need to pick up is from the pragmatic programmers 'The Pragmatic Programmer: From Journeyman to Master' remember although this book details how to do software dev your management overrides this unless you can convince them otherwise.
There are many other books to pick up but in general pick up classic books not how-tos e.g. pick up Mythical Man Month not Dummies guide to HTML, pick up OOA/OOD/OOP rather than the latest O'Reilly, pick up HTDP/SICP rather than Javascript in 24hrs.
If you wish to transcend the mediocre be prepared to understand that most dev shops are truly mediocre. The current status quo in development is in reality piss poor performance.
For heaven's sake, try to be humble. For some reason, this industry just breeds arrogance. You'll run into many colleagues that think they are experts at everything.
Few are, and the real experts are usually the humble ones you don't know about until you actually work with them.
Find those people. Emulate them, befriend them.