Slashdot Mirror


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."

662 comments

  1. Go with the flow by Anrego · · Score: 5, Insightful

    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.

    1. Re:Go with the flow by tekiegreg · · Score: 1

      Oh certainly you're not going to forget the book "Code Complete" are you? Then again, what books to read as programmers can be a whole other post,in fact I think it's come up.

      --
      ...in bed
    2. Re:Go with the flow by martinw89 · · Score: 5, Insightful

      I agree to an extent. As a new developer I think it's important to listen to more than one source. So listen in training but also be skeptical. Try to find other sources for claims.

      And as for my book recommendation, I suggest "Code Complete"

    3. Re:Go with the flow by Anonymous Coward · · Score: 4, Funny

      Tip: Get together with your coworkers after work -- hit a bar on Thursday/Friday night, loosen up, relax, talk shit about your managers, etc. Find out what people do outside of work. Ask the girls if they shave their pussy, the guys if they shave their balls. If you're in the bathroom taking a piss together, compliment them on their cock. Little things like that make the work environment easier and the coding more fun.

    4. Re:Go with the flow by SQLGuru · · Score: 5, Insightful

      Great stuff. Find a mentor. Most technical classes focus on how to use the language, never how to use it right.....at least not until you get to the advanced classes, which as a new dev, you aren't ready for. The best place to learn these things quickly is to figure out who in the group knows what (and is friendly/helpful) and glom on to them. Become their friend (bribe them with caffeinated products) whatever it takes. And absorb everything you can from them. This will usually take more than one expert (best design guy, best coder, best db guy, best politics guy). Just don't be a pain about it....if they explain something once, write it down and don't ask them about it again except for further clarification.

      I love taking people under my wing and helping them grow, but if they keep asking the same questions, I see that they aren't trying to learn anything and just trying to take advantage of my knowledge. I still help those people for the good of the team, but usually with "here's your answer, now go away" approach instead of the "here's your answer, oh, and here's a better way that will make you a better programmer" approach.

      Layne

    5. Re:Go with the flow by calmofthestorm · · Score: 0, Troll

      Or get you fired for sexual harassment.

      --
      93rd rule of Slashdot: No matter how obvious my sarcasm is, my comment will be taken seriously by someone.
    6. Re:Go with the flow by jd · · Score: 5, Informative
      On the other hand, there are some universal rules:
      • Plan/Design everything
      • Document everything
      • Version control everything
      • Test everything
      • Deny everything
      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    7. Re:Go with the flow by Whiteox · · Score: 4, Funny

      On the other hand, there are some universal rules:

              * Plan/Design everything
              * Document everything
              * Version control everything
              * Test everything
              * Deny everything

      Don't forget:
              * Lots of GOTOs
              * Delete those annoying REM statements
              * Use weird, arcane variable names like 'ORGO' and 'FTOOMSH'

      Good Luck!

      --
      Don't be apathetic. Procrastinate!
    8. Re:Go with the flow by SL+Baur · · Score: 1

      "Elements of Programming Style" is probably a better starting place (I hope it's still in print). Whatever language you are programming in is (or should be) irrelevant. For any worthwhile piece of code, development cost is essentially 0 compared to lifecycle costs.

      Errors in code are human. Practice the egoless programming methodology and have your work reviewed by everyone you possibly can, listen to what you are being told. Not all of it will be correct, but you have to develop what Linus Torvalds calls "taste" in programming in somewhere and the more opinions you collect, the better off your code will be.

      Reading (and understanding) other's source code is always important and it's good resume material and good experience to get involved with an open source software project (at whatever level). As maintainer of XEmacs, I wrote letters of recommendation, offered myself as a reference etc. for contributors who wanted that sort of thing.

      And always remember, programming is fun! If it isn't fun for you, then perhaps you pursuing the wrong line of work.

    9. Re:Go with the flow by Rei · · Score: 2

      Even better than GOTO -- if your programming language supports them, COMEFROM statements can be a godsend. If your language doesn't support them, have your program call programs written in languages that do; wise usage of INTERCAL linkages can help ensure that you're seen as irreplaceable in your position.

      --
      You don't exist. Go away.
    10. Re:Go with the flow by Anonymous Coward · · Score: 5, Funny

      For the complete list see how to write unmaintainable code at:

      http://mindprod.com/jgloss/unmain.html

    11. Re:Go with the flow by Nefarious+Wheel · · Score: 5, Insightful
      Remember at all times that "Listening" isn't the same as "waiting for your chance to speak". You'll get better mileage by laughing at the customer's jokes than telling your own.

      Keep your reading up, and buy those books.

      Keep a register of absolutely everything anyone asks you to do. Number and date each item. If you don't have access to a help desk-style problem registry then build your own. Make it quick to use. Notepad works. Spreadsheets a little better. BMC Remedy or HP/Mercury Interactive if you're spending someone else's money. Besides being good organisation, it's a serious cover-your-tail survival bonus.

      Make your code clear. You want it to be so easy to read and understand that you can debug it over the phone in a new year's eve party if you have to. (Yes, I've had to.)

      Comments first -- if you can't explain it in English, you probably don't have a handle on the problem yet. If you're chasing your tail and can't get that loop to work right, throw the code out and re-write it in English. Then try coding it again. Remember that English, your natal firmware, has been debugged over the course of your entire life and is still the highest bandwidth channel to your brain. (If you can write correct English, of course. If you don't, treat it like an essential coding discipline you have to learn.)

      Be careful with your code libraries, and avoid bloat. If you're sorting a customer's web shopping basket, consider writing the sort yourself rather than including 200k worth of otherwise unused code. Even the lowly and properly-maligned bubble sort is better than that.

      Conversely, never write your own little calendar applet if you can grab the code off the web. Plenty of work out there without requiring everything to be crafted with your own unique style.

      Never, ever code when you're tired, you will break something. Caffiene is for the smiley boost during the work shift, doesn't cure the 10th hour stupids.

      Disclaimer -- I've been a programmer for nearly 40 years, so I'm probably a stupid old person now. You're allowed to ignore the above (heh heh).

      --
      Do not mock my vision of impractical footwear
    12. Re:Go with the flow by clockwise_music · · Score: 1

      "Pragmatic Progammer" is horrifically outdated. Do not bother - you'll actually learn things that are very bad practice. (only learn 1 text editor?? please).

    13. Re:Go with the flow by Hal_Porter · · Score: 1

      You may joke but when you do static binary translation, finding the COMEFROM's by hand is very time consuming.

      http://www.gtoal.com/sbt/
      Well, we need to know the flow control of the program and note the destinations of jumps. Those jump destinations are the only opcodes which need to be labelled. To some extent you might be able to work those out statically, by having a slightly smarter disassembler framework which does a tree-walk of the source, starting at the entry point. I.e. whenever it hits a branch or subroutine call, it also goes off to the destination and looks at the code there too. The problem with this is that very few architectures are designed so that you always can determine the jump destination just by looking at the code. Most architectures allow indirect jumps through store or registers, or let you tweak a return address on the stack so that your return from subroutine goes somewhere other than where your subroutine was called from. This is a major pain in the ass and the only practical solution is to profile the execution of the code and mark the jump destinations at run time.

      In fact if I were designing a JITable VM, I would definitely have a list of possible jump destinations in the executable format.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    14. Re:Go with the flow by huckamania · · Score: 1

      My favorites...

      Compile early and often
      Save often
      Backup your work area

      I've done it myself but always regret writing a ton of code and then waiting to save it or compile it. Also, make sure your work is getting backed up on a regular basis. Disk errors always seem to occur when you haven't done a backup for a long time.

      It sounds like you are going to be working on existing code. As soon as you get access to it, build it and run it. If you have a decent debugger, run the existing stuff through it and make sure it behaves how you are expecting it to behave. Keep a separate work area for your code so when the new code breaks, you can diff it with the old code.

      I just started at a new company and I had the code built and running in debug mode the first afternoon. Haven't looked back since.

    15. Re:Go with the flow by IorDMUX · · Score: 1
      You jest, but the first code I saw at my new job looked that way.

      The previous programmer went ahead and unrolled a bunch of loops, cleared the code of comments (supposedly, it had some at one point), and scattered his magic numbers everywhere (down to lines that simply read "X = Y * 200 / 100 + 12 - C - 1;").

      The variable names were the most amusing. They fell into three categories--the hopelessly obfuscated, the pointlessly simple, and the... well, just look:
      • Hopelessly obfuscated
        • Ca_calun8_infil_o3 (something to do with capacitor calibration unit, .. input, .. file?
        • xcssc32 (it multiplied some stuff)
        • C_C_R_S_T_1 (I think it's "Capacitor Calibration Register ... I give up)
      • Group 2
        • list1 (reused a number of times)
        • variabel2 [sic]
        • x (This one's okay as a for loop counter or the like, but here it stored a value that was not used again for hundreds of lines)
      • Group 3
        • Uh... The programmer abbreviated Capacitor Unit --> CUnit --> A very mean thing to call a woman.
      --
      >> Standing on head makes smile of frown, but rest of face also upside down.
    16. Re:Go with the flow by Brickwall · · Score: 1

      Wish I had mod points! I followed the link, and laughed my head off for an hour.

      --
      What was once true, is no longer so
    17. Re:Go with the flow by Anrego · · Score: 1

      I dunno.. I agree there is the odd bit of bad advice (such as what you just mentioned).. but I think in general the book gives some very level headed practical advice.

      That being said, I don't think I have ever found a book that didn't say _something_ I disagreed with. It's all about reading, absorbing, but not mindlessly assimilating.

    18. Re:Go with the flow by blad3runn69 · · Score: 1

      heh you make a lot of sense and make very good points. Thanks.

    19. Re:Go with the flow by MadKeithV · · Score: 1

      So there's one item in there that you might disagree with, and that makes it "horrifically outdated"?
      Err. No.
      It's still one of the best non-technical starter books for developers to know what the true spirit of software development is. Like another reply says: every book is likely to have something you disagree with. Many times the items you disagree with are the most interesting ones, because they may contain wisdom you have not previously considered.

    20. Re:Go with the flow by thogard · · Score: 1

      Remember for short lived variables its i,j for integers and x,y,z for floating point unless your doing 3d work and then its a,b, and c.

    21. Re:Go with the flow by jhol13 · · Score: 1

      I'd recommend "design" and "document" once again.

      UML, with its limitations, is a good design tool. Thankfully some modern IDEs have it (NetBeans, for example). No, it is not sufficient, i.e. you need more (text explanation, pictures, ...).

      Documenting will show when (not if) you go astray, off the specs.

      For version control - don't use CVS. Even Subversion is a bit suspect, distributed version control systems are better. Even in single person projects. I synced code between my development desktop and lab debug machine with Mercurial, it decreased the number of mistakes by a factor of ten or more (compared to hand-copy) and allowed independent branches (and reliable merges - not yet in Subversion).

    22. Re:Go with the flow by Count+Fenring · · Score: 1

      Wasn't it "Only learn one text editor completely?"

      I mean, know vi, emacs, and the standard IDE pattern well enough to use them if dropped into them... but is it worth the time to become a wizard in multiple editors?

    23. Re:Go with the flow by kwerle · · Score: 1

      What he said. Or she. Whatever.

      I highly recommend getting an external tester if you don't already have one. I find that when I test my own stuff, it usually works. But when someone else tests it... Not so much.

    24. Re:Go with the flow by Mr2cents · · Score: 2, Insightful

      I really hope that, one day, writing code like that will be a capital offence. Sometimes I just wonder what's going on in the heads of people who write code that way. Don't they ask themselves why their code doesn't work well? It didn't work well, did it? Unless if it was a small application, code written like that is guaranteed to be full of bugs.

      I recently saw a very interesting webpage (I've even printed it out) about coding: http://bsolano.com/ecci/ci-2200/artu/ch01s06.html

      In 11 pages, it condenses a lot of the knowledge you learn after programming for 20 years. Very, very interesting.

      The rest is discipline to keep your code clean and well documented. Also, if you don't feel 100% comfortable with how you are going to implement a function, write the function comment first and describe what the function does. I found that by first writing it down in plain text, it becomes easier to transform the idea into statements. It's tricks like that you'll have to learn.

      --
      "It's too bad that stupidity isn't painful." - Anton LaVey
    25. Re:Go with the flow by centuren · · Score: 1

      I've both been a new developer, and also have trained plenty of new (and I mean new) developers.

      Ask your lead developer (or the most senior developer on your team) questions without fear. If the answer is "figure it out", expect that answer without worry.

      Try to learn what good, maintainable code looks like. If you're working with an ugly code base, tacking on top of it to get the quickest results is not the way to go. In my experience, any developer will appreciate taking the time to implement a good solution in bad code, rather than adding bad code. It's the PMs and managers who push for faster results, and doing a good job is a golden defense.

      Starting out, you will likely be slow, but it's much better to question and learn how to improve your efficiency without sacrificing quality.

      People are divided on this, but take a look at your typing ability. I may be influenced by a command line background, but it's my experience that has shown that programmers who cut and paste a lot, and don't make an effort to learn to touch type efficiently (that is with code, mavis beacon doesn't cut it here), are much more likely to replicate bad code and more likely to not fare so well in the company.

      I've had to train some desperate hires, and I've had some really bad experiences with code written by people I'd qualify as poor to bad typists. Since the new programmers work almost entirely in PHP, the line I use is that I expect them to start to type "$this->" as effortlessly as they type their own name.

      The typing approach is entirely up to debate, and I'm sure there are thousands of programmers much, much more talented than I, who disagree. I'm not going to defend it.

      More important is questioning, and learning what it means to write clean, logical, maintainable code. Don't be intimidated, when questioned how an error came to be in code you wrote, I always found the best answer to be "programmer error". It happens, that's the learning process.

      How code flows on a page is important, and a lot of the code I send back to new hires is accompanied by a second copy in which I merely moved things around and condensed functions to make it more readable, with only one or two actual code changes.

      Look at some good code, look at some bad code, and the difference is often apparent at first glance. Remember that in a development environment, the initial exploratory process can be messy, but at the end of the day, the work you save might be reassigned and someone else will be dealing with it.

    26. Re:Go with the flow by Anonymous Coward · · Score: 0

      And me without my mod points... Oh well, I don't think I could decide between funny and insightful anyway.

    27. Re:Go with the flow by centuren · · Score: 1

      On the other hand, there are some universal rules:

      • Plan/Design everything
      • Document everything
      • Version control everything
      • Test everything
      • Deny everything

      Plan/Design, Document, and Version control everything are not his responsibility as new dev (although good advice for a dev team). Run your own tests, but expect a testing process beyond your own. Deny everything is misleading. You can't always say "the problem is on the user end". The fallback is saying "okay I'll fix it", pointing out or alluding to the bug fix round being a normal and expected part of the development cycle, and, if the bugs made it live, the failure was in a different link in the chain.

    28. Re:Go with the flow by centuren · · Score: 1

      foo and bar are required variable names also.

    29. Re:Go with the flow by centuren · · Score: 1

      I should add, learn regular expressions. It's an amazing how few programmers are comfortable with them, when they are so useful.

      A modest background in Perl and Vim as my choice of text editor made me the company RegExp guru in no time. Non-Linux people can be very impressed when you do an inline cut command in vim using a regular expression (that you type quickly and flawlessly, thanks to your technical typing speed).

    30. Re:Go with the flow by Anonymous Coward · · Score: 0

      On the other hand, there are some universal rules:
      Plan/Design everything
      Document everything
      Version control everything
      Test everything
      Deny everything

      Universal? We're talking about work here, not what you do at home. You know, work, the place where the boss makes the decisions... Even if said boss says "we don't need design", even when the people who have design experience from previous work explain to him that things are taking ten times as long because we don't have any design.

    31. Re:Go with the flow by c0p0n · · Score: 1

      Don't even get me started on the indentation topic...

      --

      Your head a splode
    32. Re:Go with the flow by tomatensaft · · Score: 1

      Man, even in programming experience means something! Great post!

    33. Re:Go with the flow by jacquesm · · Score: 2, Interesting

      My advice to you would be: Stay the hell out.

      Seriously, if you're just attracted to programming because of the career opportunities then programming is not for you, and it will make the life for the rest of us that much harder.

      You'll compete with people that *really* like to program for jobs, you'll give us all a bad reputation for producing crappy code. The world has too many third and fourth rate coders already for you to think that your support desk background is the stepping stone to becoming a programmer.

      Real Programmers (tm) were doing it when they were 12 or 13 (and sometimes even younger) because of a fascination with the tech, not for the money.

    34. Re:Go with the flow by kaizokuace · · Score: 2, Funny

      also, don't boink the boss's daughter for at least 3 weeks!

      --
      Balderdash!
    35. Re:Go with the flow by Anonymous Coward · · Score: 0

      Another Universal rule:

      Functional Programming >>> {The Rest} >>> Object Oriented Programming

    36. Re:Go with the flow by digitig · · Score: 4, Insightful

      Then again, what books to read as programmers can be a whole other post,in fact I think it's come up.

      Yes, but the general principle of "keep reading" is a good one. Read code. Read books (online or dead tree). Read articles. Read about new technologies, new approaches to old technologies, innovative solutions, successes, failures, pretty much anything. The person who stops doing background reading once they can do their job is a person who stalls and gets left behind. Do read critically, though, and remember Sturgeon's 2nd Law ("90% of everything is crap") -- there's nothing (well, not much) worse that someone who wants to overhaul the complete development process just because they read a magazine article about a new approach that promises to solve all the problems of everything that went before!

      --
      Quidnam Latine loqui modo coepi?
    37. Re:Go with the flow by Anrego · · Score: 1

      I may not have put is as bluntly, but I would be inclined to agree with the basic point you made.

      I would point out that he did say "for money". I've known _many_ coding gurus relegated to help desk/support type jobs because they never got the formal education or couldn't find an entry level position with no experience. Where I live, very few companies hire entry level, so new graduates have to either move somewhere else, or if they want to stay put, take a crap job and hope to one day impress the right person and get into the role they wanted.

      The really great programmers I know all found it on their own... and then later decided to pursue it as a career.

      I fall into this boat (doesn't automatically make me a great programmer though).. I got into programming fairly early on, then decided some time during high school that I'd make a career out of it. I got lucky and was able to get into a nice job (thanks in large part to references I got doing volunteer work.. karama++)

      So I guess to sum all that babbling up.. if the poster is a long time hobby programmer.. but has just never programmed for a company... then for all we know he could be great. Certainly the fact that he is asking these questions means he at least cares about the quality of work he will produce. Thats more than a lot of programmers out there.

      On the other hand if he had no prior interest in programming.. and is just seeing this as a bigger pay cheque.. then yeah... stick with the help desk.

    38. Re:Go with the flow by jacquesm · · Score: 1

      from the summary: "Now my company will be training me, so I think the technical side of things will be covered"

      That pretty much puts me in the 'stick with the help desk' camp, if you think a couple of courses are going to make up for a lack of interest and prior knowledge then please don't...

      Coding to me is like making music, sure you can learn how to do it by rote but it will never ever make up for the elegance and quality of someone doing it for the love of it.

      That said there are plenty of corporate trained coders that produce excellent work but they almost without fail have an engineering or scientific background, hardly ever an office one.

    39. Re:Go with the flow by ciderVisor · · Score: 1

      And as for my book recommendation, I suggest "Code Complete"

      A fantastic book. I'm just surprised to see so many /.ers recommending something issued by Microsoft ! Another good one is 'The Art of Unix Programming' by Eric S. Raymond (yeah, that one). You can read it online, too. http://www.faqs.org/docs/artu/

      --
      Squirrel!
    40. Re:Go with the flow by Tarwn · · Score: 1

      I would disagree. Planning and Design is every developers responsibility. Whichever piece your responsible for (from the whole thing down to one small chunk), you spend time planning it before jumping in to put code on the screen.

      Even if you have smoeone who works full-time just on documentation, you should be providing them with at least notes and good comments, if you don't have a documentation person than don't expect your Mom to come in and do it for you later.

      Version Control is iffy, depends on your environment. Some places won't let certain levels of developers touch version control, some places only have one developer and versioning isn't even setup yet. in the second case it should be setup and used, in the first case someone else has the responsibility.

      Self-testing is critical in many environmants. Small development groups may not have dedicated test people, frenzied environments may have test people, but part of the testing should include "Does it work the Way I, as the developer, expect it to?". In a frenzied environment you don't often get a chance to go back and fix these things, test early and test often.

      --
      Whee signature.
    41. Re:Go with the flow by tacocat · · Score: 1

      The Art of Unix Programming.

      This is an excellent book that is not based on fad or fiction but takes programs that have an established history of working and examines why and how they work so well. From this, many advanced applications can be developed such that they are easy to maintain, debug, write, enhance.

      I think this is often overlooked as a Great Book in the software community. It's very insightful at a level that any shop or practice will benefit. It makes you a better programmer.

      My other fav is The Design of Everyday Things. It might be out of print, but it's worth finding. Very valuable if you are building any kind of GUI.

      What I like most about these books is that they are not the typical software developers books so they don't come with a prerequisite that you know everything about the one language they use as an example. These apply to very common concepts that the authors are (re)introducing into the software development world. They are about programming/design philosophy rather than development methodologies.

    42. Re:Go with the flow by Anonymous Coward · · Score: 0

      On the other hand, there are some universal rules:

      • Plan/Design everything
      • Document everything
      • Version control everything
      • Test everything
      • Deny everything
      • Use vi
    43. Re:Go with the flow by John_Sauter · · Score: 2, Insightful

      Disclaimer -- I've been a programmer for nearly 40 years, so I'm probably a stupid old person now. You're allowed to ignore the above (heh heh).

      I've been a programmer for 45 years, so I am definitely a stupid old person now. Nevertheless, for what it's worth, I endorse the above advice.

    44. Re:Go with the flow by Swizec · · Score: 1

      Some of us started at 9 you insensitive clod!

    45. Re:Go with the flow by Anonymous Coward · · Score: 0

      Have you been reading my code? It's full of GOTO's and might actually have a variable named FTOOMSH...

      (So ashamed...)

    46. Re:Go with the flow by TrueJim · · Score: 3, Informative

      Whenever you write code on future projects, you're often going to start by trying to re-use code from previous projects. So don't just treat the source-code you're writing now as something you know you're going to reuse in the future. Try to think of each useful chunk of code you write as being part of a "package" that includes not only the code itself, but also the associated documentation, the test cases, the performance metrics, use cases, the build files, etc.

      You want to write the entire -package- so that it can be re-used on future projects, not just the code itself. Remember that as a developer only a fraction of your time is actually spent writing code: the bulk of your time is spent putting together all that associated "stuff." So make the "stuff" re-usable too.

      --
      I hope that after I die the one word people use to describe me is "resurrected."
    47. Re:Go with the flow by jonaskoelker · · Score: 1

      Lots of GOTOs

      I've heard from a very reliable source that GOTO are dangerous: http://www.xkcd.com/292/

    48. Re:Go with the flow by Anonymous Coward · · Score: 0, Flamebait
      Oh my goodness! You printed that webpage out?! How amazing! How fascinating! How exciting!

      Go fuck yourself, dumbass. No one give's a shit what you fucking printed. And next time you need to print something that you'll never look at again, don't.

      sincerely,
      Your Boss

    49. Re:Go with the flow by Rob+Kaper · · Score: 1

      Uh... The programmer abbreviated Capacitor Unit --> CUnit --> A very mean thing to call a woman.

      Mean? Way off-topic but can someone explain to me how cunt is any worse than, for example, dick or ass?

    50. Re:Go with the flow by jacquesm · · Score: 1

      neat !

      I'm actually tutoring a kid that is 10 right now, he's quite amazing...

    51. Re:Go with the flow by Bitsy+Boffin · · Score: 1

      Cornflakes. Cornflakes. Cornflakes, Cornflakes, Cornflakes. Cornflakes, Cornflakes, Cornflakes, Cornflakes.

      Cornflakes.

      ***
      The postercommment compression filter is the single most predicatable and boring filter that any post could be subjected to.

      --
      NZ Electronics Enthusiasts: Check out my Trade Me Listings
    52. Re:Go with the flow by sdpuppy · · Score: 1
      You forgot one essential obvious item that we all forget from time to time:

      When changing code that was previously working, be sure to keep a backup copy.

      now where's that misplaced semi colon grumble

    53. Re:Go with the flow by Swizec · · Score: 1

      Tell them right now that the people they'll eventually work for/with will be idiots with, at twice the age, seemingly much less experience. It comes from talking programming languages almost like they were natural, every other programmer you meet just seems ... stupid.

      Please, tell the kid this, I only wish someone would have told me back then (I'm 20 now and suffering through courses designed for people with 5% my programming experience)

    54. Re:Go with the flow by EraserMouseMan · · Score: 1

      Furthermore,

      Put as much code as possible into the same subroutine. When your subroutines are over 1000 lines you've got the hang of it.

      * Do all of your validation on the client side. Nobody turns off javascript any more like they used to.

      * Screw layered architecture. It just creates way too many confusing files and projects.

      * Error handling? Your code should just work properly. Error handling is for the weak.

      * Code is like art. Every programmer should have their own unique standards.

      * Pick one modern popular language and vehemently refuse to work with any other language.

      * Never work with anybody else's code no matter how seemingly battle-hardned. It is always faster and better to start the project over from scratch (especially if you can change the language to your pet language).

      * Have I missed any essential tips?

    55. Re:Go with the flow by iphayd · · Score: 1

      make sure to use different variations of both. foo2, bar493, and a couple baz's are all valid.

    56. Re:Go with the flow by Phreakiture · · Score: 2, Insightful

      Draw lots of pictures.

      You don't necessarily need to have a flow chart, per se, but they can sometimes be helpful. Other times just an informal scrawling on a whiteboard will suffice.

      What I do is this: First, I write pseudocode. I indent it properly. Next, I turn the pseudocode into comments. Finally, under each pseudocode-generated comment, I will write the actual code to support it. You might also consider these as a good place to break out a function/method from the main programming logic.

      I repeat jd's point, and emphasize it: VERSION CONTROL EVERYTHING .

      When you discover a bug (as surely you will), some developers like to take the approach of writing a test to look for the bug, then solving the bug. This prevents the bug from creeping back in in later versions.

      I think that's all I've got for the moment.

      --
      www.wavefront-av.com
    57. Re:Go with the flow by Twyst3d · · Score: 1

      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.

      Most companies these days do the later

      --
      And this has been another installament of Captain Obvious! /whoosh
    58. Re:Go with the flow by kiwimate · · Score: 1

      "Vyvyan! Have you been using my roll-on deodorant again? There's a revolting hair on it and it's not one of mine!"

      "How d'you know?"

      "Because I know what mine look like, Vyvyan, I can see them now!"

      "Not the ones on your bum, you can't. Perhaps it's one off your bum."

      "Oh! And I suppose you think that being lewd first thing in the morning is a terribly trendy thing to do, do you, Vyvyan? Well it's not!"

      "Look, it's probably a hamster hair. He was getting a bit whiffy, so I gave him a good going over."

      "And was I consulted, pally? How d'you think I feel, stinking like a student's armpit?"

      "It's stealing Vyvyan. It's common stealing. And if you ever touch it again...ever!....I'm going to the police. I will, you know, I will go to the police!"

    59. Re:Go with the flow by Rasperin · · Score: 1

      KISS (Keep It Simple Stupid) if it's already been done, it's probably been done better than you can do it. Code reuse is the key to the current days woes in programming so be ready to do that. Also, make sure you have a damn good grasp of the languages syntax and how it's supposed to work (also a few design patterns wouldn't hurt). If you are working in Java my suggestions are Head First Java Effective Programming (by Joshua Bloch) (EE enviroment) Head First Servlets and JSP's Head First Design Patterns Yeah, I like my comic books version of programming tutorials.

      --
      WTF Slashdot, why do I have to login 50 times to post?
    60. Re:Go with the flow by j-pimp · · Score: 2, Insightful

      Mean? Way off-topic but can someone explain to me how cunt is any worse than, for example, dick or ass?

      Women get offended more easily.

      --
      --- Justin Dearing http://www.justaprogrammer.net/ We're just programmers.
    61. Re:Go with the flow by Whiteox · · Score: 1

      But do you see the timeless wonder of it all?
      You see, you plant the seed, you grow the seed, you eat the seed.....
      THWAAAAK!

      --
      Don't be apathetic. Procrastinate!
    62. Re:Go with the flow by j-pimp · · Score: 1

      Another Universal rule:

      Functional Programming >>> {The Rest} >>> Object Oriented Programming

      What do you define as "the rest." I'll accept functional programming is this great thing for some reason many people (including me) never adopted. But I think object oriented programming is greater than procedural programming in most cases. C is nice when you need it. Then again C# lets me call a DLL I wrote in C, or lets me turn off garbage collection. They even wrote an OS in it.

      I don't think C# s the end all to everything. However, I think .NET was done right in many way. I also think F# is the next step in that "done right" thing. I think .NET is just the herald of something better, probably not from Microsoft. But that successor will also have a better successor.

      --
      --- Justin Dearing http://www.justaprogrammer.net/ We're just programmers.
    63. Re:Go with the flow by TheRaven64 · · Score: 3, Funny

      Please try to keep up with technology trends. Conditional COMEFROM is now called 'Aspect Oriented Programming.'

      --
      I am TheRaven on Soylent News
    64. Re:Go with the flow by Anonymous Coward · · Score: 0

      I recommend two articles by Joel Spolsky: "The Joel Test" and "Getting things done when you're only a grunt."

      The Joel Test lists twelve things that are ideal for developers. Implement the recommendations as much as you can. There are some good tips about implementing the guidelines in the Getting things done when you're only a grunt article.

      Others have said it, and I agree: Maintenance of code is a lot harder than writing it to begin with. So if you can, write your code with an eye towards maintenance.

      And for crying out loud, use the preferred coding style and guidelines. They exist for a reason.

    65. Re:Go with the flow by joost · · Score: 1

      Also, if you don't feel 100% comfortable with how you are going to implement a function, write the function comment first and describe what the function does.

      Um, how about you write the unit test (or spec) first, then write the code? Comments and everything are good, but the only way to produce high-quality code consistently is to have automated unit test and complete coverage.

    66. Re:Go with the flow by TheRaven64 · · Score: 1

      If you're sorting a customer's web shopping basket, consider writing the sort yourself rather than including 200k worth of otherwise unused code.

      I know this is just an example, but it's pretty unlikely that you will be using a programming language that you will be using a language without a built-in sort routine. The C standard library, for example, includes quick sort (qsort()), and some implementations also include heap sort and merge sort (heapsort() and mergesort()). If you know your library well then you can often avoid writing code, and the less code you write, the easier it is to debug.

      Comments first

      I'd expand this by saying you should learn about Literate Programming. You will almost certainly never be in a position to use this technique directly, but like many other things (e.g. learning Lisp and Smalltalk) it will improve the quality of your code even when you can't use it directly.

      --
      I am TheRaven on Soylent News
    67. Re:Go with the flow by uncledrax · · Score: 1

      Sure.. i mean everyone can say 'ORGO'..

      "Hey.. lets goto the market OR-GO to the pub.. no one says FTOOMSH!"

      --
      ----- The internet has given everyone the ability to have their voice heard equally as loud.. even if they shouldn't be
    68. Re:Go with the flow by rhiorg · · Score: 1

      your Young Ones reference made my day.

    69. Re:Go with the flow by Thaelon · · Score: 1

      Conversely, never write your own little calendar applet if you can grab the code off the web. Plenty of work out there without requiring everything to be crafted with your own unique style.

      I would amend this to read, "Never write your own calendar/Date code period." I know the parent poster is talking about a GUI widget, but this brings up a tangential point. Don't try and create your own Date/Calendar utility. Getting one 100% right on your own is nigh impossible. For example, the Gregorian Calendar code in Java 1.5 is 2900 lines long. Heavily commented, but still. Getting a date/calendar correct is a non-trivial task. For example, we once had a customer try to get us to send dates in "their format" which mean 12 months of exactly 30 days. It was one of the few times we told a customer to pound sand. That's how you do it wrong.

      For my own points:
      Get The Pragmatic Programmer, Mastering Regular Expressions, and spend some time writing C. Not C++, C. You'll learn intimately what's going on behind the scenes in higher level languages when you instantiate something, and how pointers really work. You'll especially appreciate string classes after living with unterminated character arrays. :-)

      Learn a scripting language you can use in your current environment. I recommend perl or bash (google advanced bash scripting guide). Perl is available about anywhere, so is bash via Cygwin on windows.

      Find a good editor/IDE for your language(s). For Java I recommend IntelliJ IDEA if you can get them to buy it (I'd buy it myself if my company wouldn't). For me Eclipse is a distant second, but it's free. I'll leave C++, C# etc. up to someone else to recommend editors/IDEs for.

      --

      Question everything

    70. Re:Go with the flow by Eudial · · Score: 1

      also, don't boink the boss's daughter for at least 3 weeks!

      That won't be a problem, he frequents slashdot.

      --
      GAAH! MY PRINTER IS ON FIRE!!! PUT IT OUT! PUT IT OUT!
    71. Re:Go with the flow by Anonymous Coward · · Score: 1, Insightful

      Excellent advice in the parent. I'd add:

      - Get written approval / agreement on all changes to requirements and schedule.

      - Get written confirmation on priorities.

      - Build automatic testing with the application; a test infrastructure to validate every function point is required. You'll probably spend 50% of your time on testing. It is really nice to be able to run regression tests after a build and **know** you didn't break anything else.

      - Pad your schedule by at least 3x. If you really think it will take 2 weeks to code it, report it as 6 weeks so you can add testing, installs, documentation, version control overhead. We're all optimists - before reality happens.

      - If you have a release cycle - learn when to freeze new features so you can beet the date by a week.

      - Get an independent QA team.

      You won't be able to follow most of these suggestions due to a boss who hasn't a clue about software stability.

      I only have 22 years of experience, so I'm probably clueless on this development stuff.

    72. Re:Go with the flow by feldicus · · Score: 1

      I'd suggest taking at least one pass over "The Mythical Man-Month", if only for the principle of "build one to throw away".

      feldicus

    73. Re:Go with the flow by mindstrm · · Score: 1

      Ultimately that's subjective...

      I, for one, find it quite clearly a level more offensive then the words you mention.
      Based on nothing, of course.

    74. Re:Go with the flow by Anonymous Coward · · Score: 0

      One thing to keep in mind is that performance and readability can be a trade off. For example bubble sort very simple, very easy read, very slow. Quick sort harder to read and understand.

    75. Re:Go with the flow by klapaucjusz · · Score: 1

      Delete those annoying REM statements

      It was difficult to write, there's no reason it should be easy to read.

    76. Re:Go with the flow by Anonymous Coward · · Score: 0

      agree on code complete. See also, the Pragmatic Programmer.

    77. Re:Go with the flow by Anonymous Coward · · Score: 0

      You're a fucking retard. As a programmer who comes from a support desk background, I can honestly say that most of you "nose-in-the-air" programmers write some of the least maintainable code I've ever seen. If most of you actually knew how to write unit tests and understood why you do so, us people from the helpdesk wouldn't have to step up to fill your spot.
      </rant>

      Seriously though, I've only been writing code for about 2 years. I've got a lot to learn, and yet somehow I seem to be the only one with interest in actually learning. Yesterday I had a "senior" ask me for help with a quick and dirty script I wrote. It turns out that he'd modified the script, couldn't write a goddamned if conditional right and broke the code. Of course, he would have known he'd screwed it up had he not commented out my unit tests simply because they were failing after his change. He's got a degree. He's been programming for many years at highly prestigious companies. I'm pretty sure he likes his job.

      That does not, however, make him any better than me. It's a lesson most arrogant programmers need to learn.

    78. Re:Go with the flow by Anonymous Coward · · Score: 0

      * Use weird, arcane variable names like 'ORGO' and 'FTOOMSH'

      Variable names can have more than one letter? Gosh, the things you learn here.

    79. Re:Go with the flow by Anonymous Coward · · Score: 0

      GOTO is essential for modern coding.

    80. Re:Go with the flow by ckaminski · · Score: 1

      Cunt is to cock as dick is to pussy...

      I might say either of the latter in front of a 10 yo, but neither of the former unless the shit is really hitting the fan.

    81. Re:Go with the flow by Anonymous Coward · · Score: 0

      Training? What's that?

    82. Re:Go with the flow by Logic+and+Reason · · Score: 1

      Be careful with your code libraries, and avoid bloat. If you're sorting a customer's web shopping basket, consider writing the sort yourself rather than including 200k worth of otherwise unused code. Even the lowly and properly-maligned bubble sort is better than that.

      That may just be an example, but what modern progamming environment lacks a decent sorting algorithm, with "pluggable" comparison operators?

      More generally, I'd warn against being too concerned with "bloat" coming from libraries unless you are specifically targeting resource-constrained environments. Memory is cheap, and every line of code you don't have to write is a line you will never waste time and brain power on, and a line in which you will never accidentally introduce a subtle bug.

    83. Re:Go with the flow by hendrikboom · · Score: 1

      This is a joke. It is funny to us experienced programmers, but it is misleading to the original questioner, who may not have the experience to realize that he's being advised to do wrongs.

    84. Re:Go with the flow by itwerx · · Score: 1

      Well, I think you'll probably pick up those best practices as part of your "training".

      Yeh, sounds like he's got a good head start on things already:

      the last 3 years of support desk gives me the business sense

      ROFLMAO!

    85. Re:Go with the flow by jacquesm · · Score: 0

      Your post is about as arrogant as they come.

      Who do you think came up with unit tests to begin with, someone in the help desk department ?

      You've been programming for *all of 2 years* and you think you are in the same league as people that have been doing it for 30+ years ?

      I'm sure you'll point me now to your amazing track record during these two years ? It's a funny state of affairs when help desk people get promoted to write software when there is arguably a surplus of seasoned programmers out there (according to an article a few days ago on this site).

      What am I doing wasting my time with an AC anyway, but really, come back when you've written a nice little os or something like that instead of a few 'scripts'. That hardly qualifies as programming anyway.

      Writing scripts is 'programming' in a sense, but hacking three blind mice out of a piano is also 'making music' in that same sense.

      Go take a look at the guts of GCC, the linux kernel, some of the more interesting stuff that comes out of SIGGRAPH, write a speech recognizer for a large vocabulary and multiple users and we'll talk about your programming skills.

      Until then, at least have the decency to recognize the difference between 'programming' and 'scripting'.

      Scripting can be a step in the right direction, but for the most part people get stuck there because they can make a living.

    86. Re:Go with the flow by tekiegreg · · Score: 1

      Excellent point and amen to "keep reading", I'd like to add that (current) certifications are at least a good way to show you've read the latest and greatest out there and if you need to demonstrate this, go out and get some industry specific certs (I.E. Microsoft if you're a .NET programmer, Sun's certs if you're a Java programmer ,etc.). Though a cert is by no means a substitute for genuine programming knowledge.

      --
      ...in bed
    87. Re:Go with the flow by Anonymous Coward · · Score: 0

      And once again we see some extreme arrogance, bad presuppositions, and poor reading comprehension. You make several statements that assume I only do scripting and that I have never worked on real code. The sad fact is that the faulty logic you display in your comments is likely also reflected in your code. I will give you this though: you are extremely effective at trolling. I wouldn't normally respond twice to someone who makes the asinine assumptions that you do.

    88. Re:Go with the flow by LrdDimwit · · Score: 1

      What do you mean? As long as the one text editor he learns is EMACS, he should be fine.

      *duck*

    89. Re:Go with the flow by Free+the+Cowards · · Score: 1

      I started doing BASIC on a C-64 at age 6 or 7. Although I sucked really hard for a really long time after that.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    90. Re:Go with the flow by Anonymous Coward · · Score: 0

      If you have a few minutes to burn, you might also want to visit http://www.growingbettersoftware.com./ The full book is online as preview.

    91. Re:Go with the flow by Anonymous Coward · · Score: 0

      Boy what advice... LOL
              * Lots of GOTOs
                                      * Delete those annoying REM statements
                                      * Use weird, arcane variable names like 'ORGO' and 'FTOOMSH'

      Also make sure you use none of that compartmentalization crap. The programs will run all together so don't repeat don't try to break those big complex task into bit size chunks. That will only distort your value to your boss. Back in the older days (like at IBM) you got paid by the Lines of Code. So make sure you have as many LoCs as you can. This shows you are a hard worker... ;-)

    92. Re:Go with the flow by Anonymous Coward · · Score: 0

      * Use weird, arcane variable names like 'ORGO' and 'FTOOMSH'

      An UBER-OBSCURE Young Ones reference?! NICE!!

    93. Re:Go with the flow by Anrego · · Score: 1

      the last 3 years of support desk gives me the business sense

      ROFLMAO!

      That's probably not as insane as it sounds. Usually the guy's who really know the ins and outs of the software are the guy's who spend all day helping users get it working.

    94. Re:Go with the flow by 680x0 · · Score: 1

      be sure to keep a backup copy

      These days, we call that a version control system.

    95. Re:Go with the flow by khellendros1984 · · Score: 1

      I'd like to say that one of the reasons my manager hired me was specifically that I *didn't* have certifications. He tends to equate certification with people that can't get out and learn something on their own. Of course, maybe my boss is just a rare kind of guy...

      --
      It is pitch black. You are likely to be eaten by a grue.
    96. Re:Go with the flow by tekiegreg · · Score: 1

      Indeed a cert isn't the total picture of an employee. I certainly would look for other things. However to specifically exclude certs could mean a big loss of talent.

      --
      ...in bed
    97. Re:Go with the flow by jd · · Score: 1

      If the boss says "don't design", buy paper napkins and design during lunch. If the boss says "don't version control", take the work laptop home and version control to your own damn server. These things are not optional. If the boss says something stupid and things go wrong, guess what? The boss won't be the one taking the fall. Bosses know this, which is why they continue to say stupid things rather than learn better. The better software developers also know this, which is why they rapidly discover ways to bypass the pettiness of stupid bosses who don't see any reason to not be stupid.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    98. Re:Go with the flow by Anonymous Coward · · Score: 0

      The Pragmatic Programmer discusses all the practices you must master to excel as a developer.

    99. Re:Go with the flow by Anonymous Coward · · Score: 0

      Also there must always be a mysterious function called 'Foo()' somewhere. Put it in there as a closure and nobody will touch it for 20 years.

    100. Re:Go with the flow by namco · · Score: 1

      If you can write correct English, of course. If you don't, treat it like an essential coding discipline you have to learn

      If you can't write correct english, or aren't sure how to word it, use picture/symbol representation instead - as they say:

      A picture tells a thousand words

      Never, ever code when you're tired, you will break something.

      There are times you may have to, and, if you do, a second (fresh) set of eyes is always handy!

    101. Re:Go with the flow by DigitalLogic · · Score: 1

      That was a wasteful and non-productive comment.

    102. Re:Go with the flow by Anonymous Coward · · Score: 0

      Auntie flo making a visit?

    103. Re:Go with the flow by mindstrm · · Score: 1

      I find Cunt worse.... dunno why.

    104. Re:Go with the flow by Simon80 · · Score: 1

      For crying out loud, doesn't everyone use version control yet? when done right, it provides a clear record of the development history in addition to being a backup.

    105. Re:Go with the flow by jacquesm · · Score: 0

      Who knows, maybe if I can troll you I can also code.

      Fact is:

      - you've already admitted to not being able to understand code written by people with more experience than you
      - you've so far only stated that you write some scripts, if it was more than that I'm sure you would have used that to bolster your argument
      - you conveniently hide behind your anonymous shield so any claims you make can not be debunked, whereas I'm quite visible to you
      - you seem to have quite an ego to want to debate your presumed skills but you fail to back them up with any example, or even your identity

      So, in short you're probably just another wannabe coder that can't handle the fact that it's a lot more complicated than you thought it was and you take that out on others.

      You seem to think that coding for 2 years in a bunch of scripting languages makes you a programmer, even after a lifetime in everything from several kinds of assembler, more high level languages than I care to enumerate I still know for a fact that there is more that I don't know than that I do, and it certainly isn't for lack of trying.

      On a regular basis I get hired to untangle the mess from what I from today forward will call 'helpdesk programmers' and I strongly suspect that you know exactly what I mean when I say that because you respond so violently to it.

      Get a userid if you feel like being taken seriously and let's have a look at your 'real code' then, you show me yours, I'll show you mine.

      until then, stfu mr. anonymous

      j.

    106. Re:Go with the flow by Anonymous Coward · · Score: 0

      Because if you look around, there are several different meanings and connotations for words like dick, cock and ass, but there is only one meaning for the word 'cunt' and 99% of the time, it is derogatory.

      Except in Australia, where 'ya big cunt' is almost a term of endearment between two males, or it can be used as part of a greeting. 'Owyergoin Ollie, ya big cunt!' Even there, it is being used with the Australians reverse insult idiom, which is basically where people who know each other well enough can say things like that to each other, but if a stranger tried it he would probably get beaten up.

      Most of the time though, the word is derogatory and I would challenge people to find an alternative meaning for it other than 'female genitalia'.

    107. Re:Go with the flow by Anonymous Coward · · Score: 0

      I've some db questions to ask... kindly post your e-mail in this thread.

    108. Re:Go with the flow by Nefarious+Wheel · · Score: 1

      The most effective expletives always start with a hard consonant. Think about it.

      --
      Do not mock my vision of impractical footwear
    109. Re:Go with the flow by Nefarious+Wheel · · Score: 1

      What I do is this: First, I write pseudocode. I indent it properly. Next, I turn the pseudocode into comments. Finally, under each pseudocode-generated comment, I will write the actual code to support it. You might also consider these as a good place to break out a function/method from the main programming logic.

      Oh baby, talk to me dirty some more -- the secret is finally out.

      That is some seriously good advice, go with it.

      --
      Do not mock my vision of impractical footwear
    110. Re:Go with the flow by ZFox · · Score: 1

      It's worse because I get slapped anytime I call a woman that. Somewhat Pavlovian I guess.

    111. Re:Go with the flow by Anonymous Coward · · Score: 0

      @Nefarious Wheel:
      I just wanted to thank you for your post.
      Slashdot is a community full of information but often lacking in wisdom.
      You can imagine my surprise in seeing a comment full of both.

      I'm saving your post. Thank you. :)

    112. Re:Go with the flow by jgrahn · · Score: 1

      Backup your work area

      So you mean you do not place your sources in revision control? If your disk crashes and you lose more than a few hours' worth of work, you are doing something wrong.

      (Or the positive version of this message: congratulations! You can go out and pick any of dozens of free tools for revision control, understand what it's all about, and it will take away many of your daily worries.)

    113. Re:Go with the flow by Nefarious+Wheel · · Score: 1

      More generally, I'd warn against being too concerned with "bloat" coming from libraries unless you are specifically targeting resource-constrained environments.

      You're right about the sort functions, this was just from an example I remember from the dot-boom.

      And I do not wish to offend, and I seriously do not want to position myself as a troll, but isn't this the sort of attitude, accumulated, that resulted in Vista?

      --
      Do not mock my vision of impractical footwear
    114. Re:Go with the flow by Logic+and+Reason · · Score: 1

      ...isn't this the sort of attitude, accumulated, that resulted in Vista?

      I don't know much about Vista, but I don't think the suckiness of Microsoft's products comes from their coders using too many external libraries. If anything, I'd expect just the opposite due to NIH syndrome.

      Remember, including KitchenSinkLib in your project doesn't mean you actually have to use all of its functionality. It just means your program's binary will grow somewhat; and given how little of our hard disks and RAM are taken up by binaries themselves these days, it's a pretty minor concern in my opinion. How minor obviously depends on the circumstances, but I'd contend that it's better to err on the side of code re-use than on the side of small binaries.

  2. Goto is good by corsec67 · · Score: 4, Funny

    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
    1. Re:Goto is good by bigstrat2003 · · Score: 5, Insightful

      Hey, I like the ? : construct. You leave it alone!!!

      --
      "16MB (fuck off, MiB fascists)" - The Mighty Buzzard
    2. Re:Goto is good by Rinisari · · Score: 3, Insightful

      ?: ternary is fantastic for short clauses, such as $foo = isset($_GET['id']) ? sanitize($_GET['id']) : 0;.

      The logical sequence for this is a and b or c, or isset($_GET['id']) && sanitize($_GET['id']) || 0;, but ignore the PHP 'cause PHP won't handle it this way (it'll put a boolean in $foo).

    3. Re:Goto is good by Walpurgiss · · Score: 1

      The only time I liked ? : was in school. It made my source look elite.

      Of course, it didn't matter very much since half of the class didn't turn in working source code anyway, and couldn't figure out how to use scp or ssh, and coded their homework on windows before compiling in the lab with g++.

      I consider it the school's fault that no one knew how to use even basic linux/unix commands, since for the first undergrad C++ class they used textpad + MiniGW port of g++ to code and compile.

    4. Re:Goto is good by TheRealMindChild · · Score: 5, Funny

      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
    5. Re:Goto is good by TheSpoom · · Score: 1

      I generally only use ternary when I'm outputting or concatenating something and it's a very simple test... otherwise, it's effectively an if (as in the example you posted), and can be more clearly expressed as such. Humans generally think "if x, than y, else z", not "var = (if x, than y, else z)".

      --
      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
    6. Re:Goto is good by mudetroit · · Score: 3, Insightful

      This is one of the times when the saying "there is more than one way to skin a cat" comes to mind.

      I work in a shop that has a solid rule of not commenting anything. It carries another hard rule along with it. We write very explicit method, field, parameter, and test names. If the code is in someway not understandable for you than stop and rewrite it so that it is clear.

      Comments are a nice concept, but in practice they are rarely kept current. And amazingly enough are rarely correct immediately after they are written.

      Sometimes there might be a better way to do things.

    7. Re:Goto is good by Anonymous+Brave+Guy · · Score: 1

      The main difference between the ternary ?: operator and an if block is that one creates a condition expression while the other creates a conditional statement. There are significant advantages to each in a typical programming language that provides both, but they are certainly not equivalent.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    8. Re:Goto is good by SQLGuru · · Score: 0

      Humans generally think "if x, than y, else z", not "var = (if x, than y, else z)".

      Humans that have decent English skills usually think "if x, THEN y".....and I'll give you no slack because as a programmer, that should be drilled into you during your BASIC, PASCAL, PL/SQL, etc. days.

      Layne

    9. Re:Goto is good by Z34107 · · Score: 0

      Goto actually is good, for some cases.

      We were given a lab assignment were we were practically forced to use it - a user can draw a picture, and you have to write the code to allow you to fill in a closed (or not so closed) shape. You know, the paint bucket tool in pbrush - you click in the region is filled with a solid color.

      There's a nice recursive algorithm - something like fill(x, y). Return if (x,y) is filled or a boundary color, else do fill(x+1,y), fill (x, y+1), fill(x-1, y), fill(x, y-1). Or something like that, I'd have to look at my notes, or maybe think about it for a minute or so. But, the idea is that you recursively fill outwards from where the user clicked and fill every point.

      Except, that such an algorithm would blow the stack. Even a tiny region on the screen has thousands of pixels - can your compiler handle thousands of layers of function calls? The solution was to code your own stack structure for saving the state of the function, and gotos were really handy for simulating "function calls."

      --
      DATABASE WOW WOW
    10. Re:Goto is good by actionbastard · · Score: 2, Funny

      Calculon: What? Have you got an extra 'GOTO 10" line? Look. I'm programmed to be very busy. If you can't heat water to 212 degress, I'm not interested!

      --
      Sig this!
    11. Re:Goto is good by Anonymous Coward · · Score: 0

      Having an expression and a statement is more for an academic point of view than real practical use. I guess it's like saying that one of the major fault of C is to have no procedure and only void functions. It doesn't change anything except for the purist.

    12. Re:Goto is good by Pulzar · · Score: 1

      Except, that such an algorithm would blow the stack. Even a tiny region on the screen has thousands of pixels - can your compiler handle thousands of layers of function calls?

      That's a troll, right?

      --
      Never underestimate the bandwidth of a 747 filled with CD-ROMs.
    13. Re:Goto is good by Anonymous Coward · · Score: 0

      if (light_on_in_next_office)
      assessment_of_boss = "Really driving the organization";
      else
      assessment_of_boss = "What a frickin' bozo!"

      That's OK, but

      assessment_of_boss = (light_on_in_next_office ?
      "Really driving the organization" : "What a frickin' bozo!");

      is more concise.

    14. Re:Goto is good by Spy+der+Mann · · Score: 1

      My rule is: Only use ? : for simple variable and string assignment. And in the very few cases that have operators in them, ALWAYS use parentheses.

    15. Re:Goto is good by shock1970 · · Score: 1

      Java's solution to goto: Make it a reserved word that has no functionality so that it can't even appear in a program.

    16. Re:Goto is good by Anonymous+Brave+Guy · · Score: 1

      Having an expression and a statement is more for an academic point of view than real practical use.

      Nonsense. Moving towards a more declarative programming style is an effective way to reduce programmer errors and improve code readability. That includes initialising data using expressions and, ideally, marking it immutable, rather than starting with uninitialised variables and then setting their values via assignment statements. If your “variables” can't, then it's always easy to work out where each value came from, and you can never forget to initialise a variable, accidentally change its value, or reuse it for a different purpose later.

      Even in primarily imperative programming languages, which mostly aren't as expressive in this respect as their functional counterparts, you can follow the basic principle most of the time with minimal effort. Try it: your code will almost certainly wind up less buggy and easier to maintain.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    17. Re:Goto is good by Kingrames · · Score: 1

      Yes, it's especially useful in php switches, when using a string case comparison.

      --
      If you can read this, I forgot to post anonymously.
    18. Re:Goto is good by Anonymous Coward · · Score: 0

      Even though the parent is trolling he does have a point. Joke or not, GP is probably an inexperienced developer. I mean all he left out is a comment about how you should never use a single global variable.

    19. Re:Goto is good by Anonymous Coward · · Score: 0

      Anyone who think the goto is bad, is a moron who never read, or didn't understand, Dijkstra's paper.

    20. Re:Goto is good by ambulatorybird · · Score: 1

      I was under the impression that gotos are actually the best way to express certain types of computations, such as finite state machines. (Mutually recursive functions would be better, but most language implementations don't optimize tail-calls.)

    21. Re:Goto is good by jaminJay · · Score: 2, Insightful

      Judicious use can make code clearer. As Mum always says, everything in moderation. (That is where the emphasis is, right?)

      --
      Leela: "Is all the work done by children?" Alien: "No, not the whipping."
    22. Re:Goto is good by Anonymous Coward · · Score: 0

      Humans generally think "if x, than y, else z", not "var = (if x, than y, else z)".

      Those of us who actually code for a living don't always "read code in English". The ternary operator is very very handy, and generally makes more sense to read than the equivalent if/else statement.

      It bothers me when coders insult those who use things like ternary, just because their own mind somehow can't wrap around how to use it. The people who don't like ternary are often the same people who couldn't write a regex to save their life. Who are the same people who wrap every statement with tons of parentheses because they can't be bothered to memorize order of precedence.

      Honestly, if you can't handle the ternary operator, I don't ever want to have to look at code you've written. Ever.

    23. Re:Goto is good by Anonymous Coward · · Score: 1, Insightful

      [snip]...Please please please, leave comments so others can figure out what the fuck your logic was...[snip]

      Just elaborating on that - write comments that explain _why_ you're doing something not _how_ you did it.

      It's much more useful to see why someone did a bit of code in a particular way than it is to have an explanation of what the next 10 lines mean. Programmers can work the latter out if they need to.

    24. Re:Goto is good by nodonn · · Score: 1

      Nope ... It's the kind of solution you get when the developer has more time available and wants the code to consume a different resource; more Heap than Stack. It is slower because you are managing your own container in the Heap and not leveraging the PUSH/POP of registers, but this is outweighted by the massive advantage of being able to consume as much Heap memory as the OS will give it. It will aslo make the code more compatiable / portable to run in different modes; everything from 8bit EPROMs running in virtual memory to the latest 64bit OSs ... all you really have to do is port and compile without really having to answer the question of "Will the compile parameters be big enough? (stack size)".

    25. Re:Goto is good by kylben · · Score: 2, Interesting

      Wow. So.. you guys don't write comments because you guys sucked at writing them and keeping them up to date. Is that a fair assessment? Comments are wonderful if used properly, but as you point out, too few use them effectively.

      There is a separate circle of hell for those who write:

      //increment foo
      foo++;

      Comments are best used to explain design principles, data models, constraints (if they aren't already coded in), and the purpose of long code blocks - high level concepts that aren't likely to change as the code gets debugged and added to, as well as any code that has to be written in an obscure way for performance. Procedural documentation is best done by the code itself with explicit variable, class, and function names and the like. Even a one-line function used only in one place can be worthwhile if the name explains what an otherwise impenetrable line is meant to do.

      Anybody who thinks they are going to maintain detailed procedural comments along with the code either works for the government or hasn't been writing code in a competitive business environment very long.

      --
      Insightful and funny are really the same thing, except one has a punch line.
    26. Re:Goto is good by Anonymous Coward · · Score: 0

      goto is not always bad and does not always lead to unmanageable code.

      I use them all the time but they are called:
      next;
      last;
      exit;

      Every programmer has to find the balance between harnessing the power and expressiveness of their tools and the importance of being understood by other humans.

      Here is my advice for a new programmer:
      1. Make one of your mantras "everyone is a master". Listen to everything everyone has to say, glean what you can.
      2. Make your other mantra "everyone is a fraud". Be ready to throw out everything everyone tells you and especially your own beliefs.
      3. Dont trust other peoples' account of whats going on- check for yourself, see how it works.
      4. Read the Effing M.
      5. Believe in technical osmosis; physically surround yourself with clever people; Sit next to a sysadmin. Go to lunch with other programmers
      6. Just keep writing code- pick a project and start writing and when you find some other app that already does the job, just finish your app anyway.
      7. Let go; submit yourself to the process.

    27. Re:Goto is good by Rei · · Score: 5, Insightful

      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.
    28. Re:Goto is good by try_anything · · Score: 1

      I found myself using the ternary operator in a proof for a set theory class. It saved me so much verbiage that I retained it when I presented the proof to the class. I just explained what it meant and used it -- no one was the slightest bit confused despite never having seen it before. I remember seeing it used a few times by other people later in the semester, even though their only exposure to it was my fifteen minutes at the chalkboard. So it isn't that counterintuitive, at least not to logic-oriented people like programmers and mathematicians.

      And anyone should feel free to use IN CODE something that makes sense to programmers, regardless of whether it makes sense to "normal" human beings. The bad reputation of :? is entirely due to the confusion caused when a programmer fails to realize it's an operator -- a mistake he will only make once, at most, in his entire career.

    29. Re:Goto is good by MikeBabcock · · Score: 1

      Just wait till they see you using map and lambda functional expressions. Personally I love list comprehensions in Python:

      taxes = [ tax_calc(item) for item in items ]

      Throw in something like:
      taxed_items = zip(items, taxes)

      for fun.

      --
      - Michael T. Babcock (Yes, I blog)
    30. Re:Goto is good by ari_j · · Score: 1

      Someone should mod you down for posting a link to an xkcd image, depriving us of the alt text. Granted, that one wasn't the best, but it's still as much a part of the comic as Jon is part of Garfield.

    31. Re:Goto is good by poopdeville · · Score: 2, Interesting

      It also makes a nice case statement structure in languages that don't support it -- Perl, for example. Something like:

      $self->is_foo ? $self->do_foo :
      $self->is_bar ? $self->do_bar :
                      warn("No match in blah blah blah");

      --
      After all, I am strangely colored.
    32. Re:Goto is good by Anonymous Coward · · Score: 0

      you = (I_use_that()? "Insensitive clod" : "Funny");

    33. Re:Goto is good by tshak · · Score: 1

      Exactly.

      If you have to write "what" comments, then refactor your code so that it more clearly describes its intent. When I see code that is heavily commented (and this is usually from those that brag to do so), I see code that is not clearly written in the first place. Additionally, you always have the risk of code and comments being out of sync, making the comments worse than useless. The best use of comments is when the purpose of clearly written code may still be unclear. That is, we can clearly see "what" the code is doing, but not "why". This is what makes comments useful. However, this situation should be relatively rare.

      --

      There is no longer anything that can be done with computers that is nontrivial and clearly legal. -- Paul Phillips
    34. Re:Goto is good by Profane+MuthaFucka · · Score: 1

      Fuck no. Don't code a state machine as a shitload of gotos.

      If you're object oriented, use a state pattern. If you're functional, your new state function is the return value of the old state function.

      If you're going to use gotos to implement states, please use an obfuscator on your code to make it easier to read. Seriously. State machines are so fucking horrible when coded using gotos that an obfuscator makes that shit EASIER to read. It's the only known exception to the second law of thermodynamics.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    35. Re:Goto is good by Max+Littlemore · · Score: 1

      I'd like to point out that if you don't understand the ? : op, you shouldn't be programming in a language that uses it. It is an elegant and perfectly valid way of expressing an idea.

      Seriously, what is so hard to read about it? I find it amazing that people who can handle complex programming tasks can't somehow figure out how to replace the ":" character with the word "otherwise". If you understand the word otherwise you've got it, otherwise piss off.

      Or:

      you = (vocab.contains(otherwise)) ? worthy : unworthy;

      --
      I don't therefore I'm not.
    36. Re:Goto is good by Your.Master · · Score: 1

      The body of the Universe's well-written code has a place for goto. It just doesn't have very many such places, and as a beginning programmer, it's excellent training to assume that goto should not be used, and then use it only if the alternative you come up with is barbaric.

    37. Re:Goto is good by dubl-u · · Score: 3, Insightful

      I want to make one point. *any* code is unmanageable if you don't comment

      I disagree strongly. I think the important thing is to make your code easy to understand. Comments should be a last resort.

      As an analogy, consider your MP3 player. Suppose that every time they struggled with a UI decision, they just decided to put something in a manual or on a sticker on the back. It would be an abomination. The right approach is to make it so that as much as possible, instructions aren't necessary.

      When I'm coding, I'll first try to put information in names, like variable and method names. Next I'll try to extract methods or objects, so as to minimize complexity. Then I'll worry about interface and object names. And I put a lot of information in readable unit tests, as that's a kind of documentation that the computer can verify still is valid. Documentation is always a last resort.

      I have to deal with a lot of other people's code, and I'll always take beautifully polished code with no docs over mediocre code with lots of docs.

    38. Re:Goto is good by enjo13 · · Score: 2, Insightful

      Disagree...

      Commenting should be reserved only for especially complex algorithms (describe the algorithm itself) and class level descriptions (what the class or module does). Decipherable code has much more to do with good variable naming, good indentation habits, and consistent well thought out use of flow control structures.

      I can't count how many times I've been tripped up by a 'helpful' comment that had been left when code was refactored or changed over time. Dangling comments are a real problem. It's one thing to have to actually read the code (a skill good programmers universally have) and another to have a comment tell you one thing and then have to grok that the code is actually doing something quite different.

      --
      Turn s60 photos into awesome videos with mScrapbook for all S60 3rd edition phones!
    39. Re:Goto is good by Anonymous Coward · · Score: 0

      Don't forget to make sure you invent everything in house. Never make use of previously written code - it may have undiscovered bugs.

      It's a lot faster to re-architect and re-write code from scratch instead of fixing the bugs. Plus, your new code will be bug free now that you know what bugs were in the old code and can avoid them.

      Learn an old tried and true language. Basic, ALGOL and APL have been around a long time for good reasons. Champion their use tirelessly for all your and your teams projects instead of those flash-in-the-pan languages like Java or C++. Your team members will thank you for helping them to see the light.

    40. Re:Goto is good by ImustDIE · · Score: 1

      I'm definitely in favor of self-documenting code, but no matter how well you try to do it, it is never going to be as easy to read as a well written comment.

      While '// increment x' is definitely overkill, I like to comment my code in such a way that you can easily skim over just the comments to get to the piece of code you are looking for. Usually this takes the form of coding in paragraphs with a comment above each paragraph describing what it does. Each comment has a line of whitespace (or a single bracket) above it to separate the paragraphs and make the comments stand out.

    41. Re:Goto is good by Nefarious+Wheel · · Score: 1

      I was under the impression that gotos are actually the best way to express certain types of computation

      I would think that code that executes the pyro charge of an ejection seat would be a good target for a goto.

      Provided the "jettison canopy" code was executed first, of course...

      --
      Do not mock my vision of impractical footwear
    42. Re:Goto is good by Amazing+Quantum+Man · · Score: 1

      Yep they "why". Though sometimes they overlap. I once wrote a comment that took up about 3/4 of a printed page.

      I was doing some nasty 14-bit scaled fixed point trig work, and I didn't want to lose any precision due to multiplication, so I converted the sin/cos multiplications to angle additions.

      The 3/4 page comment was the mathematical description of what I was doing (the what) along with the rationale for doing so (the "why").

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    43. Re:Goto is good by Amazing+Quantum+Man · · Score: 1

      There are places in C where I can see a goto.

      for (i = 0 ; i &lt; something; ++i) {
        for (j = 0 ; j &lt; something_else; ++j) {
        do_something;
        if (disaster)
            goto bailout;
        }
      }
      bailout:

      However, in C++, you can use exceptions to clean up gracefully.

       

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    44. Re:Goto is good by Z34107 · · Score: 2, Interesting

      That's a troll, right?

      You're fucking kidding, right?

      Open your favorite C or C++ compiler. Write the following function:

      void blowthestack(int i) {

      printf("%i", ++i);

      blowthestack(i);

      }

      Tell me what number you get to.

      Stack is very, very finite. And, by the default settings in most compilers, very, very small. Visual Studio 2008's default settings made it to 4713; YMMV.

      --
      DATABASE WOW WOW
    45. Re:Goto is good by dcam · · Score: 1

      I largely agree however, comments can be really handy in a number cases:
      - Units (eg time in seconds, milliseconds or minutes)
      - explaining why this is done this way
      - highlighting debugging code that was left in (possibly commented out)
      - explaining something that might appear odd at first glance

      --
      meh
    46. Re:Goto is good by bboxman · · Score: 1

      The ternary op is often more readable than an if, if used correctly. (this almost always holds true if the condition in question affects a single assignment, and if the assignment itself is a relatively simple one (i.e. a = (cond) ? b : c)) -- Ben, whose code is riddled with ternary ops, but seldom a goto.

    47. Re:Goto is good by Almahtar · · Score: 4, Interesting
      I'm pretty much in agreement. The compiler can't check your comments: It's explicitly told to ignore them.

      While it's a ridiculous example, someone could easily change

      std::string mkdec(std::string x) // Converts x, a string representing a hexidecimal number, to a decimal string.

      To

      std::string mkdec(std::string x) // Do a little dance, make a little love, get down tonight

      And everything would still compile just fine, but all of a sudden new devs on the project are left in the dark as to what mkdec() does without reading through its code. If someone named the function convert_hex_string_to_decimal_string something cryptic or incorrect it would appear in many places (everywhere the function was used) and be much more noticeable and likely get fixed sooner.
      Another fun one I've seen in legacy codebases a lot is

      //Only used in this place or that place, or for this or that purpose.
      int some_func() { blah }

      ... and that comment was written 5 years ago and is completely wrong. People used doxygen or intellisense or whatever and saw that this function exists and takes the input/output they want but never saw that comment so they used it in 1000 other places.
      Or another fun one.

      /* function foo()
      does this, that, and another thing.
      ... big long description of inputs, outputs, constants that affect it, whatever ...
      */
      void foo() {blah }

      ... and the description is horribly out of date because it's been changed a million times.

      I'll say it again: the compiler can't check your comments, and it's just too easy to change some code that will make a comment wrong and not realize it. So comments have their place but their use should be judicious.

      "Self documenting code" (good variable and function names, etc) that the compiler can verify for you are preferable.

    48. Re:Goto is good by TheSpoom · · Score: 1

      I actually went on a small quest before I posted to find out whether or not I was gramatically correct there, and then just (as you said) defaulted to my horrid BASIC thinking. Alas.

      --
      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
    49. Re:Goto is good by TheSpoom · · Score: 1

      Humans generally think "if x, than y, else z", not "var = (if x, than y, else z)".

      Those of us who actually code for a living don't always "read code in English".

      So people like me, then?

      Personally, I like code that's readable and doesn't require extra effort to process. It saves me time in the long run. If you like to write code that's more difficult entirely so you can try to appear "smarter" than the rest of us, good for you.

      --
      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
    50. Re:Goto is good by pjt33 · · Score: 1

      If the code is in someway not understandable for you than stop and rewrite it so that it is clear.

      Proof of correctness? Warning maintainers that although there's a simpler, algebraically equivalent, way of writing the expression it overflows or has worse numeric properties (accuracy / stability)?

    51. Re:Goto is good by Anonymous Coward · · Score: 0

      And how is that different than an evil anonymous macro?
      Its not clever and its been responsible for many misunderstandings in python code.

    52. Re:Goto is good by Eivind · · Score: 1

      It's okay in trivial cases. can_drink = (age>18) ? True : False

      But using it in anything complex should be a capital offence.

    53. Re:Goto is good by TheSpoom · · Score: 1

      Also, I just realized what you were saying. Cancel that, I'm an idiot. Or at least tired. ;^)

      --
      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
    54. Re:Goto is good by TheSpoom · · Score: 1

      More concise is not always better.

      --
      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
    55. Re:Goto is good by Anonymous Coward · · Score: 0

      I was doing some nasty 14-bit scaled fixed point trig work, and I didn't want to lose any precision due to multiplication, so I converted the sin/cos multiplications to angle additions.

      So, why'd you spend 3/4 of a page describing what you just wrote in a single line here?

    56. Re:Goto is good by PinkyDead · · Score: 1

      Useful, but if he's getting into progamming, he's also going to have to know http://xkcd.com/303/

      Soon he will have the foo of the xkcd master.

      --
      Genesis 1:32 And God typed :wq!
    57. Re:Goto is good by harry666t · · Score: 1

      Goto might also be useful for error handling:

        status = do_something(foo);
        if (status == ERROR)
          goto error_handle;
        do_something_else(status, foo);
        //...
      error_handle:
        undo_something(foo);

      It can be a nice replacement for try/catch in C, and could actually lead to cleaner code IMO (separation of normal code and error handling).

    58. Re:Goto is good by mjjw · · Score: 1

      The logical sequence for this is a and b or c

      No it isn't a?false:true should return false when a is true but by your logic it would return true.

      --
      If you aren't far left by the age of 18 you have no heart. If you aren't far right by 30 you have no brain.
    59. Re:Goto is good by javaxjb · · Score: 1

      Who are the same people who wrap every statement with tons of parentheses because they can't be bothered to memorize order of precedence.

      I understand precedence perfectly well, but I use parentheses because too many programmers don't. It's not that unusual overhear someone complaining that a rather complex condition isn't working, at which point I butt in and ask if they're sure they have the precedence right, followed almost immediately by, "The what?" Then a quick tutorial, "'False' is 0, 'true' is 1, 'and' is multiplication, 'or' is addition (where overflow counts as 1). Follow standard algebraic precedence. Now that you understand, put parentheses around it to make it immediately clear to anyone."

      Of course, there's nothing like learning APL very early on to make one very fond of parentheses.

      --
      Programmers in mirror are brighter than they appear
    60. Re:Goto is good by pbhj · · Score: 1

      Wow. So.. you guys don't write comments [...]

      There is a separate circle of hell for those who write:

      //increment foo

      foo++;

      That's why I always write
      //add one to integer variable foo
      foo := foo + 1
      // foo is now 1 larger

      Paid by the character you say, why how did you know?

    61. Re:Goto is good by Kvasio · · Score: 1

      this is a perfect example where you should not use GOTO.
      Have you heard about break() ?

    62. Re:Goto is good by Anonymous Coward · · Score: 0

      --- stack.c.zealoussniper 2008-09-26 22:31:09.000000000 +1200
      +++ stack.c 2008-09-26 22:29:08.000000000 +1200
      @@ -1,7 +1,7 @@
      #include <stdio.h>

      void blowthestack(int i) {
      - printf("%i", ++i);
      + printf("%i\n", ++i);
      blowthestack(i);
      }

      fnord$ uname -a
      Darwin Fnords-mac-mini.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 fnord$ ./stack | tail -2
      261632
      261fnord$

    63. Re:Goto is good by Tarwn · · Score: 1

      I'm left wondering what kind of companies you guys work for that you believe complexity only comes in algorithmic flavor.

      I provide comments for the following:
      Class level - this is the general idea of the class as a comment so you don't have to grok the entire chunk of code at once
      Method level - this is either for doc builders or like the class level, to get a general idea of how something works without reading the next 500 lines
      Complexity - Whether it is algorithmic complexity, business rule complexity, whatever - if it is not immediately obvious _WHY_ I am doing something, it gets a comment

      So far most of these comments have been along the lines of "I don't comment because I make readable self-documenting code". Great, but when I come back in two years to maintain your code and I am trying to figure out why you did something a certain way - a comment with a little information on your intent or why you programmed your logic in that manner goes a long way

      Self documenting names are great, but assuming that you don't also need commenting because of your naming technique is a bad assumption to make. The fact that code changes are done without accompanying comment changes does not invalidate the usefulness of comments, it invalidates the level of work you think your doing.

      --
      Whee signature.
    64. Re:Goto is good by moonbender · · Score: 1

      It's okay in trivial cases. can_drink = (age>18) ? True : False

      But using it in anything complex should be a capital offence.

      Eh? can_drink = age>18 No ternary operator necessary.

      --
      Switch back to Slashdot's D1 system.
    65. Re:Goto is good by confused+one · · Score: 1

      Dude, in the event of an if (disaster) you should always throw (OMFG)

    66. Re:Goto is good by Nurgled · · Score: 1

      I think this isset($something) ? $something : NULL idiom is probably the only thing I ever really used ? : for, in PHP. I'm told that they've now added an operator or something else that can do this idiom a lot more tersely, which is nice. I don't really write much PHP anymore.

    67. Re:Goto is good by Anonymous Coward · · Score: 0

      Use "self-commenting" code and you've solved the majority of your commenting woes. You won't need to explain what each variable represents and the flow of logic is much easier to understand. Plus, not many people enjoy going back to their finished code to add comments.

      An example of what I mean would be this (sorry if the objective-c syntax throws you off, it's what I personally use the most). The code is supposed to take two strings and combine a first and last name into one string.

      Non-commenting:
      -(NSString*)combine:(NSString*)a with:(NSString*)b
      {
                  return [NSString stringWithFormat:@"%@ %@", a, b];
      }

      self-commenting:
      -(NSString*)fullNameWithFirstName:(NSString*)aFirstName lastName:(NSString*)aLastName
      {
                return [NSString stringWithFormat:@"%@ %@", aFirstName, aLastName];
      }

      See the difference there? It's one small example but doing so throughout your code solves you so many problems. If you're worried about how much typing you're gonna have to do, relax; most modern IDEs have some sort of auto-complete capability.

    68. Re:Goto is good by Ambiguous+Puzuma · · Score: 1

      With any decent optimizing compiler it shouldn't terminate. Try it with "gcc -O2", or more specifically, "gcc -foptimize-sibling-calls".

      As for the flood fill lab assignment, there are methods that do not require recursion or the use of "goto".

    69. Re:Goto is good by Anonymous Coward · · Score: 0

      Or you might just test to make sure that you have covered against overflows and instability, and that it meets the projects goals in terms of accuracy.

      Trust me, the project I am currently working on has a lot of fun large complex equation. You can't avoid them, but you can write them to be as clear as they can possibly be even without comments.

    70. Re:Goto is good by jeremyp · · Score: 1

      Then you're doing it wrong.

      Sure, you can read the code to find out what it does, but you also need to know what the programmer intended that the code should do - the two do not necessarily coincide.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    71. Re:Goto is good by Angostura · · Score: 1

      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....

      No, sorry it doesn't. If you are familar with the language it may, but if you are new to the language the former is quite a bit clearer. Remember someone might be trying to examine your code in 50 years time

    72. Re:Goto is good by Mr.+Underbridge · · Score: 1

      I know you're kidding, but I want to make one point. *any* code is unmanageable if you don't comment - especially java if you use lots of objects and polymorphism. Please please please, leave comments so others can figure out what the fuck your logic was without diagramming logic on a whiteboard for 3 days...

      Yep. And in case altruism isn't your thing, just remember that with all the code you'll be writing, "others" in the parent's statement can be replaced by "you in 6 months". I - as well as probably everyone here - have cursed some damned rat's nest of code only to discover I wrote it. More than once.

      Not only is commenting important, though, but use clear design. I took over a project where the previous guy loved layers of abstraction - think about taking multiple class member functions, getting pointers to them, then passing those function pointers into a non-class standalone function. The only way you can trace that back is with grep, and three days with a whiteboard like parent mentioned. Don't do that.

    73. Re:Goto is good by admdrew · · Score: 2, Informative

      In Perl there are modules for everything.

    74. Re:Goto is good by Da+Fokka · · Score: 1

      That not what she said to me.

    75. Re:Goto is good by TheRaven64 · · Score: 1

      Self documenting code means that it should be apparent from the code how something is being done. If you need comments to tell you how the code works, then the code is usually bad (sometime you need to write bad code for speed, but it's quite rare). Comments, on the other hand, are to tell you why something is being done. Just because you don't know how to write good comments doesn't mean that comments are bad.

      --
      I am TheRaven on Soylent News
    76. Re:Goto is good by TheRaven64 · · Score: 1

      If you're using a (real) object oriented language, which supports a become operation then you can code very clean state machines by having a separate class for each state and changing the object's class in each method that involves a state transition. In Objective-C you'd do this by setting the isa pointer, in JavaScript or Self you'd do it by setting the object's prototype.

      --
      I am TheRaven on Soylent News
    77. Re:Goto is good by TheRaven64 · · Score: 1

      Any relatively modern C compiler (Visual studio may not count, Sun's compiler, GCC and LLVM do) does tail call elimination, so in this case you will not get a new stack frame for each call to blowthestack(). If you have any stack-like data structures then you will get faster (and more readable) code with a recursive implementation - which will use hardware push and pop operations which are aliased with hidden registers on x86, or more register windows on something like SPARC - than with an iterative implementation, which will use load and store instructions with indirect addressing.

      --
      I am TheRaven on Soylent News
    78. Re:Goto is good by pbhj · · Score: 1

      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.

      Are you sure it's not a grue?

    79. Re:Goto is good by Mongoose+Disciple · · Score: 3, Insightful

      I agree that as developers we should strive to write good, self-describing code that doesn't need comments.

      Yet I still tend to write a lot of comments.

      Well-written code can convey most of the how of what you're doing, but it rarely can convey the why -- and that's important too.

      Suppose I look at code someone else (or even myself) wrote two years ago. I see what I think is an error in how the logic applies one of the business rules.

      Is it an error?

      Or was it right, and the business rule has changed?

      Or is it still right, and there's some reason for the way it is that I don't understand?

      Did someone in management mandate a change that runs contrary to the last version of the design docs? Was a more obvious solution tried first, but found to fail under testing?

      All of these things are useful to know, and as much as I'm in favor of self-describing code, it rarely can communicate them.

    80. Re:Goto is good by aztracker1 · · Score: 1

      I happen to like shortcuts like the tirnary operators... the ifnull ?? in C#, and using && or || as shortcut operators in JS..

      setting.value = (input && input.value) || default;

      --
      Michael J. Ryan - tracker1.info
    81. Re:Goto is good by CrazedSanity · · Score: 1

      Commenting code is good, as long as the comments are useful. If your comments are misleading, then their presence is much more damaging than if they hadn't been there at all. I used to comment all my code, even if the code's purpose was very obvious, then I got bitten by it:

      I coded something a long time ago that needed to be fixed. I looked at the comments around where the problem occurred, and made a minor fix. Later, it seemed the bug had mutated into a different form, and it all went back to the afore-mentioned block of code I'd fixed. I read the comments and fixed accordingly... which completely broke the system. When I had made the first fix, I didn't update the comment to explain the updated functionality, so the comment was completely misleading.

      This goes along with "naming conventions." I put this in quotes because it can be more than just the code. For instance, if the front end changed "todos" into "tasks", make sure the code IMMEDIATELY uses the new term and drops the old one altogether. Seems simple, but this seemingly simple thing can avoid potential psychological breaks later.

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    82. Re:Goto is good by CrazedSanity · · Score: 1

      AMEN! Code that means exactly what it says is key to sanity. Consider:

      $UI->update_section('message_box', $myError);

      versus:

      ## Update the "message_box" part of the user interface with the error...
      $obj->$callMethod($tName, $data);

      The first one is pretty straight forward. The second one is so irritating to read that one is more likely to lead the reader into assuming that reading the comments is more important than reading the code (remember: assuming makes an @ss out of "u" and "ming"... and that's one pissed-of Chinaman, I'll tell ya).

      --
      Sanity is like a condom: rather have it and not need it, than need it and not have it.
    83. Re:Goto is good by Anonymous Coward · · Score: 0

      I like your sig.... Ker-Patty!

    84. Re:Goto is good by Amazing+Quantum+Man · · Score: 1

      And how do you plan to throw in C (either C90 or C99)?

      I *said* that in C++, you'd throw.

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    85. Re:Goto is good by Amazing+Quantum+Man · · Score: 2, Insightful

      Yes, and I wanted to break out of *BOTH* loops, not just the inner.

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    86. Re:Goto is good by Amazing+Quantum+Man · · Score: 1

      Because I put the math into the comment.

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    87. Re:Goto is good by Anonymous+Brave+Guy · · Score: 1

      I agree with you that using basic higher order functions can make things much cleaner, but FWIW I'm not a big fan of list comprehension syntax, in Python or otherwise. It tends to be horribly cumbersome. In simple cases, such as your example, a typical functional programming language would just write something like this:

      taxes = map tax_calc items

      with no repeated extra variable that doesn't actually do anything. For more complicated comprehensions, an explicit series of filter/map/reduce type steps seems clearer to me personally than forcing a hybrid into a new syntax for no particular benefit. In short, list comprehensions are syntactic sugar that don't actually make things any easier to read to my eyes. YMMV, of course, and obviously in languages that have comprehensions but not first class functions your choices are limited (and still better than writing out all the loop logic manually).

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    88. Re:Goto is good by Anonymous+Brave+Guy · · Score: 1

      No-one said anything about being smarter than you. Don't take things so personally.

      That said, you might like to consider that mathematical notation has diverged from natural language for practical reasons, and programming languages have a lot in common with mathematical notation.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    89. Re:Goto is good by Coryoth · · Score: 1

      Or another fun one.

      /* function foo()
      does this, that, and another thing. ... big long description of inputs, outputs, constants that affect it, whatever ...
      */
      void foo() {blah }

      ... and the description is horribly out of date because it's been changed a million times.

      One way to assist with these situations is to use something like JML, which gives you a more formal language to write your "does this, does that, constraints on inputs and outputs" comment wit the following bonuses: the formal comment gets included in the documentation; you can automatically generate unit tests from the formal comment, so tests will fail badly if the comment and code fall out of sync; you can use other tools (like ESC/Java2) to run automated checks that the rest of your code is using the function correctly (i.e. not assuming anything about inputs or outputs that can't be guaranteed by your formal comments). All up that's quite good gains for the tiny extra work of learning JML to write your comments in.

    90. Re:Goto is good by Anonymous Coward · · Score: 0

      I have NEVER found a case I could not program the gotos out of. I even fixed the gotos in GCC once but I got overridden.

    91. Re:Goto is good by ggvaidya · · Score: 1

      To say nothing of the gifts of on-going development (if they let you at Perl 5.10 at your workplace).

    92. Re:Goto is good by Free+the+Cowards · · Score: 1

      It's not a fair assessment. They don't write comments because, they believe, everybody sucks at writing them and keeping them up to date. While what you said is true it is woefully incomplete.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    93. Re:Goto is good by Just+Some+Guy · · Score: 1

      I actually prefer stuff like:

      // The Foo library likes to send hex strings without the
      // 0x prefix for some reason. Make sure we add it for
      // consistency with other data sources.
      hex = "0x" + number_str;
      return convert_hex_string_to_decimal_string(hex);

      --
      Dewey, what part of this looks like authorities should be involved?
    94. Re:Goto is good by 19thNervousBreakdown · · Score: 1

      stack.c++:
      ----------
        1 #include <iostream>
        2 #include <limits>
        3
        4 using namespace std;
        5
        6 void blowTheStack (int const i) {
        7   cout << i << "\r";
        8   if (i == numeric_limits<int>::max()) {
        9     return;
      10   }
      11   blowTheStack(i + 1);
      12 }
      13
      14 int main () {
      15   blowTheStack(0);
      16   return 0;
      17 }

      g++ -O0 -o stack.noopt stack.c++
      ./stack.noopt; echo $?
      523776Segmentation fault.
      139

      g++ -O2 -march=pentium3 -fomit-frame-pointer -o stack stack.c++
      ./stack; echo $?
      161515648 ... still going at the time of this post.

      Running now, will update to let you know if we return 0.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    95. Re:Goto is good by ckaminski · · Score: 1

      That has been my biggest stumbling block with Java, to get over the immutable aspect of so many classes (not just String). I'm used to doing

      obj.addSomething(a) versus

      obj2 = obj.addSomething(a).

      I think its good in the end, but I'm so used to it being the OTHER way, I trip up on it all the time. Need to undo 14 years of bad C++ practice, I guess.

    96. Re:Goto is good by iluvcapra · · Score: 1

      - Units (eg time in seconds, milliseconds or minutes)

      Honest question: Which would you prefer?

      Option 1

      launchEvent.time = 12.0; // minutes until launch, positive values indicate time *before* launch.

      Option 2

      setMinutesBeforeLaunch(&launchEvent,12.0);

      Option 3

      In units.h:

      typedef minutes double;

      In LaunchActions.h:

      void setPreLaunchTime(LaunchEventStruct *event, minutes time);

      --
      Don't blame me, I voted for Baltar.
    97. Re:Goto is good by Mia'cova · · Score: 1

      I'm more of a ?? fan myself.

    98. Re:Goto is good by Chirs · · Score: 1

      You joke about goto and "?:", but as a primarily linux kernel coder I use these all the time since they map directly to what the hardware does underneath. The kernel coding style tends to avoid many levels of indentation, so instead of

      if (foo) {
                    do something....
                    if (bar) {
                                      do something else
                    }
      }

      they would simply do

      if (!foo)
                    goto out;
      do something....
      if (!bar)
                    goto out;
      do something else...
      out:

      The advantage of this type of coding is that when you have a common "out" path you can handle all the unlocking in one place, making it easier to verify that you've gotten it right in all logic paths.

    99. Re:Goto is good by Anonymous+Brave+Guy · · Score: 1

      Need to undo 14 years of bad C++ practice, I guess.

      Perhaps, but the nice thing about this particular change in programming style is that it doesn't have to be an all-or-nothing commitment. You can simply be aware of the issue, and write your new code in a more declarative style. It doesn't mean anyone else working with your code has to learn new language features or idioms, nor does it require you to change any existing code or modify any project-wide design decisions. You don't have to use it all the time, if using mutable variables seems a more natural way of expressing a particular algorithm. And while of course with experience you'll pick up a few useful tricks that help you to write better declarative code later, the earlier declarative code you wrote before you understood those ideas will still benefit somewhat from the basic approach. So go ahead and give it a try, even if it's only a little at first. If your experience is anything like mine, you'll be glad you did.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    100. Re:Goto is good by Eivind · · Score: 1

      true enough. Just intended to illustrate a trivial example. But its a bad example, you are right.

    101. Re:Goto is good by TedRiot · · Score: 1

      Off the top of my head without knowing the context, I personally would prefer:

      launchEvent.setMinutesBeforeLaunch( 12 );

    102. Re:Goto is good by Kingrames · · Score: 1

      A single comment line, appropriately placed, can mean the difference.
      switch ($month)
      {
      case (preg_match("/ary/", $month)?$month:!$month):
      /*do something here if the month ends in "ary" */
      break;
      default:

      ... etc.

      --
      If you can read this, I forgot to post anonymously.
    103. Re:Goto is good by 19thNervousBreakdown · · Score: 1

      Whoops, forgot about this, fell asleep, ^D the window, had to run it again... anyway:

      2147483647
      0

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    104. Re:Goto is good by confused+one · · Score: 1

      good point. I've been coding in .net all the time lately and have forgotten too much wrt my ansi c roots.

    105. Re:Goto is good by wdef · · Score: 1

      Who is the author of these cartoons? http://imgs.xkcd.com/comics/ I like 'em.

    106. Re:Goto is good by jacquesm · · Score: 1

      well, don't listen to your mum then :)

    107. Re:Goto is good by poopdeville · · Score: 1

      Yeah, we use 5.6 at work. I haven't really bothered keeping up with any Perls past that.

      --
      After all, I am strangely colored.
    108. Re:Goto is good by ckaminski · · Score: 1

      Oh I agree with you 100%. I've started adopting it where it makes sense in my programming. Just not being 100% cognizant of whether a library is or is not composed of mutable objects has led to some of the most exasperating bugs and defects in my code since starting to learn J2EE.

    109. Re:Goto is good by dcam · · Score: 1

      1 or 3. But this is a significantly simplified example. Often the functions might need more parameters, which would tend to require more documentation.

      The problem with 1 is that pretty verbose. The comment could be "minutes before launch".

      I don't like 2 because you are embedded the units in the function name. This makes it harder to maintain, you can'y switch to units in hours at a later date without renaming all instances. Also it might imply that there is a setSecondsBeforeLaunch or setHoursBeforeLaunch.

      I'm not completely sure I like 3, I'm not a fan of typedefs, but I think it is clearer. Probably the best of the three.

      In this (simplified) example, I'd be inclined to go for:
      In LaunchActions.h:

      void setPreLaunchTime(LaunchEventStruct *event, double minutes);

      That way seeing the header file would document the units.

      A better example of the kind of issue I am talking about is more in calling code.

      Suppose you have some code where threads run at scheduled intervals and sleep for a time period. Here is an example of what I would consider good practice:

      sleep(1000 * 60 * 5); // 5 minutes

      The problem is that even when you know all the functions/APIs etc, it is easy to forget something. Documenting it makes life a lot easier.

      --
      meh
  3. Always think about maintenance by Mad+Merlin · · Score: 5, Insightful

    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.

    1. Re:Always think about maintenance by corsec67 · · Score: 3, Informative

      Yep, nothing worse than saying "Who the hell wrote this crap?", running svn blame, and then realizing that I did.

      And, if you aren't using a versioning system, like SVN(preferably), CVS, git, that is a very bad thing. SVN and CVS also have the benefit of getting code to a remote computer when you check it in.

      --
      If I have nothing to hide, don't search me
    2. Re:Always think about maintenance by moterizer · · Score: 1

      And the most important aspect of maintaining your work is to remember this: six months after you've written your code, it might just as well have been written by someone else. So here's a way to get in a time machine and make your future self really happy: INCLUDE CLEAR COMMENTS EVERYWHERE. Even to things you think are obvious. If it takes you more than 10 minutes to figure out how to do something, make a note to remind yourself why you did it.

      You'll be glad you did.

    3. Re:Always think about maintenance by try_anything · · Score: 5, Insightful

      There's a famous epigram (hopefully someone can provide it) to the effect that it's twice as hard to read code as to write it, so if you write your code as cleverly as possible, you will most certainly be unable to read it.

      If you're proud of a clever solution and can't wait to show it off, then it's an unsatisfactory solution. The best solution to a difficult problem is the one that is so clear that after reading it, nobody can comprehend that the problem presented any difficulty in the first place. The sign of a really great programmer is that he never gets stuck with any difficult projects. Everything assigned to him turns out to have a simple, easy solution -- what luck!

    4. Re:Always think about maintenance by Anonymous Coward · · Score: 0

      Yes! Code has to be written for people to read - the computer doesn't care about readability but the poor suckers who come later to maintain it will appreciate clean code. Take pride in cleanliness. Be tidy. Make it pretty. Nobody likes working in a smelly garbage pit.

      Build tests to go along with your code. Learn to write tests at the same time e.g. test-driven development. Use code coverage tools to insure you really are testing your code. This won't give you any certainty of correctness, but it will help you find problems that are easy to miss.

      Don't be too clever. You will lack the experience to write brilliant code so don't try; stick with writing correct and useful code.

      Less code is better. Don't make it complicated, and don't try to forecast the future in terms of reusable code.

      Find some outside projects, even your own, to work on that require writing lots of code. Publish your code to other people - it will encourage you to be honest about how good your testing and code really is.

      Be humble.

    5. Re:Always think about maintenance by enkidu · · Score: 5, Informative

      Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?
      - Brian Kernighan, "The Elements of Programming Style", 2nd edition, chapter 2

      --

      There is no trap so deadly as the trap you set for yourself
      -Raymond Chandler, The Long Goodbye
    6. Re:Always think about maintenance by dcam · · Score: 1

      There is a variation on an old chinese proverb:

      May you be condemned to maintain your own code.

      I've been maintaining my own code for ~8 years, sigh.

      --
      meh
    7. Re:Always think about maintenance by Count+Fenring · · Score: 1

      Especially (in some cases, probably exclusively) comment on your data structures. Logic is much easier to figure out after the fact from code than how many of what unit you stored where how.

      Also, this has the handy side effect of limiting you to data structures that you understand well enough to describe in English.

    8. Re:Always think about maintenance by El_Muerte_TDS · · Score: 1

      Yep, nothing worse than saying "Who the hell wrote this crap?", running svn blame, and then realizing that I did.

      I had that a couple of times, but I was never able to find the person with that userid. But know I know it's you.
      Stop messing up the code in my projects!

    9. Re:Always think about maintenance by Lonewolf666 · · Score: 1

      Or exactly knowing that I wrote that crap, but for various management-related reasons didn't have much of a chance to make it better. Or will ever get the time for proper refactoring.

      That company is doing a round of layoffs now, I'm among them and almost glad about it.

      --
      C - the footgun of programming languages
    10. Re:Always think about maintenance by qc_dk · · Score: 1

      A colleague of mine has this piece of advice in his email signature. I've forgotten to whom it is atributted:
      "Always code as if the guy who ends up mantaining your code will be a violent psycopath who knows where you live."

    11. Re:Always think about maintenance by jrbirdman · · Score: 1

      Actually, the best lesson is going straight into code maintenance. You can learn a lot just by looking at others good/bad examples. Have a mentor available so he/she can point to which is which just so you don't get confused.

    12. Re:Always think about maintenance by nategoose · · Score: 1

      I agree. Make sure that your identifier names and comments can be easily understood by the overseas programmers that your job is outsourced to.

    13. Re:Always think about maintenance by owlstead · · Score: 1

      Yup, just for fun wrote a Java application with a command line. Every command was an inner class (using a CLI library to define the arguments). Then got lazy and instead of adding all classes manually, I wrote a small piece of reflection code to automatically add the classes (by instantiating all classes of a certain type automatically and putting them into a list).

      Brilliant coding, just a shame that the debugger does not understand that class instances created this way should also change during live code replace. Never understood why certain classes did accept changes and others did not. Looking back at it and seeing the reflection code made me weep. I was instantly made irreplaceable for an otherwise boring piece of code.

    14. Re:Always think about maintenance by Anonymous Coward · · Score: 1, Interesting

      "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." â" Brian W. Kernighan

      And a personal favorite:

      "Always code as if person who is going to maintain your code is a maniac serial killer and knows where you live." - ??

    15. Re:Always think about maintenance by Anonymous Coward · · Score: 0

      "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."
      I belive it was Kernighan who said that.

    16. Re:Always think about maintenance by try_anything · · Score: 1

      Totally off-topic, but it sounds like a nice simple plugin architecture to me, nothing to be ashamed of. It's easy enough to understand (though I didn't realize you can find inner classes using reflection): all inner classes in class Foo implementing interface Command are instantiated and registered as commands. Any decent Java programmer should have no problem inheriting the code from you, assuming you put that one-sentence explanation in the class documentation for the class containing the command classes.

      It's not surprising that live code replace didn't work, but that's hardly a significant issue. The biggest issue I see is having a bunch of code in a single huge source file, which is stylistically bad when coding in Java. For that reason, it would have been better to rely on explicit registration of commands, but it should be easy to refactor to that.

    17. Re:Always think about maintenance by emmCee · · Score: 1

      It was Brian Kernighan:

      Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?

              * "The Elements of Programming Style", 2nd edition, chapter 2

    18. Re:Always think about maintenance by Anonymous Coward · · Score: 0

      Glad to help:

      Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?
      Brian Kernighan, "The Elements of Programming Style", 2nd edition, chapter 2

      (thx Wikipedia)

    19. Re:Always think about maintenance by Anonymous Coward · · Score: 0

      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. -- Brian Kernighan

  4. Get out now by Anonymous Coward · · Score: 5, Funny

    Get out, now, for the love of God, while you still can.

    1. Re:Get out now by Anonymous Coward · · Score: 0

      I would, but i dont love god. Well, in the same way i dont love the tooth fairy, or any other 'being' with no physical evidence whatsoever of its existance.

      Remember, there is no such thing as magic!

    2. Re:Get out now by martin-boundary · · Score: 3, Funny

      Yeah, those book recommendations are cook books!

    3. Re:Get out now by Anonymous Coward · · Score: 0

      Programmers is people!!!

    4. Re:Get out now by Anonymous Coward · · Score: 0

      Parent should be moderated insightful, not funny.

    5. Re:Get out now by fortapocalypse · · Score: 1

      It's true. Many developers (including myself) dream of quitting and becoming lawn maintenance professionals.

    6. Re:Get out now by Anonymous Coward · · Score: 0

      Working outside... now you just need to ehm... misplace the office's red stapler to get things started. Then you'll have an open space to work in.

    7. Re:Get out now by Anonymous Coward · · Score: 0

      I think he's serious.

      and /agree

  5. Learn how to just Google it by Anonymous Coward · · Score: 0

    Seriously, you can look it up yourself.

  6. Document your code by TheSpoom · · Score: 5, Informative

    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
    1. Re:Document your code by Anonymous+Brave+Guy · · Score: 1

      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.

      Better, don't repeat what it's doing (by definition, the code itself tells the reader that, and does so without any risk of becoming out of date) but add comments describing why it is doing it.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:Document your code by pipingguy · · Score: 1

      Comment. Comments are incredibly, incredibly important.

      Just to go off on a somewhat related tangent since I view programmers' work to be quite similar to the draftsmen of yesteryear...

      Back when I was doing manual drafting before CAD became ubiquitous I used to use blue pencils to make comments on the original. The comments would describe a bit about my thinking during the design phase. The blue writing wouldn't appear on Blueline prints or photocopies (different shades were needed depending on the repro technology used) but could be read when looking at the original. I never noticed other draftsmen doing a similar thing.

      Before CAD took over the technical drawing field, advanced methods of drawing production like cut-and-paste drafting and the use of erasable vellum were becoming quite efficient due to Xerox-type technologies permitting re-sizing and reuse of pre-existing designs and design details.

      While current 3D CAD can do some amazing things like fly/walk-through models (very cool and impressive, but overrated) of proposed designs and up-to-the-second material reports (dubious value, IMO), it has also made design and "drawing" production more complicated due to the expensive, complex tools required and the unforgiving nature of hardware/software setup and configuration. Not to mention vendor lock-in, the lack of ability to objectively evaluate different programs' suitability for the tasks at hand, the difficulties in finding properly trained users, third party software interdependence and half-baked, beta-like features in software that always work in demos but not so much in real life usage [1]. Oh, and the constant tinkering from vendors who "improve" the software for the next release (often to justify paying the upgrade cost), causing users to re-learn how to use the tool rather than focus on improving their design skills.

      [1] Which usually results in home-grown workarounds (obviously not supported by the software company) that get broken when the users are forced to upgrade to a later release.

    3. Re:Document your code by set · · Score: 1

      Better yet, write tests that explicitly state and test what your software is supposed to do.

      Write them before you write the code that implements them, if at all possible. If you can't, the 'supposed to do' part in the first sentence is all the more important. Don't test what the code *does*, test what it's *supposed to do*.

      Comments are lies waiting to happen, and the computer can't tell you when they're wrong. Failing tests will tell you your system is not working the way it's supposed to.

    4. Re:Document your code by Anonymous+Brave+Guy · · Score: 3, Insightful

      Unfortunately, test-driven design is not a silver bullet, unless you're lucky enough to have a finite problem space where you can achieve 100% test coverage, which almost no-one does, and you can consistently write perfect test code, which would be surprising if you're worried enough about your normal code to write all those tests in the first place.

      In the absence of such unrealistic guarantees, TDD lies somewhere between a useful addition to your coding practices and snake oil, depending on the realism and honesty of the person advocating/implementing it. Either case, it is not a substitute for good documentation and commenting.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    5. Re:Document your code by The+Moof · · Score: 1

      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.

      To add to this: comment your else and ending braces. Makes working your way back up the code much easier than trying to count off tab block a page down from a condition. The 2 seconds it takes to add /* if(a==b) */ to you code will save a lot of time in the long run (especially for the poor guy who has to maintain it in the future).

    6. Re:Document your code by plasmacutter · · Score: 1

      The commenting point cannot be stressed enough.

      I was one of a class of two in a CS practicum where we were handed an orphaned OSS work.

      It had no comments, and we didn't even really get even one good live demonstration of what it even did. (it was specialized to the linguistics field).

      Because of this paucity of information, I was tasked with running through the code and documenting it.

      The fact that each class didn't appear to enclose a distinct function, and that every function traversed 15 classes because of this, made for a very VERY frustrating experience.

      It ended up taking months to do, and i'm still not satisfied with the results.

      The truth is, the app would probably have been better off rewritten from scratch given the amount of time it took to analyze the byzantine nightmare I slogged through.

      --
      VLC FOR MAC IS DYING! IF YOU DEVELOP, PLEASE SAVE IT!!
    7. Re:Document your code by Anonymous Coward · · Score: 0

      I don't think that commenting everything it's so important. I try to write code that is easy to understand even without comments.

      That way I enforce myself to rewrite the code if I see it's getting messy. Self document code, that's my mantra.

    8. Re:Document your code by TheSpoom · · Score: 2, Insightful

      Readable code is great. Don't use it as an excuse not to comment though. It might be perfectly obvious to you what's happening, but that doesn't mean it's obvious to someone else, and you could easily be pissing someone off without knowing it.

      --
      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
    9. Re:Document your code by wiredog · · Score: 1

      Absolutely. First job I had (15 years ago) I was debugging a piece of code that did various weird things to set/read bits in a word in a memory efficient way. These bits were used to control some loops. So there was a while(pow(stuff))for(otherstuff){for(morestuff)
      {moreweirdstuff}}

      At the top of the block in question, a block which when printed out on the Epson Lq-510 ran 2 pages single spaced, was the following comment:

      //why did I do this?

      There were no other comments.

      I wanted to hunt him down and kill him.

      Ever since then, no one has complained about my code having too few comments. Nor too many, even though I comment everything. All variables:

      int i,j;// loop variables

      and

      motor x,y;//the x and y axes

      All methods and blocks, including closing braces because it may be a long block and I don't want to be scrolling up and down to see what the brace closes.

    10. Re:Document your code by try_anything · · Score: 1
    11. Re:Document your code by 32771 · · Score: 1

      You can write C code anyway you like just run indent later (assuming you aren't afraid of command line tools like the other guys around here ;).

      Here is a wonderful manual:

      http://www.gnu.org/software/indent/manual/html_node/Index.html

      Now look what it says under Copyright notices: ...
      Copyright © 1976 Board of Trustees of the University of Illinois.

      Damn it guys, you had 32 years to figure it out!

      This problem is almost as old as C itself and every new generation of programmers has to invent idiotic coding rules about tabs and who knows what, so you have something to keep your minds occupied while you are programming.

      --
      Je me souviens.
    12. Re:Document your code by crucini · · Score: 1

      In vi, the % key will bounce between braces. Emacs undoubtedly has an equivalent. What editor are you using?

  7. Perhaps have a look at StackOverflow by debrain · · Score: 2, Informative
  8. Design Patterns by Anonymous Coward · · Score: 0

    Learn design patters. They will make the world make sense.

  9. Commenting by Anonymous Coward · · Score: 0

    I know it's annoying and I know that it takes some extra time... but one of the BEST practices for any programmer is good commenting.

  10. Er by Anonymous Coward · · Score: 2, Funny

    Sometimes I wonder if the editors eyer bother checking the firehose tags for "tvpo" or "tvpoinsummarv".

    1. Re:Er by Anonymous+Brave+Guy · · Score: 1

      Sure, just not eyerv time.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  11. Always.... by ad0le · · Score: 1

    Resist the temptation to reinvent the wheel.

    --
    My mother never saw the irony in calling me a son-of-a-bitch.
    1. Re:Always.... by Bill,+Shooter+of+Bul · · Score: 4, Funny

      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.
  12. Stay away from the vending machine! by Anonymous Coward · · Score: 5, Informative

    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.

    1. Re:Stay away from the vending machine! by Anonymous Coward · · Score: 0

      And you won't turn into a fat tub of shit by the time you're 35 years old, and wondering why no women want to touch you!

  13. Code Complete is the #1 book I would recommend by tatomaste · · Score: 1

    Timothy, Not meaning to disencourage you, but programming is not somethign you can learn to do properly in a short period of time. With that said, I would highly recommend you get your hands in a copy of "Code Complete." This books compiles a lot of good programming practices. If you are going to develop Object-Oriented applications, it will be also important you get some concepts down from the start. Larman's "Applying UML and Patterns" is a good introduction to object oriented programming. I have not read "Pragmatic Programmer" (recommented by the previous poster) but I hear it is pretty good. Depending on the language and the programming paradigm, the learning curve may vary. But good software engineering practices take long to master. Remember, learning the programming language does not mean you have learn how to program. The difference is as big as the difference of knowing english and knowing how to write scientific papers in english. So keep on reading, keep the intellectual curiosity always high, there is lots to learn and it is a lot of fun. Good luck and have fun!

    1. Re:Code Complete is the #1 book I would recommend by try_anything · · Score: 1

      Larman's "Applying UML and Patterns" is a good introduction to object oriented programming.

      Dangerous advice. You should ignore anything until you understand the need for it. There are too many software engineering methods that sound like really good ideas but must be applied judiciously because they're only worthwhile under certain circumstances. If there's a Dark Side to the art of programming, it's the way of Impressiveness: using techniques that sound progressive and responsible, without thinking hard about their true cost and true value.

      UML is a great example of something that is presented as a Good Thing that programmers never use enough of, just like kids never eat enough broccoli. In reality, there's a proper amount of UML to use on every project, and on most projects it's zero. (And in reality, you really don't want to sit near a guy who eats a pound of broccoli a day.) Teaching UML in an introductory OO book is irresponsible -- the value of UML only emerges in circumstances that the readers can't appreciate yet, so you have to lie to them about its domain of usefulness.

      Design patterns are a borderline case. I wouldn't recommend them for a brand-new coder, but if you're already experienced, you'll understand the need for some of them right away. Others might be a mystery for years until you see, in a real life project, a situation where they apply. Just don't be the guy who adds Visitor patterns and Mediator patterns in places where they don't make sense and don't contribute anything to the subsequent evolution of the code.

      Read all you want, but be somewhat closed-minded and only use things that you really understand the need for.

      A great book if you know C++ is The C++ Programming Language . Stroustrup talks about the cost of everything and warns against misusing language features. He's a great person to absorb your programming philosophy from, because he teaches that every language feature and programming technique ever invented can be counterproductive in the wrong context.

      You should expect this from every author, and when you sense that an author is taking a one-sided approach to his subject matter, advocating something or trying to get you excited about it instead of explaining when it is good and when it is bad, then you should put it down and avoid polluting your brain.

      Incidentally, this means you will have to be very selective when reading about Java, .NET, or any other technology where people are trying to drive adoption. Enterprise technologies are especially problematic because the best technical publications often come from vendors or consultants, but you have to be extremely skeptical when consuming those publications because they are designed to give you a somewhat-less-than-objective enthusiasm.

      With some technologies (*cough* Microsoft *cough*) boosterism has become the customary writing style, even among people who have no financial stake in the technology. Some readers expect an injection of enthusiasm every time they pick up a book. Don't be a sucker -- those guys are clowns, and everyone hates working with them.

    2. Re:Code Complete is the #1 book I would recommend by tatomaste · · Score: 1

      I agree with most of your statements. However, the title "Applying UML and Patterns" is misleading. The book is a good introduction to OO programming, the use of UML simply helps communicate the author points in a graphical one. I actually in fact hesitated to buy this book because of its title alone, but don't let it mislead you, it is a good beginners book, despite its UML & RUP propaganda.

      The C++ Programming Language is propably my favorite programming book I've ever read. However I would not recommend it to a new programmer, specially one who is trying to learn by himself.

  14. Good tip... by Anonymous Coward · · Score: 0

    DON'T fall into the trap of spending all day on Slashdot when you should be working. Trust me, it happens.

    Seriously though, ask questions. Lots of questions. Understand the process fully before you take on a full-time assignment. It's going to be essential to your success.

  15. first post! by Anonymous Coward · · Score: 0

    Spend your day looking for opportunities to make the first port on slashdot.

    1. Re:first post! by Anonymous Coward · · Score: 0
  16. help by Anonymous Coward · · Score: 0

    Biggest thing is document not just for the guy that will look at it later but for your self a couple months down the line and they want something to work a little different.
    Modulize it makes it easier to debug and also to change things
    Also think about what you want todo and how you want to do it before you start to type the first line of code
    follow the preset methods your company programers write

    1. Re:help by SirSlud · · Score: 1

      As a subset to this learn to anticipate design changes - if you think there is any chance they will ask for something different down the road, the time to build in the flexibility is NOW when writing new code. Code with future changes in mind - it often costs very little more to build in the futureproofing for changes in strategies.

      --
      "Old man yells at systemd"
  17. Experiment and dabble in other languages by BrynM · · Score: 5, Insightful

    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...)
    1. Re:Experiment and dabble in other languages by corsec67 · · Score: 1

      Also, try to vary the kinds of languages you experiment in, like compiled, or interpreted and functional, or imperative.

      (These are all imperative)
      Compiled: Java, C/C++
      Interpeted: ruby, perl

      Functional: lisp, scheme, Erlang

      --
      If I have nothing to hide, don't search me
    2. Re:Experiment and dabble in other languages by wmbetts · · Score: 1

      That's some really good advice.

      I started programming as youngster in basic then moved to pascal and then C. When I was at university I wrote in C++ and then in C#. Now I find myself mainly writing in PHP. Over the years of experimenting in different languages I've found there's not many languages I can't pick up and use, because I know how to program not just the syntax of a certain language.

      --
      "Ubuntu" -- an African word, meaning "Slackware is too hard for me". - stolen from Dan C alt.os.linux.slackware
    3. Re:Experiment and dabble in other languages by RockoTDF · · Score: 1

      Plus if a new coder only learns Java, they look like a real idiot when they don't know what a function is because they have been calling it a "method" the whole time.

      --
      There is more to science than physics!

      www.iomalfunction.blogspot.com
    4. Re:Experiment and dabble in other languages by Fallingcow · · Score: 1

      Heh, I think it's worse coming from the other direction. A combination of naming convention oddities and heavy reliance on poor analogies in the books I was reading ("Say Bob is a class. Bob wants to buy flowers, so he calls the buyFlowers method in class Sally, who is a florist...") made it take much, much longer than it should have for me to grok OOP.

      A class, or object, is a container for functions, arrays, variables, etc. They can be treated like data structures for many purposes, e.g. placement in arrays. You can have more than one of the same class active, or "instantiated", at a time. One class can inherit another's attributes, and "extend" them. They are, above all, tools for making your code more compact, more reusable, and easier to understand. They are not magic, and they really don't do anything that you couldn't do without them.

      There. If the first OOP book I had read has just said that on page one, it would have saved me many headaches.

      It's SO. FUCKING. SIMPLE. I don't know why most of the introductory OOP books I've seen insist on making it sound so complicated.

    5. Re:Experiment and dabble in other languages by Anonymous Coward · · Score: 0

      Absolutely! Keep learning other languages and keep an open mind. We all have a tendency to fall in love with the one language we know best and there's a trait of human nature that we tend to resist change. Fight the tendency by diversifying.

      You WILL need to change languages someday (probably several times) and if you get stuck on any one language you're going to hate the new one, even if it's actually better than what you had.

      This goes for all the tools of the trade, even operating systems. If you get fanatical about any of them you are seriously limiting your knowledge, skills and job potential.

      Focus first on the skills they need/want you to have for the job. Once you're settled in set aside some time each week for extra study of competing tech. Don't judge it: you won't know it as well as what you are working with each day - so it's not a fair comparison anyway.

      Welcome to the insanity ;-)
      Ian

    6. Re:Experiment and dabble in other languages by RockoTDF · · Score: 1

      At least it makes your projects sound cooler and more complicated to people who don't know their stuff.

      --
      There is more to science than physics!

      www.iomalfunction.blogspot.com
  18. Listen, think, and listen by truthsearch · · Score: 4, Insightful

    - 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.

    1. Re:Listen, think, and listen by timothyf · · Score: 1

      I would go so far as to say it's more important, if you can, to *watch* your users as they try to use your software. That can be an even bigger eye opener. I'd say it's much more important to give them something they can use, even if it doesn't have everything they might want.

    2. Re:Listen, think, and listen by dubl-u · · Score: 1

      Excellent points. One amplification:

      Listen to your end users.

      One of the best ways to do this is to release early and often, and then pay attention to what happens. Study usage statistics. Observe people using your stuff. Ask people what they think, and set your natural pride and defensiveness aside to really listen.

      Always remember that your work isn't to write code; it's to make the computer serve others. The more frequently you get feedback, the faster you can get to that end.

    3. Re:Listen, think, and listen by Anonymous Coward · · Score: 0

      Read "The Inmates are Running the Asylum", if you can still get it. The book is excellent in explaining the user perspective and why software (interaction) designed by developers usually is broken and difficult to use.

      Think about your end users. Ask them how they think something might be done as they often have good ideas. For me, I work in an industry where while we don't quite directly sell to the end user, their input in the selection process is very heavily taken into account. If we don't pass the laugh test in a presentation we don't get the sale.

      Oh, and finally use your software in a similar environment to how the users will use it. If it starts to anoy you then it will probably anoy the target users too.

  19. editing standards? by Anonymous Coward · · Score: 0

    My company just tagged me for full time App Dey

    Maybe if submitters don't know how to spell, when the editors quote them, they could be like most editors and put "Dey[sic]" or something so we know it's not the editor's typo and that the editors can at least spell check?

    1. Re:editing standards? by Anonymous Coward · · Score: 0

      They'd probably end up making it "Dey[sick]".

    2. Re:editing standards? by Hal_Porter · · Score: 1

      hope dey get bettah.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
  20. Advice to increase productivity. by radarsat1 · · Score: 4, Funny

    Don't read Slashdot at work. :)

    1. Re:Advice to increase productivity. by middlemen · · Score: 2, Informative

      Learn assembly programming. It will teach you inner workings of a computer and how higher level languages get down to the lowest levels. You will be able to appreciate computers a lot more than just by coding java.

    2. Re:Advice to increase productivity. by igny · · Score: 1

      And to increase reproduction do not read Slashdot at home either.

      --
      In theory there is no difference between theory and practice. In practice there is. - Yogi Berra
    3. Re:Advice to increase productivity. by radarsat1 · · Score: 1

      Way funnier than my comment. Mod up! ;-)

    4. Re:Advice to increase productivity. by TheRaven64 · · Score: 1

      Totally agree. Even better, take some time to study your compiler's source code, or at least its output. Learning assembly isn't vital, but it's the easiest way of learning about your architecture and about the how the code you write in a high-level language will actually execute. If you view languages as a continuum from high to low level, then you can only really program well in a language by understanding at least one language on the rung above and below. If you want to program well in Objective-C, learn Smalltalk and assembly. If you want to program well in Smalltalk, learn Self and C. If you want to program well in Lisp, learn lambda calculus and ML. (Note: all of these are examples - exactly which pair of languages you should learn depends a lot on you).

      --
      I am TheRaven on Soylent News
  21. Comment removed by account_deleted · · Score: 5, Insightful

    Comment removed based on user account deletion

  22. code socially by palinurus · · Score: 1

    ask someone else to review your code. explain it to them; if it's hard to explain, maybe it needs work. read other people's code voraciously and critique it (maybe privately). let your ideas about style, techniques, practices become more fluid over time, not more rigid; this is the number one cause of death among programmers. be passionate and don't feel bad if other people don't care as much.

  23. Help the suits by rwade · · Score: 1

    Ensuring that the business people and cost estimators are aware of hours you believes are required to complete can ensure that you're always in the work in a resource-constrained organization.

    If you give the suits crap, you may put your project at risk of not being able to justify its existence.

    1. Re:Help the suits by SupplyMission · · Score: 1

      If you're in a resource-constrained organization, you have two options:

      1. Make yourself more valuable and less likely to get fired, or
      2. Find a job at a thriving organization where you can focus on doing good work, not worrying about staying in your job.

      Your best bet is to work on the first, until an opportunity for the second arises.

      The best thing you can do for your career (programming or other) and your own happiness is to learn how to work hard at tough jobs, and to recognize and act on opportunities to get into something better.

    2. Re:Help the suits by GuldKalle · · Score: 1

      Ensuring that the business people and cost estimators are aware of hours you believes are required to complete can ensure that you're always in the work in a resource-constrained organization.

      I'm sorry, but you sound just like a Markov generator. You failed the Turing Test.

      --
      What?
    3. Re:Help the suits by rwade · · Score: 1

      Well, of course you should concentrate on career development. To develop one's career, however, one should ensure that the project on which one works keeps going so they remain working and learning.

      There is nothing worse for career development than not having a project to work.

    4. Re:Help the suits by smellotron · · Score: 1

      Hey, I resent that! I was generating more believable Markov chains in high school!

  24. Read Risks Digest by Jah-Wren+Ryel · · Score: 4, Interesting

    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.
  25. Some advice I've learned by TheRealMindChild · · Score: 2, Insightful

    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
    1. Re:Some advice I've learned by mudetroit · · Score: 3, Insightful
      Or you could try working somewhere crazy where they actual value you and:

      1.) Asks you how long you believe something will take and then actually listens to you, and more importantly won't punish you if you were wrong. (Though it is important to tell them as soon as you know were wrong.)

      2.) Maybe people could actually just volunteer and say "I screwed up." when something comes to light? No need to blame period then.

      3.) Overtime pay is completely dependent on what you agree to when you are hired. And if they agreed to it, and still won't pay you, then you don't want to work there.

      4.) Or you work at a place where the salesman have a good relationship with the development team. And like above will talk to them about how long things will take and set priorities appropriately.

      5.) Don't bring your own code in, but still keep coding in your off time. You learn from it.

      6.) Any place you work should give you in writing what they ask to include. If they are out to stab you in the back you don't want to work there.

      Not everyplace out there is a hellhole. It took me a while to learn this too, but there are legitimate good places to work. Find one.

    2. Re:Some advice I've learned by Anrego · · Score: 1

      I totally agree, except for number 4. I have _never_ found a marketing type with any kind of grasp (or desire to grasp) basic reality.

      Yeah.. I'm bitter

    3. Re:Some advice I've learned by apathy+maybe · · Score: 1

      "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"
      Don't take it, if you can't do the job because the expectations are over the top, say it and relax.

      "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 "
      If it doesn't work out, you're better off anyway. If you aren't getting paid over time, don't work over time.

      "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."
      If the salesperson promises stuff that can't be delivered, make it clear that it can't be delivered and don't deliver it. Don't bend over and take it.

      Keep your CV up to date, and relax. Don't stress unless you are being paid to do it. Join the union (and stupid fuckers think that IT workers shouldn't have a union, if you don't have a union, you can get fucked over). Don't work overtime unless you are being paid. If the boss treats you like shit, don't do more work then what you are being paid to. Don't ever work 24/7, only work overtime sometimes, and even less if you aren't being paid.

      Keep your CV up to date and savings in the bank, and if you have a shit boss who expects you to work crazy hours and isn't willing to pay you, apply for other jobs.

      Don't listen to crap advice like I've quoted, don't "bend over and take it". (2,5 and 6 is OK or good advice, but "bend over and take it" is never good advice. Always be prepard to leave your job if its shit. And being raped is not good, whether figuratively or literally.)

      --
      I wank in the shower.
    4. Re:Some advice I've learned by Rakishi · · Score: 1

      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

      Find a better employer, I'd aim for one that pays beyond minimum cost of living for the area.

      2) Never blame someone else directly, even if it is obviously someone else's fault

      Find a better employer and a boss who understands who causes problems.

      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

      If you're hourly than legally they need to pay overtime. If you're salaried then legally they don't. Don't complain because you chose one when you got hired and your employer doesn't want to break the law. If you're salaried you didn't get hired to work 40 hours a week but rather to work X hours a week (X should have been agreed upon during hiring process). Your pay will likely be higher because it's for more hours or work a week, if it's not then you should quit and learn to negotiate better.

      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.

      Find a better employer and a boss who has a spine.

      6) Get every promise in writing. Whether it a bonus, "comp time" for late/extra hours worked, whatever.

      Generally good advice although see points 1 and 4 if this is actually usually necessary for you (rather than simply a good safety net).

    5. Re:Some advice I've learned by Anonymous Coward · · Score: 0

      Wow... To the person who asked for help, do NOT take OP's advice. Don't EVER get stuck with a job you hate, coding can be very rewarding if you don't give in.

      Well, to be fair, not taking code from home is good advice if you work for a large software company with restrictive licensing, no matter how much you love the job it's not worth it.

    6. Re:Some advice I've learned by ozphx · · Score: 1

      Sounds like you have forgotton rule #1 and rule #3 of professional developers.

      1) No freebies.
      2) No backsies.
      3) Give them the finger.

      No overtime pay? Rule 1. No overtime work.

      Bend over and take it? Hell no. Apply rule 3. Get a better job.

      --
      3laws: No freebies, no backsies, GTFO.
    7. Re:Some advice I've learned by Anonymous Coward · · Score: 0

      >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

      I'm a contractor in the UK. I'm paid by the day (defined as 8 hours usually). Frequently during interviews I'm asked am I prepared to be "flexible" regarding the hours I work. I always tell them that if there's a crisis - I'm willing to help out, but no, I'm not willing to work 60 hours a week each week for 40 hours pay. If you are willing to bend over and take it, then go ahead, personally, I choose my employer as much as my employer chooses me - and I don't let them screw me over.

  26. Oh my... by Anonymous Coward · · Score: 0

    Lets hope you have some well hidden coder aptitudes

  27. A few tips by mr_mischief · · Score: 5, Interesting

    I'm far from a master programmer myself, but this much I know.

    • Don't get attached to your code. Your code sucks as a newbie. Your code will suck a little less with experience. Even the master coders sometimes write a section of code that sucks. Much of the difference between a newbie and a master coder is that the master coder recognizes his own mistakes when he comes back to them and rips his old code apart to be replaced by new code. The quality of the application as a whole is where to take pride if you're going to be proud of something. Being overly proud of a line, a function, a class, or a library will often get in the way of the quality of the application. Your users don't care about the code you write or how clever/inspired/tight/beautiful/special it is. If rewriting part of the code improves the application, then that's what matters.
    • Bugs happen. Fix them without blaming or arguing. Don't place blame on the people who wrote them. If blame must be placed, place it only on the code in which they were found. Your job is to make the code work, not to piss people off by pointing fingers. You'll write bugs into code, too, anyway, and you don't want every one of them thrown back in your face.
    • Make a habit of promising less and delivering more. It's much better than the other way around.
    • If you're doubting how to design or code a section of a program, ask two people whose programming styles differ. Take as much of the advice of both as will fit into one solution. Try to change which two people you ask from one task to another, even if some of them are not the absolute best programmers on the team. You'll learn more this way than attaching yourself to one mentor unless your mentor happens to be a world-class wizard. You'll also keep allegations of cronyism and team splitting down.
    • Use source control of some sort. Even if your team doesn't use it overall, use it for your portions. Even if it's something really basic like tarring up your project directory at the end of every work day and keeping the tar files, do it. Try to subtly hint at its benefits for the whole group if they're not already using it.
    • Learn a programming language completely different from what you use at work in your spare time. The perspective it gives you can be very helpful. Lisp, Scheme, Haskell, Erlang, and Forth are good candidates for most people to pick up. If you're not exposed to one of Python, Perl, or Ruby at work, pick one and study it at home, too. Any one of those will do, although my personal preference is Perl (after all, it's just a personal preference). JavaScript's object model is interesting, so that wouldn't be a bad choice either.
    • Don't read /. and other sites too much when you need to be coding. It's great to take a break and come back to a problem, but don't overdo the break part when a deadline looms. Cramming and hurrying when coding isn't as easy as hurrying up many other kinds of work.
    • Get plenty of sleep and drink plenty of fluids. I know it's old advice and it sounds corny. All those tales of lone hackers coding all week on coffee, Jolt cola, cold pizza, pot stickers, and hot and sour soup are romantic and inspiring. They're stories about great people getting stuff done against the odds, though. You need to think clearly to code well. If you can think clearly on 3 hours sleep and cold pizza night after night, then good for you. If not, take care of your body so you can concentrate.
    • Set reasonable short-term goals on projects and cross them off one after the other. You don't have to knock the whole project out as one commit two days into the schedule. If you can schedule kind of conservatively and get ahead of schedule, then use that time to improve your code or save it for troubleshooting later in the project. Don't get cocky when one module gets implemented smoothly and tell your boss to shorten the whole schedule. It'll just come back to bite you in the ass if you do.
    1. Re:A few tips by Fencepost · · Score: 1

      A few more:

      • Don't trust your inputs. Sanity-check what you get, particularly if you're getting it from users but even from your database. Don't assume that your users will make stupid mistakes, assume that your users will make stupid malicious mistakes.
      • Trim whitespace. If you don't, something else will and someday your program will be comparing "This " and "This" and giving unexpected results.
      • When you test for errors, do something significant.
      • The best reason to write good (documented, understandable) code is so you don't have to look at it again. This doesn't mean that looking at it is bad, but you don't want to be pulled off projects in the future because "You wrote it and none of us understand it, so we need you to make these few little changes."
      • Sneak in a "Credits" Easter Egg. If you find yourself wanting to be sure your name doesn't appear on that egg, it's a good indication that you should've picked up major problems long ago. See also "Cordwainer Bird" and "Alan Smithee"
      --
      fencepost
      just a little off
    2. Re:A few tips by Anonymous Coward · · Score: 0

      Great write up.

      I remember when i first started programing many moons ago, i would come back after being much more versed in a given language and be like "what the hell was i thinking?". So your are correct in saying, noob code smacks of suckyness.

      One of the best coding methodologies that i live by is "Great code writes itself."
      If you have a great design, you'll know it by it's relative ease of implentation.

      and im a huge stickler for consistant code formatting.

    3. Re:A few tips by jschmerge · · Score: 2, Informative

      This is all great advice. The parts about not being defensive about code you've written are spot-on. I would add the following to the list:

      • Invest time in making your tool-chain work for you. I've been a professional developer for close to ten years, and tricks that I spent a day figuring out when I was a newbie *still* save me a lot of time. I don't care what environment you're coding in, but having a tool that cross-indexes the source base your working in, and allows you to (in your editor) immediately jump to a different function will save you hours. All IDE's will do this with a small amount of config tweaking. Additionally, emacs & vim are very capable at this once you learn the black art of configuring them.
      • Recognize when you're doing something tedious. Usually when something is a repetitive drag, you'll save time writing a script to do the repetitive work. It can be a crappy throw-away script... Don't make it work correctly... Just make it good enough that you can hand-edit the output and save yourself time. Finally, save that script somewhere so that you can hack it later if you need to.
      • I'm going to re-emphasize mr_mischief's point of using a revision control system. Using a revision control system is kinda like always having the ability to save your progress in a video game. An RCS allows you to go back and see what you did that f*ed up the code. I will add that it really helps to have a graphical diff program that works w/ you version control system. IDE's usually provide a graphical diff that understand most version control systems, but find a good one; it will save you hours over time.
      • I have no idea of what environment you're going to be coding in, but you would do well to learn the basics of editing text with VI... There will be a point that you're on some random system without your IDE... VI is usually available on any system, or easily installed. This again, will save you hours. (Full Disclosure: I use VIM for development for this very reason)
      • Do your development from the command prompt. Once you learn how to do everything from the prompt, you can script the common stuff.
      • When someone asks you how long something will take, come up with an honest estimate of the amount of time it will take, and then multiply it by two. It's better to say things will take a while than to be late on a project.
      • Prototype your code in a high-level language like perl or python, then port it to the language it needs to be written in. It saves you writing code that has stupid bugs in it. You get to write the code w/o dealing with the ugly low-level stuff.
      • To add to the previous point, pick a prototyping language that you have enough knowledge of to translate your code into the end-result language easily. I would advice against picking a prototyping language like haskell or lisp if you're delivering code in C/C++/C#
      • Never stop learning
    4. Re:A few tips by dubl-u · · Score: 1

      All those tales of lone hackers coding all week on coffee, Jolt cola, cold pizza, pot stickers, and hot and sour soup are romantic and inspiring. They're stories about great people getting stuff done against the odds, though.

      That's a great point. And it's important to remember that stories like that only matter when external circumstances necessitate heroics. In my career, about 98% of the heroics I've seen are unnecessary bullshit that could have been avoided with a little forethought. And easily 90% are in response to problems that the "heroes" helped create.

      If you save somebody from a burning building, you're a hero. If you keep saving people from the same burning buildings where you keep storing gasoline cans near furnaces, then you're a dangerous lunatic.

    5. Re:A few tips by zobier · · Score: 1

      Listen to the wise posters above me, and;

      • If you have to estimate a piece of work, take a reasonable guess as to how long you think it will take... then double it.
      --
      Me lost me cookie at the disco.
    6. Re:A few tips by Anonymous Coward · · Score: 0
      Good points. To add a few in no particular order,
      • Try to keep up a good ratio of tests vs code. Tests make your code more robust and make it easier to change it without breaking anything - but most of all they force you to think about what you're trying to accomplish and they can serve as a spec for your code at the same time.
      • Refactor often. This is a lot easier if you followed the previous point.
      • Run a lint-like tool on your code now and then, e.g. PMD for Java or pyLint for Python. You shouldn't treat its output as gospel but it can be quite enlightening.
    7. Re:A few tips by Anonymous Coward · · Score: 0

      Very good points!

    8. Re:A few tips by jonaskoelker · · Score: 1

      Even if your team doesn't use [source control] overall

      My keyboard used to love soda, but I think this turns it straight into a zombie: "mmm, braaaains..."

    9. Re:A few tips by mhall119 · · Score: 1

      My additions:

      • Make a design that in 80% perfect, then start coding and hack the rest. No design will ever be 100% perfect, and if you wait to code until you can figure out the remaining 20%, you'll never get anything done. Honestly, even if you have 99% of the design figured out, you'll still probably end up hacking as much as 20% of the code.
      • Flexibility is good, but your code will never be flexible enough to handle everything, so don't even try. Again, get 80% coverage then add hacks to cover the fringe cases (unless you can ignore the fringe cases, in which case do that).
      • Beware of pattern creep, patterns are good but that doesn't mean you have to use them all. If you find yourself using more than 2 patterns on a given code path, you probably want to re-think how much you actually need them. Sometimes you will need them all, but more often than not you're just using one of them because it can be used there, not because you actually benefit from it.
      • Don't get so carried away with how you are accomplishing something that you forget what you are trying to accomplish in the first place. The best process ever written is useless if it doesn't actually get you where you wanted to go.
      --
      http://www.mhall119.com
    10. Re:A few tips by Anonymous Coward · · Score: 0

      Make a habit of promising less and delivering more. It's much better than the other way around.

      Be careful with this one.

      One clown I worked with estimated that it would take a week to complete one section of code, which ultimately took him three months. He successfully convinced the project lead that it was because of refactoring of the requirements and interference from other team members when in fact it was a result of his own incompetence.

      Concurrently, I estimated a job at 30 days to generate production quality code, and delivered working, tested and documented cross-platform code on time as promised. Meanwhile our clown had managed to convince the project lead that the job should have been completed in a mere three days, and I got tagged as "slow".

      The difference was this: he had always worked in jobs where estimates were based on how long it took to hack together a prototype, whereas my estimates were based on the time it took to get code to the point where it was truly complete and never need be touched again.

      Ultimately, I was let go and our clown kept his position. When the project failed, he spun it as an intrinsically insoluble problem - which was true only for someone with his ineptitude.

      Sometimes politics wins, so match your promise/delivery strategy to your environment.

  28. Columbo by MarkusQ · · Score: 3, Interesting

    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

  29. Dont ever... by ya+really · · Score: 1

    10 print "think about doing this\n" 20 GOTO 10

    1. Re:Dont ever... by ya+really · · Score: 1

      forget not to use a line break when you post something like the above in html

    2. Re:Dont ever... by base3 · · Score: 1

      And don't forget that BASIC doesn't grok printf format specifiers :).

      --
      One CPU cycle wasted on digital restrictions management is ONE TOO MANY.
  30. think about maintenance -- write crap !! by Anonymous Coward · · Score: 0

    considering an offshore group will probably be the ones to take your job, might as well go ahead and write crap now. So when you're unemployed, at least you'll get to laugh about the poor schmuck slogging through your recursive spaghetti nightmare.

    1. Re:think about maintenance -- write crap !! by SQLGuru · · Score: 1

      You could always learn [insert foreign language here] so that when your job goes off-shore, you get to be the on-shore "manager". Usually a bump in pay, some extra travel, and a little more job security than your neighbor.

      Layne

  31. Work a year or two doing maintenance by MikeRT · · Score: 4, Insightful

    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.

    1. Re:Work a year or two doing maintenance by Alpha830RulZ · · Score: 1

      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.

      And you should be thoughtful about how much of this crap code passes the tests and gets the job done. Beautiful code is good, but it's a means to an end, not the end in and of itself. It's usually the result of clear thinking and good design, which are also useful, but not the end goal, either. The end goal is solving some problem, for the right amount of cost, for some customer/user. Make sure you know what that problem is and solve it, and you'll do well.

      --
      I was taught to respect my elders. The trouble is, it's getting harder and harder to find some.
  32. standards by wrench+turner · · Score: 1

    standards

    CM - revision control, continuous integration, CVS is fine, SVN is popular, CC is expensive

    Use good naming conventions for symbols & files.

    Make consistent use of whitespace/indenting.

    Put a comment header at the top of each file (author,date,source repos,exec path,prerequisites,revision history).

    Take your time designing/documenting/writing test plan, and less time coding/testing. Use good design over voluminous comments.

    Don't make waves. Use the programming language you're supposed to. Write in the style (OO, procedural, structured, RPN) the successful members of the team do.

    Learn from your mistakes. Be honest with yourself about your performance. Get good at estimating and delivering on time.

    Treat people the way you like to be treated.

    Find a mentor.

    1. Re:standards by Nicopa · · Score: 1

      Wow! You shouldn't be making recommendations!

      CVS fine? and SVN just the popular new kid?

      Naming conventions? Do you really think that is one of the most important things to have?

      Useless comment with revision history in the top of the file?

      Find a mentor? What for?

      Don't make waves??

      All this sounds as a recipe to be a mediocre programmer... =)

    2. Re:standards by chromatic · · Score: 1

      Naming conventions? Do you really think that is one of the most important things to have?

      Only if you want to write and maintain screechingly obvious code.

  33. Some things to do by MarkKnopfler · · Score: 1

    Introduction To Algorithms -- Cormen
    Unix Internals : The New Frontiers -- Uresh Vahalia
    Programming Pearls: John Bentley

    1. Re:Some things to do by Timedout · · Score: 1

      Algorithms, eh? My job is to design them, but before I came to this job I never worried about it in a professional setting. (school was another thing, since CS is a lot of algorithm analysis as a degree) Seriously, you will find most sorts and searches are already programmed for you, and are optimized. And if you work in a larger framework there will probably be an optimized sort and search already implemented for you for that specific data set.

  34. Write good descriptive comments... by madhatter256 · · Score: 4, Insightful

    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!
    1. Re:Write good descriptive comments... by dubl-u · · Score: 1

      Try to right program code comments as much as possible as long as memory permits it (if you do have a memory cap).

      Are there actually people who have had a problem this decade with this? Sure, when I had 4k of RAM, this was an issue for me, but now?

    2. Re:Write good descriptive comments... by Anonymous Coward · · Score: 0

      if you feel the need to write comments then stop and think about the variable names and the code itself because its probably a pile of shit! and should be rewritten clearly.

  35. Know your strengths - your boss won't. by eagee · · Score: 1

    Here are some tips that've helped me over the years:

    1. Inheritance is very easy to misuse. Use it *very* sparingly!!! Figure out what Aggregation, Composition, and Delegation are (check out the strategy pattern, composite pattern, and facade patterns!)

    2. Read an OOAD book. I liked the head start series - really fun, and easy to digest.

    3. Never rewrite a project that's broken. Fix it first, then refactor.

    4. Do all your planning *before* you write a line of code. It's much easier to erase a line between two objects than it is to refactor a class.

    5. Figure out what you're best at / what you enjoy the most - implementation or design. Then you can play off the strengths of your team mates:

    Implementationists are your low level guys who are great at math, know how everything works, and the kind of people you go to when you want a complex algorithm done.

    Designers usually lean toward the visual side of things, are more concerned with how things are used than how they work, and are good with big-picture items like software architecture.

    6. Don't stress, you don't become good at programming without making *lots* of mistakes! You'll learn how to avoid most of the pitfalls over time.

    I hope some of that was at least a little helpful. Good luck!

  36. Exceptions! by mangu · · Score: 1

    goto is sometimes useful, for breaking out of a few layers of loops/blocks.

    Maybe, if you are still programming in FORTRAN-77. For modern languages, the use of exceptions is recommended.

    1. Re:Exceptions! by gamanimatron · · Score: 1

      Not so fast. There are exceptions to the use of exceptions.

      It depends on what you're programming for. While this discussion seems to be BigCorp app-centric, there are other coding situations where exceptions are not available. Like, say, anything in a .DLL or .so that might be called by something other than C++.

      Or when writing for next-gen game systems, where your code is running on three different architectures and the tech lead tells you that exceptions are going to be disabled for one of 'em.

      --
      cogito ergo dubito
    2. Re:Exceptions! by TypoNAM · · Score: 1

      C language doesn't do exceptions for example and another one is that in Linux kernel module development they suggest to use goto in their coding style for cases like when you have mutliple exit points in a function and need to do some cleaning before returning. Doing anything else would just add code bloat and then the compiler would have to waste time optimizing it all down to Esentially a goto / jump instruction.

      - Coding Style Reference

      --
      This space is not for rent.
    3. Re:Exceptions! by nog_lorp · · Score: 3, Insightful

      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.

    4. Re:Exceptions! by Count+Fenring · · Score: 1

      And on what you're programming in. In Perl, goto LABEL is a clearer, syntactically cleaner way to break out of loops than any of the various exception handling methods I've seen.

    5. Re:Exceptions! by 19thNervousBreakdown · · Score: 1

      For modern languages, the use of exceptions is recommended.

      Yeah. What? No.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    6. Re:Exceptions! by Anonymous+Brave+Guy · · Score: 0

      Exceptions are not meant for intentional flow control, they are for exceptions.

      Says who?

      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.

      Not so fast, hotshot. Techniques for implementing exceptions efficiently have been known for quite some time now. There are still necessarily overheads involved on the occasions when an exception is thrown and caught, of course. However, there can also be savings from skipping over redundant code efficiently in exceptional cases, which may (or may not) outweigh the overheads. Moreover, in simple cases where the general exception mechanism would be overweight because the exception is thrown and caught locally, how do you know your compiler/interpreter isn't just optimising it to a goto anyway, since it can see the entire picture all in one place? You really need to look at the profiling results if the performance matters.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    7. Re:Exceptions! by Anonymous Coward · · Score: 0

      Mod parent up.

      Goto is SOP in certain parts of linux kernal/driver dev.

    8. Re:Exceptions! by Anonymous Coward · · Score: 2, Informative

      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.

    9. Re:Exceptions! by TheSpoom · · Score: 1

      I have to agree with the parent. Exceptions are called "exceptions" for a reason. If you have code that would be called in the normal flow of a program, it should be in a method or function of its own.

      My guess is that you did not go to school and learned programming on your own, which is fine, but please, understand that in this case, you are wrong. Exceptions aren't for normal failure cases or input verification, they are for exceptions. Usually stuff that would otherwise stop your program.

      There is also something to be said for code cleanliness when using exceptions... Exceptions are much like GOTO in that they can literally skip out of code and skip back in. You don't realize it but it allows you to create spaghetti code really easily, which might be easier to begin with but will ultimately make your code hard to follow when it starts to become larger.

      --
      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
    10. Re:Exceptions! by Macman408 · · Score: 1

      I wouldn't write that technique off completely... There might be times when it could be quite effective. Like if function A calls one of 10 different functions (call them 1 through 10), and each one of those might call function B, possibly multiple times. Now, there might be a case where function B wants to return all the way to function A. Do you really want to add if statements to each of functions 1 through 10, possibly in multiple locations of each, to check B's return value, and possibly then return to A? I could envision using an exception here instead, as long as performance is not critical, or the event is uncommon.

      There are other ways one might implement this; say implement functions 1 through 10 as a single function, and the parts that are different could be implemented, say, as case statements. That significantly reduces the number of places you'd have to check the return value, but also gives you one very large function. I'm sure there are many more ways one could reorganize the code, perhaps avoiding the need to pop up to function A at all, depending on the specific algorithm.

      But, the point is, don't dismiss using an exception just because it doesn't "seem" exception-like (eg, an I/O error). According to Sun:

      An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions.

      OK, so that leaves some more questions - like what's the "normal flow" of a program? In any case, there's nothing here to say that you can't use an exception to break out of deep nesting. If it works, use it. If there's a better way (in terms of maintenance, speed, readability, code size, coding ease, etc.), use that instead. Often, you'll find that absent a specific guideline ("speed is more important than anything else"), several options might work well. Don't discount a technique just because it's not the "usual" thing you're used to seeing.

      On the other hand, if you're not used to seeing it, that's a mark against it for readability and maintenance - so it had better have some benefits in the other categories.

    11. Re:Exceptions! by Anonymous Coward · · Score: 1, Insightful

      How well do you know exceptions in Java? I haven't tested it myself but read a thread on a J2ME forum in which somebody showed how it is faster to iterate an array if you don't do bounds checking yourself but instead simply catch the ArrayIndexOutOfBoundsException because Java checks it anyway and while (true) is fast. People there perform plenty of such tests when they try to optimize their mobile phone games - and gladly admit that it requires some horrible coding practices.

    12. Re:Exceptions! by I+cant+believe+its+n · · Score: 1

      No.. you are a fucking idiot. Please never write software again.

      Although I only use exception handling for exception conditions, agreeing with some of the technical points of your rant feels awful.

      People like you kill debates and make other people hesitate even though many of them know a lot more than you do on any given subject. It is amusing that you do not even have the balls to be anything but an Anonymous Coward when you go all in.

      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).

      Where do you catch your exceptions? Are you 100% sure of this complete stack walk? Since I don't know anything, surely you will be able to teach me. Tell me in detail how this works.

      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.

      Perhaps he has just been around longer than you? I recall when java was really slow and servlets where a "new thing". Back then it was common to suggest using this technique to get better performance. Sure, times have changed and using exceptions and loops this way is not the best way to go. Still, being impolite about it only makes you look dumb.

      Learn to code.

      Don't be an ass

      --
      She made the willows dance
    13. Re:Exceptions! by MadKeithV · · Score: 1

      You know, performance isn't the only consideration, and not even the main consideration. Confusing the living daylights out of other programmers by writing something that's twice as complex as the obvious solution is not good. Especially if it is for no real gain other than not wanting to bother to figure out why your design is so wrong that you're having to use exceptions to control flow.

    14. Re:Exceptions! by garyrob · · Score: 1

      "exceptions are (in almost all implementations) much slower"

      In Python, it can be much faster to catch SOMEWHAT rare conditions in exceptions than by using if tests to test for those conditions. So, the maxim "exceptions are for exceptional conditions" isn't considered paramount in Python as it is for, say, C++. Exceptions are becoming something more people are using for flow control when it's convenient to do so.

    15. Re:Exceptions! by Anonymous Coward · · Score: 0

      I believe you've misunderstood me. I interpreted the parent poster's statement "extremely expensive" to mean slow and addressed that. I also did say that J2ME coders admit that certain optimizations require horrible coding practices.

    16. Re:Exceptions! by Anonymous+Brave+Guy · · Score: 1

      You seem to have taken a post that you disagreed with, and instead of actually providing any information about why you feel it is incorrect (such as a verifiable counter-example to the notes on efficiency gains and losses I provided), you have repeated urban legends about exception performance that have been obsolete on good platforms for several years. You have also engaged in an ad hominem attack, and in making generic statements about "handling exceptions" without defining in any useful way what you consider to be exceptional. Finally, you have attempted, without giving any reason, to narrow the discussion to a small number of very similar VM-based languages, which may or may not have performance characteristics that match other languages; I don't program on those platforms much myself, but even I am aware that one of them has been notorious for its slow exception mechanism in the past, and notes from another post suggest that this may still be the case.

      I like my code just fine, thank you, and the way I write it is based on using the right tool for the job. That means making a decision about whether to use exceptions (or not) is based on readability/maintainability of the code and objective evidence about performance, not on dogma and hear'say.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    17. Re:Exceptions! by Anonymous+Brave+Guy · · Score: 1

      Exceptions are called "exceptions" for a reason. If you have code that would be called in the normal flow of a program, it should be in a method or function of its own.

      But what is the "normal flow" of a program? I have never seen a useful, universal definition of "normal" vs. "exceptional" in this context. The best approximation I have seen came from, IIRC, Herb Sutter, who described things in terms of whether pre-condition, post-condition or invariant contracts are violated. But then of course you have to consider whether it's appropriate to write a function with a simpler interface and deliberately force the more complicated failure cases into failed post-conditions that become exceptions.

      In other words, it's easy to quote dogma about normal flow and truly exceptional cases, but it's a whole lot harder to make the words actually mean something specific.

      My guess is that you did not go to school and learned programming on your own, which is fine, but please, understand that in this case, you are wrong.

      Thanks. I'll just take my academic CS qualifications, many years of programming, and numerous successful long-term projects I've worked on, and assume everything I've learned from that experience is wrong because someone on Slashdot told me so.

      Curiously, one of my responsibilities these days is providing training for less experienced developers. One of the first things I do when we talk about dealing with faults, failures and errors is to show that there are several very different approaches you can take. One of the next things I do is explain that this area is full of more dogmatic rules than just about any other in software development, and almost all of them should be broken at some point. A lot of the guys I work with have come from a background using something like Java or .Net-based languages and have never seen ideas like the Erlang "let the thread die" model, or the use of monads in Haskell. When I ask a few warm-up questions, they'll quote me all kinds of rules and dogma just like several of the responses in this thread, yet they rarely have any reason beyond blind faith to believe what someone once told them. By the time we've finished, pretty much the one thing everyone always agrees on is that all of these techniques are merely tools, and dogmatic adherence to rules is never a substitute for looking at what reads most naturally, performs best, leaves the smallest scope for errors, and similar criteria. You can only judge those things when you're looking at real code for a specific problem, knowing the programming language, preferences of the development team, and so on.

      Exceptions are much like GOTO in that they can literally skip out of code and skip back in.

      You should come to one of my courses some time. One thing we talk about, in considerable detail, is the important differences between exceptions and gotos.

      In any case, your final comment has betrayed your real feelings:

      You don't realize it but it allows you to create spaghetti code really easily, which might be easier to begin with but will ultimately make your code hard to follow when it starts to become larger.

      It's not the particular exception vs. goto argument we were talking about here that bothers you. You just don't like exceptions at all, do you?

      I've got a few successful, multi-million line projects behind me that say you're wrong on the claim above, BTW. Using exceptions can be very helpful for keeping your error handling systematic in code bases on that scale. It requires a little forethought, as all architectural issues on that scale do, but in most cases it is strongly preferable to relying on manual error handling using things like propagation of return codes.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    18. Re:Exceptions! by Anonymous+Brave+Guy · · Score: 1

      People like you kill debates and make other people hesitate even though many of them know a lot more than you do on any given subject.

      I appreciate the moral support, but I've taught far worse than that AC in my time. The ones who go around f'ing this and s'ing that are invariably all bluster, usually uncomfortable with not being the "smartest person in the room", perhaps for the first time. After a while, they realise that there are always a lot of smarter, more experienced people in the world, and that perhaps listening to other views is good even if they don't always agree with them.

      And yes, I have been around a fairly long time in the programmng world. Long enough to know that a lot of people who balk at using an exception don't bat an eyelid at using a break/continue, or an early return statement, or even a goto, yet can't quite explain logically why these are OK but using the exception is a cardinal sin. Some of them still write convoluted loop logic with early exit flags, despite the horrendous clutter it introduces in complex cases, because they have an almost religious belief in structured programming and the single entry-single exit rule, but again, they never quite know why it's supposed to be better. There's not much you can do to help someone with a closed mind, but you can at least show them options for when they learn to open it.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    19. Re:Exceptions! by 19thNervousBreakdown · · Score: 1

      Says Bjarne Stroustrup, the inventor of the language, and nearly anyone who's ever worked on or implemented the spec.

      Whether it seems OK to you or not, the fact that you're not only doing something they did not envision (which is cool), you're doing something they specifically don't think their constructs should be used for. Performance is not the only consideration, although putting exceptions in your loops can certainly have an effect on how much a compiler can optimize the loop or function calls it contains. Code clarity is something to think about, and anyone whose been in the computer industry for any amount of time (should) know(s) that going against the designer's vision is a bad idea unless you really know what you're doing, or are bug hunting.

      Not to say there couldn't be a situation where it would make sense ... but I haven't seen one sense.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    20. Re:Exceptions! by nog_lorp · · Score: 1

      The difference is the ArrayIndexOutOfBoundsException happens only once per iteration. It is (depending on how many elements there are) an extremely rare case. If, on the other hand, you need to break from a loop, say, more than half the time, the exception catching gets very expensive. The difference is how often you need to catch it.

    21. Re:Exceptions! by nog_lorp · · Score: 1

      Exceptions are essentially always slower than gotos in the case that the exception is caught/the goto is followed. I'd say a good definition for "exceptional condition" is one that occurs a small enough percentage of the time that it is more efficient to catch the exception than to check the condition all the times it isn't needed.

    22. Re:Exceptions! by Anonymous+Brave+Guy · · Score: 1

      I'm sorry, I didn't realise anything in this thread was specific to C++. Exceptions exist, in broadly similar form, in almost every mainstream programming language in use today. The only major exception (no pun intended) is C.

      As for using features other than as language designers intended... Your C++ focus seems a little ironic there. If no-one had ever tried using things like templates in other ways, a great deal of the power in modern C++ libraries would be missing. Whether the complexities of template metaprogramming and the current, almost fanatical emphasis on supporting it among the standards committee and Boost community are worth the technical and opportunity costs depends on your particular circumstances, but there is no denying that none of the people behind the language saw the idea coming or realised its potential.

      I honestly don't understand all the negative feelings towards exceptions in the discussion here. Exceptions are just a tool in the programmer's toolbox, like loops and gotos and variables and functions. They define a certain behaviour, and there are certain overheads and savings in practice that you get if you choose to use that behaviour. There's no rule that says that as a programmer I may or may not use exceptions for any particular purpose or in any particular context. That is my choice as a software developer. Saying that I should not use it in certain ways is like saying a carpenter shouldn't use a saw in certain ways because the manufacturer of the saw doesn't make furniture that way themselves. It simply isn't the manufacturer's call. All that matters is whether the carpenter can use their choice of tools effectively to produce good results.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    23. Re:Exceptions! by Anonymous Coward · · Score: 0

      This conversation is long dead, but I would like for you to know that I almost golf clapped while reading this.

      The word "owned" comes to mind.

  37. Goals, motivation, and good music by Shazow · · Score: 3, Insightful

    So far I like mr_mischief's reply best. Aside from that, here's what keeps me on track:

    • Triangulate. A common mistake I see that produces bad code is people assuming that their code will be used for one thing and one thing always. That is almost never the case, unless you have the time, resources, and naivety to write code from scratch for every project. Try to see beyond the original assignment; set multiple scenarios and applications to your code, and try to fulfill as many of them as you can. Unification is good, and specialization is good--learn when to pick each end of the spectrum.
    • Take pride. It's easy to come up with a 15 if-statement hack, but you'll always save more time in the long run if you spend that extra 15-30 min doing research on how to solve your problem elegantly. If you can't spare the time, do your best to isolate the hacks (such as into their own helper methods) so that you can come back later and replace them with something more sensible. Avoid duplicating code, avoid creating deep chains of method calls, avoid complex undocumented code (if you must write complex code, document what it does so you can keep skimming). In general, try to write beautiful code--something you'd want to paste to your friend, so maybe he can learn a thing or two.
    • Music. When you reach a certain level of confidence that lets you build a flow, try immersing yourself in some good music. For me, listening to The Knife or Justice can significantly enhance my productivity and artistic spirit. Find what works for you.

    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. Re:Goals, motivation, and good music by Anonymous Coward · · Score: 0

      +1 Justice

  38. Avoid reading Slashdot by vjl · · Score: 1

    Actually, seriously, avoid distractions while programming, including reading this site. Set your e.mail to check once per hour, or simply turn it off to begin with. Don't burden yourself with making a certain "quota" of programming lines per day; some days you'll crank out a lot of code, other days will be more idea-focused and less code-focused

    Listen to what your users want in a program; don't talk techno-babble to them, but instead watch how their workflow goes, and understand the problem your program is meant to solve. Listen to their feedback; though you may think your user interface is easy to grasp, if they don't, then it really isn't.

    The single most important rule a good programmer needs to learn: Don't have an ego; be proud of your work, yes, but never get such a big head about being a programmer that you forget the people you are writing the programs for.

    HTH, /vjl/

  39. One GNU Way. by Anonymous Coward · · Score: 0

    "What To Do Right As a New Programmer? "

    Donate everything to the GPL.

  40. Three months later by /dev/trash · · Score: 1

    Be fired because no real work was done.

  41. Business Experience by Anonymous Coward · · Score: 0

    the last 3 years of support desk gives me the business sense to know the environment I'll be coding for

    That right there is the most important thing, imo. Assuming you're familiar with have done some coding before (with any language and any tools) then I can say you'll be able to learn the technical details and get up to speed a lot more quickly than someone with the technical skill that has to learn the business and all its particulars. Back in my first job when I ended up doing a lot of in house coding for a locally owned industrial distributor, probably the best thing I had going for me wasn't my fancy new IT degree but the years of experience I had working there part time both out back in the warehouse and later in the office.

  42. Dude he's a new coder. He'll be doing maint. by HornWumpus · · Score: 1

    Seriously new coders should ALWAYS be stuck on maintenance for few years.

    Nothing will make you write cleaner code then maintaining a plumbers (coders) nightmare.

    There is nothing worse the a brand spanking new 'super genius' coder for producing crap code. Not always but usually.

    --
    John McAfee 'It was like that time I hired that Bangkok prostitute; to do my taxes, while I fucked my accountant'
  43. Learn by example by Repton · · Score: 5, Funny

    1. Read The Daily WTF. 2. Don't do that.

    --
    Repton.
    They say that only an experienced wizard can do the tengu shuffle.
    1. Re:Learn by example by fxkr · · Score: 1

      1. Read The Daily WTF. 2. Don't do that.

      3. Profit. How could you forget that?

  44. App Dey? by bsDaemon · · Score: 1

    What the fuck is an App Dey?

    Reminder: most languages are case sensitive. Likewise, pointers reference objects in the computer's memory, not your own -- so make sure you spell them right.

    1. Re:App Dey? by the-matt-mobile · · Score: 1

      Funny that you mention case-sensitivity. Other than VB, T-SQL, and Pascal, I don't know of any common languages that are case-insensitive. Kind-of a shame really.

    2. Re:App Dey? by basiles · · Score: 1

      Lisp & Scheme are case insensitive.

    3. Re:App Dey? by I+cant+believe+its+n · · Score: 1

      dON't yOU MeAn lISp anD SchEMe?

      --
      She made the willows dance
    4. Re:App Dey? by ozphx · · Score: 1

      A decent IDE will pick this kinda shit up for you anyway.

      If C#/VB.Net is your bag, make sure you pick up Resharper..

      --
      3laws: No freebies, no backsies, GTFO.
  45. Personal stuff by Anonymous Coward · · Score: 0

    Don't whine, but do ask questions if you are stuck.
    Don't be attached to your code.
    Walk away from time to time; drinking water helps with this.

  46. Orion Blastar's programming habbits by Orion+Blastar · · Score: 1

    #1 For every start you put in an end, for every open bracket you put in a closed bracket, etc.

    #2 For every object you use or open, you close it and free up the memory.

    #3 Comments are your friends, use lots of them.

    #4 Stick to the naming convention your company uses, like global variables begin with a "g" and integers begin with an "i" so a global counter variable is named as "gi_count" and a local counter is "i_count" or whatever your company says to use.

    #5 Before you start to program, do research, analysis, and design, do psuedocode and flowcharts if you can they will help you out later, only then do you write code when all of that is done first.

    #6 Work as a team, get a coworker to look over your code for mistakes and you do the same for him/her sometimes you cannot see mistakes in your own code, get help.

    #7 Security should be built into coding, always check variables for buffer overflows and set and enforce limits in length of variables.

    #8 Assume that users will type in characters in number only fields, and enter drive names that do not exist and error trap for that. Check any formula that uses division to see if the bottom is a zero and check for negative numbers before you do a square root and trap for those as well.

    #9 Learn to think like a user, they won't know what you know. Think like someone who doesn't know how to program and then use your programs and see what happens. Then you can spot things a programmer would often miss or not see.

    #10 The help desk is your friend, but get the correct error message and things the user did before the error happened to locate in your code where the problem is, if not, you'll have to play as Sherlock Holmes and figure out the mystery.

    --
    Remember, Slashdot does not have a -1 disagree moderation, and no, troll, flamebait, and overrated are not substitutes.
    1. Re:Orion Blastar's programming habbits by D4C5CE · · Score: 1

      #9 Learn to think like a user

      the last 3 years of support desk

      Given (t)his experience I think he's "painfully" aware of that already.

    2. Re:Orion Blastar's programming habbits by Orion+Blastar · · Score: 1

      Thank you Captain Obvious, what would we programmers do without you? :)

      They are my programming habits, not his, so I wrote what I knew not what he knows.

      --
      Remember, Slashdot does not have a -1 disagree moderation, and no, troll, flamebait, and overrated are not substitutes.
    3. Re:Orion Blastar's programming habbits by camperdave · · Score: 1

      #5 Before you start to program, do research, analysis, and design, do psuedocode and flowcharts if you can they will help you out later, only then do you write code when all of that is done first.

      #5.1 Keep all this analysis, flow charts and pseudo-code. Comments are fine and all, but sometimes being able to see a picture of why you're doing what your doing is far better.

      --
      When our name is on the back of your car, we're behind you all the way!
  47. Don't Get Attached to Your Code by Comatose51 · · Score: 1

    Just because you wrote it, doesn't mean it's worth keeping. I don't know if your company does any sort of code review. If someone points out where your written code could be made better, don't get defensive about it. If they're right, they're right. The real gem is when someone points out how you can do the same or more by deleting some code. In any case, expect there to be drafts of code and rewrites. The hope is that once you've become more proficient and experience there would be less drafts and rewrites.

    --
    EvilCON - Made Famous by /.
  48. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  49. 4 Steps by Anonymous Coward · · Score: 0

    1) Encourage employer to go open source

    2) Start sourceforge project to entice free labor

    3) ?

    4) Profit.

  50. Comment Code by Anonymous Coward · · Score: 0

    You may not know what that means now, but you definitely need to get into the habit of doing it now.

    As long as you are able to code something, even if it has some bugs in it, but you document it, then it will make life much easier for you and everyone else down the road.

    Too many people seem to think their code is bullet proof and they do not comment their code, which leads to many, many problems down the road.

    Understand that it may not always be just YOUR code working in a system, so documentation helps everyone understand what's happening when it hits the fan.

  51. I recommend by aaron007 · · Score: 1
  52. Design Patterns by asylumx · · Score: 1

    Please read "Design Patterns" by the gang of four. (http://en.wikipedia.org/wiki/Design_Patterns)

  53. Welcome to the Tower of Babel by Louis+Savain · · Score: 1

    Good luck. You are about to come face to face with thousands of programming languages, operating systems, dev tools and conflicting advice from fellow programmers who are fanatical about one approach or another. Get ready for the Forth fanatics, the stateless functional programming lunatics, the autistic OOP multitude, the data flow slackers, the state machine mechanics, the immature script kiddies, the deranged hackers, the GOTO alarmists, the proper art of commenting freaks and the multithreading mutants from Mars. Did I mention atheists, vegetarians, punk rockers and libertarians? Abandon all hope of sanity as you take your first fateful steps into the mental asylum from hell.

    1. Re:Welcome to the Tower of Babel by Anonymous Coward · · Score: 0

      and beware most of the cynics with empty promises.

      the evening come,
      their dining done,
      the feast of the cynics
      on the hopeful young

  54. Continuous Improvement by speby · · Score: 1

    Others here have commented that as a noob, your code will likely suck. Even a few months from you, you'll reflect back or encounter code you wrote and think about how much it sucks. The one tenant I can tell you is that code is never truly final. I mean 'final' in the sense that any product you're building (a web app or thick client or whatever) is never final because if people are using it, they'll always want new versions and updates that do things differently and better. This phenomenon gives you (and your product team) a chance to make things better, both in existing code/features and new things as well. Secondly, you should try to learn and focus on the art of testing. Just like when you were learning mathematics in high school algebra and calculus and later numerical analysis or number theory or whatever in college, your instructors always want you to 'check your work.' In the simplest case, that's taking your 'final answer' and plugging it back in for 'X' and solving to see if you actually got the equation right. Think of testing like this: a balance of both sides of an equals sign. Otherwise, be a sponge and read, listen, and absorb.

  55. ! slashdot by BenBoy · · Score: 1

    Don't waste your work time reading slashdot ...

  56. Indeed, what company is this? by Anonymous Coward · · Score: 0

    No offense to Mr. App Dey, but what company takes helpdesk people and sticks them in engineering? We need to know what products to avoid...

  57. Watch out for the groupies by Anonymous Coward · · Score: 0

    They're fun, but can cause you trouble later.

  58. Indie whore by Anonymous Coward · · Score: 0

    What the fuck are you talking about developing "a flow"? Jesus fucking Christ just listen to whatever music you want to and don't listen to elitest music whores like the parent here. Listen to country, listen to Wierd Al, listen to Michael Bolton, whatever the fuck helps you. Just don't listen to people like the parent poster that religiously reads pitchforkmedia.com every fucking day and jerks off all over the newest "indie" record.

  59. Some tips from a fellow newbie by Anonymous Coward · · Score: 0

    1. Always blame the latest bugs, and bad code on the last developer that left the team.

    2. Document as little as possible, as it takes away from your time coding.

    3. Leave a lot of crumbs from chips, and snacks around your keyboard and mouse. It will prevent people from using your computer.

    4. Don't use deodorant as it will prevent people from bugging you or asking questions unless they truly are urgent.

    5. Feel free to sit down and chat with the senior developers when they look busy.

    6. Don't worry about the readability of your code since nobody will really look at it again.

  60. step away from the compiler by pantalanaga · · Score: 1

    go get a degree in CS before you get anywhere near a compiler. That should give you your best practices and keep you from doing anything stupid.

    1. Re:step away from the compiler by gnupun · · Score: 0

      worst...advice...ever

  61. Anonymous Coward by Anonymous Coward · · Score: 0

    One specific I picked up, put your constants on the left hand side of your comparison to avoid accidentally typing '=' instead of '=='. For example:

    handle = new MyClass();
    if(NULL == handle) { ...

    If you screw up and type '=' you will generate a compiler error.

    1. Re:Anonymous Coward by Anonymous Coward · · Score: 0

      I think that is the dumbest fucking thing, and is only done by noobs.

  62. Don't Rack your Brain by DavidD_CA · · Score: 1

    Quite often (more often than I would care to admit), I reach a roadblock on how to do something the right way. I can't quite wrap my brain around what the best method or algorhythm should be, or what the interface should look like, the workflow, etc.

    Sometimes I'll spend WAY too long racking my brain for a solution.

    What I've learned is that if I just distract myself for a short period of time, by doing something else like taking a lunch break, when I return to the problem the solution will come to me almost right away.

    --
    -David
  63. Document everything by Lost+Engineer · · Score: 1

    Even if nobody else has to deal with it ever you will forget how stuff works years from now.

    Learn who likes helping people and who doesn't. Then, don't overuse the helpful people and piss them off. If you need to bug the unhelpful people do so by email. Corollary: always be willing to help, but don't be afraid to say: "this has to wait."

  64. Think about error checking! by B1 · · Score: 1

    It's one thing to write code that follows a sequence of steps and generates correct output. It's quite another thing to write robust code that handles problems gracefully.

    In the real world, problems are inevitable. For example:

    • Database servers might be offline or unreachable (or misconfigured)
    • Resource exhaustion issues (e.g. no free memory, filesystem full, etc)
    • Network issues (e.g. cannot connect to remote server, DNS failure, web services, etc). Data transfers could be unexpectedly slow.
    • Your output file might already exist from a previous run of the program
    • Your configuration file might be invalid or incomplete (BTW: configuration files names don't end with .cpp... )
    • Your user might interrupt the program in the middle of a run, after it's created a partial output file (because it looked like it was stuck)
    • Your user might run two instances of the program at the same time. Will they coexist peacefully, especially if they have to share data or resources?

    As you design and write your code, try to anticipate the problems you'll have to deal with, and the things that could go wrong. Be religious about error checking and handling -- sure, it's tedious, but it makes your software dependable and easier to support once it hits production. Unless you like 3AM wakeup calls from the guys in network.

    You may not be able to recover or work around all problems, but your code should at least handle them gracefully--even if that simply means cleaning up, logging an error, and alerting the operator for further troubleshooting.

  65. Decline and Fall of an American Programmer by Anonymous Coward · · Score: 0

    Outsource it to India.

  66. Worst commenting i ever saw by grahamsz · · Score: 1

    I once inherited a Win 3.x device driver that was written entirely in asm. Several hundred k of raw code.

    At a first glance it looked good and well commented, in fact virtually every line was commented.

    However on closer inspection i found lines like

    djnz ax loop: ;; Decrement the register ax and jumpt to loop: if not zero

    First and last x86 project i ever touched

    1. Re:Worst commenting i ever saw by FilterMapReduce · · Score: 3, Insightful

      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.)

    2. Re:Worst commenting i ever saw by azgard · · Score: 2, Insightful

      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.

    3. Re:Worst commenting i ever saw by mrbobjoe · · Score: 1

      Like I said, who can look at "djnz" and remember what it means?

      Good God, man, why do you think they're called mnemonics!

    4. Re:Worst commenting i ever saw by johannesg · · Score: 1

      DJNZ is completely obvious actually: it means "Decrease (B), Jump (if) Not Zero" and will decrease the B register, and jump to the specified label if it is not zero.

      And I expect all of you to have it, and the other Z80 mnemonics, memorized next week. There will be a test. And then there will be cake.

    5. Re:Worst commenting i ever saw by KC1P · · Score: 2, Insightful

      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.

    6. Re:Worst commenting i ever saw by Anonymous Coward · · Score: 0

      It's mnemonic - djnz == decrement and jump if not zero.
      (Yes I did have to look it up, because I have never coded for that particular cpu, but I did know that jnz == jump if not zero on x86 cpus without looking).

      And no, experienced programmers do not comment every single line. If they did that, they would lose their train of thoughts. When we see a program where every single line is commented, we take this as a very strong hint that whoever wrote it did not know what he was doing. What we expect to see is comments explaining what gets done at a high level, not at the individual instruction level.

    7. Re:Worst commenting i ever saw by hengdi · · Score: 1

      I did some 15 years of assembly code from the early eighties, and yes, it does tend to be commented on line by line. Not because you can't remember what 'dbnz' means, but because the code itself doesn''t read very well. I might say x=(2*(5+y))-z in C but that'll look like an awful lot of assembly, and you needed a lot of comments to understand what was going.

      Also, it was common to have instruction tricks; for example, on a Z80 CPU I used to use XOR A,A to set the accumulator to 0. Not obvious to anybody reading the code.

      Finally, comments didn't get in the way of the code; typically, from left to right, you would have a first column of labels, then a column of instructions, then a column on operands, then a column of comments:

      loop: LD A,15 ;setup loop counter

      Oh, those were the days....

    8. Re:Worst commenting i ever saw by Count+Fenring · · Score: 1

      Will those of us who fail get cake as well?

      Waaaaait. I don't believe in your cake.

      Your cake, sir/madam, is a lie.

    9. Re:Worst commenting i ever saw by Anonymous Coward · · Score: 0

      Before we called stuff such as 'djnz' a 'command', we used to call it a 'MNEMONIC' - that is, something which is far easier to remember than the hexadecimal code for that instruction. And the hexadecimal code was just there because it is easier to remember than the binary opcode. So if you cannot remember djnz is "decrement and jump if non-zero" you have been spoiled ;)

    10. Re:Worst commenting i ever saw by Anonymous Coward · · Score: 0

      If you don't even know the language, you probably shouldn't be the one trying to maintain the program.

      No, not even for assembler should you use something like

      inc ax ; increment ax

      But rather

      inc ax ; column+=1

      or even

      inc ax ; one column to the right

      That ax is incremented is already visible to anyone who knows the language. Why ax is incremented is not. What ax contains is not.

    11. Re:Worst commenting i ever saw by scsirob · · Score: 1

      If someone doesn't know what 'DJNZ' means in an assembly language project, he should not be allowed to work on that project. DJNZ is a Z-80 CPU instruction and stands for "Decrement, Jump if Not Zero", and is a great way to set up a loop in Z-80 assembly language.

      --
      To Terminate, or not to Terminate, that's the question - SCSIROB
    12. Re:Worst commenting i ever saw by devonbowen · · Score: 1

      For cake, I'd expect you to have the opcodes memorized, too. At least if it's good cake. LD HL... 0x21... LD A,A... 0x7F... And I haven't coded Z80 in 20 years. ;-)

      Devon

    13. Re:Worst commenting i ever saw by grahamsz · · Score: 1

      Maybe i've butchered it in my memory. I'm certainly not an assembly coder, i've done small projects in 8051 and x86 before - but being thrown into a windows device driver after the original programmer had quit was really a baptism of fire.

      While i never tried altering it, I was able to explain one of the weird behaviors it had so we could work around it in higher level code. Being 17 at the time, I was pretty happy.

    14. Re:Worst commenting i ever saw by johannesg · · Score: 1

      Funny story: I got my current job by impressing an interviewer by coding a bit of Z80 assembly on paper, and then adding the hexcodes for good measure. So yes, I have them optimized. Maybe not all, but give me a piece of paper and I can reconstructed a substantial part of the entire set.

      I used to do fMSX Amiga, which is an MSX emulator for the Amiga. Since MSX had a Z80 I had plenty of opportunity to get acquainted with that particular instruction set, and being able to read hex-dumps was actually quite a benefit during development of the emulator.

    15. Re:Worst commenting i ever saw by 19thNervousBreakdown · · Score: 1

      Absolutely. I've found it's incredibly helpful to comment the everloving crap out of code if I'm having a hard time writing it. Since I absolutely, positively will not allow myself to write redundant, obvious, or incorrect comments, and must explain exactly why a given chunk of code is being written, by the time I'm done I have a very thorough explanation of exactly how to do what I didn't understand at the beginning, and maybe didn't even understand as I was doing it. From there it's just an iterative process of making the code more readable and comments less unnecessarily verbose, specifically by eliminating duplicated code and giving an accurate but succinct overview of the whole problem at the top.

      By breaking down a problem into small enough pieces, the solution comes out. Without the ridiculously thorough documentation, sometimes you just can't hold enough of a large problem in your head to break it down into small, workable problems. Self-commenting code helps, but good, plain English comments can help more.

      I agree though. Good programmers don't comment every single line. If you see a huge swath of un-commented code, and it's by a good programmer, you can guess that it's a common design/algorithm, and you should know it.

      A good programmer is a lot like a good driver. Maybe they could drive fast, but they don't. That's why they don't get into accidents.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    16. Re:Worst commenting i ever saw by nerdguy0 · · Score: 1

      FYI, DJNZ is a Z80 instruction for Decrement and Jump if Not-Zero; very useful for doing loops.

      --
      "In /dev/null no one can hear you stream."
  67. Think twice, code once. by Timothy+Brownawell · · Score: 1

    Think before you code. What are you doing? Why are you doing it? What rules are likely to change? What data structures best represent what whatever you're coding is/does?

    Get familiar with data structures. What is a pointer? What is the difference between pass-by-value and pass-by-reference? What is a dictionary/map/associative array/indexed table? What's the difference between is-a and has-a? What is big-O notation?

    Learn to map your assignments to data structures and algorithms, independent of your programming language. Then translate that into the language; if it doesn't translate cleanly, figure out why it doesn't translate, and try a different structure/algorithm. Being familiar with your language will help here, as it will be easier to see immediately what maps to the language well, or even when a somewhat suboptimal design (say, XML) may allow massively simpler code due to standard library support. Being somewhat familiar with other (completely different, say Ocaml vs. C) languages will help you see more alternatives that you can choose from.

    If your application uses SQL to talk to a database (as opposed to being forced thru some abstraction layer), learn SQL beyond the minimum required. Pushing certain logic into the queries (with proper indexes) can be a massive speedup, pushing the wrong logic will cause problems. This is on the same order as choosing the right algorithm based on it's big-O speed, rather than silly little things like loop unrolling and hand-coding replacements for too-slow library functions.

  68. work smarter, not harder by Anonymous Coward · · Score: 0

    Master unit testing. It will keep you from screwing up the system.

    Don't code anything until you've confirmed your in-house libraries and open source libraries don't already have the solution. There is very little that hasn't already been done. You'll score more points by saving time that being a code master. Most of the time nobody reads the code, but they certainly read the time sheets and the budgets.

    Solve your problems on paper or a whiteboard before you code (or search those libraries). You've got to know where you're heading.

    Break large problems into small solvable units. If you have a block of code that is more than you can view at once on screen, you haven't broken the problem out into enough granularity.

    Prototype and refactor. Repeat.

  69. No!! by Anonymous Coward · · Score: 0

    Don't ask about programming advice on Slashdot! Over the years I never read more moronic "advice" on what constitutes good programming than the idiotic majority of Slashdot. Especially the "toy" language lovers, the Java/Perl/Ruby/Phyton/VB/C# crowd. The script kiddie whannabes that think the crap they churn out is real code. The same dweebs that think all programming is like on their beloved PC/MAC/Linux box. The ones that think real-time means really, really fast. The ones think fault tolerant means if your code has a bug, it should crash, and deservedly so! They believe recursion is a cool toy--use it everywhere! There is so much memory on ALL computer now that malloc can never fell (no need to check those return values!!). That real languages like C and C++ are too hard for them to understand (which is the languages fault). They're still trying to figure out what a pointer is. Oh, and all machines are ASCII, bytes are always 8-bits, int is always 32-bits, Unicode is 16-bits, and endian, why that is just a ghost story meant to frighten children. And Java is portable.

    1. Re:No!! by pijokela · · Score: 1

      Don't ask about programming advice on Slashdot!

      Well, I agree with the start of your post wholeheartedly. The people on this thread come from so varied programming environments that most of the advice is useless in any one environment.

      But then you go on a weird vendetta against some languages. Have fun writing business web applications with c or c++. There are different languages for different stuff.

    2. Re:No!! by Anonymous Coward · · Score: 0

      Agreed, but you've got these moron that try to use their pet languages for everything. I write real-time, embedded systems. I work with people who wholeheartedly think that Java or even Perl would be just nifty to use. They don't even grasp the concept of determinism. Then we've got people just out of college who only ever did Java. They went into programming because they played with Java as home and thought, "gee, this programming stuff is easy!" Then, they get out into the real world and panic because 1) other languages don't hold your hand, 2) don't have a library for everything under the sun, or 3) they were not taught Comp. Sci. or Software Eng. They were taught Java. They are a deer in head lights when asked to write a simple device driver. The reality is they don't have an aptitude for software engineering, they could just write some "neat" stuff in Java. They can't do the job, but I'm stuck trying to teach them. So, yeah, sorry, I am a little bitter. I just showed two clueless co-workers how to convert a string of ascii digits to an integer manually (because they thought strtol, et. al. were "broken"). They acted like it was rocket science or something. I mean, my God, I was doing this stuff 30 some years ago when I was around 8! It's not that they are stupid. They just don't have the aptitude or education (as I ranted above).

  70. Some tips by tumblebug · · Score: 1

    Some stuff I've learned over the years:

    1. Learn to use Google and techie-based forums effectively for the language(s) you are using - 99 times out of 100 someone else has had the same problem you are facing and has solved it, and posted the solution

    2. Get in good with your network admin - this is a must if you need network stuff done in a hurry!

    3. Know when to code fast and ugly, and when to code elegant - whats the point in spending 2 hours to code the elegant solution when you KNOW your code is only going to be run once, and the 10 minute ugly version with hardcoded everything will work just as well?

    4. When writing classes/methods/etc, think about the programmer who comes after you in 3/6/12/18 weeks/months/years time and has to modify what you've done. In most cases, it will be you and then you have to re-figure out what you did and why you did it that way. Make method names and variable names consistent and easy to understand, use the datatype of the variable in the name, etc...simple stuff like that helps enormously. The coding books can teach that stuff.

    5. Linked to point 4....Comment, Comment, Comment! But do it wisely - dont comment each and every line but comment a "block" of codelines. Describe what the block is doing, and if its relevant, WHY you chose to code that way - there may be a certain reason to do with the database maybe, or with the network setup. It explains to the reader why the code reads the way it does. It keeps down the "WTF/min" count!

    6. Dont refactor just 'cos you can - quite often you will come back to a piece of your code to fix a bug, and you'll find that since you wrote it, you've learned more stuff that you know will make this piece of code fly, but it involves major rework to the code. Resist the temptation (and the temptation will be there, believe me) to do the major rework! Your boss is expecting you to fix the bug, not re-invent the entire method, and if you post a fix time of 3 hours to a job that should have taken your 15 minutes...you wont win yourself friends with your boss. Plus you are introducing a new set of code to the system that requires testing, and all the stuff that goes along with that...

    7. Bide your time - the way to get onto the big, interesting projects is to do the drudgey hack work in the beginning. Do the hack work well - keep your code efficent, relatively bug free, get it done ontime and the interesting stuff will come to you.

    8. Bugs happen - just like life: make a mistake, learn from it, and try not to let it happen again. It is very rare that you will have a program run bug-free first time...and the more lines of code you have, the higher the chance it wont run first-time.

    I'm sure there's more stuff, but you can figure it out yourself ;)

  71. Teach Yourself Programming in Ten Years by Rich+Dougherty · · Score: 1

    Peter Norvig has a thoughtful list of suggestions.

  72. (1) "Don't fuck up", (2) mentor, (3) balance by zurtle · · Score: 2, Insightful
    1. This is infamous amongst football [soccer] referees as a debrief to the assistants before the game that is to be avoided.

      Same could go for software development.

    2. I guess you also mean what you need to do to make your career more prosperous? The best thing that I did was locate a mentor. Ask older guys who helped them the most, look to family friends. It doesn't have to be a technological mentor, just someone who can help you over the usual stumbling blocks anyone encounters in a new job.
    3. I would also recommend getting your life balance right sooner rather than later. I've known a few guys who worked excessively long hours and ended up hating their jobs and walking away from software development. Don't be like that! Again, a mentor can be useful in this regard.
    --
    Couldn't stand the weather
  73. a couple things by blackcoot · · Score: 2, Insightful

    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...)

    1. Re:a couple things by Kjella · · Score: 2, Insightful

      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)

      Both focus on yourself, it could use a team variation, like: "A truly clever developer will create code so easy to understand that a less than average developer could debug it." Hmm... I actually like that so much, I'll put it in my sig.

      --
      Live today, because you never know what tomorrow brings
  74. Backup! by gatra · · Score: 1

    Always have a backup!
    make sure that is you screw up, you can go back to a working previous version.
    If you work with databases, backup the databases too.

  75. Programmers thing differently to mortals by Peter+(Professor)+Fo · · Score: 1
    As clocks go "tick" and cows go "moo" so programmers go "What could possibly go wrong".

    By practising this mantra you'll soon be spotting the gaps in other people's thoughts and specifications, which in turn will make you into one of those awkward people who can simultaneously (a)hold up the slip-shod enthusiasts and (b)find a better, more elegant, solution AFTER THINKING ABOUT it.

    A good programmer has to be a mental athlete. Develop your powers of concentration and insist on a working environment where you can think in peace and are not expected to work flat-out for hours on end without a recovery period.

  76. Look for patterns by thePowerOfGrayskull · · Score: 2, Interesting
    You'll find that the ability to program and troubleshoot well comes down to being able to see patterns. That applies at all levels. Whether you're looking to find the root cause of an impossible-to-reproduce error, look for any possible pattern or commonality in the reports of the issue.

    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...)

    1. Re:Look for patterns by thePowerOfGrayskull · · Score: 1

      Ack - completely messed up that first paragraph. Still, if you just skim it quickly and move on to the rest, I /think/ I got the point out. Clearly it's time to sleep...

  77. Don't copy and paste by small_axe · · Score: 1

    Please, please, please, no matter how late it is, no matter how much of a rush you're in, don't copy and paste blocks of code when you know deep down you should be generalizing and rewriting that block as a method or function somewhere for re-use. I can't even begin to count how many hours my team has wasted tracking down and fixing the same bugs that were pasted all over the place in legacy code.

  78. Goto is good, gosub is better by TiggertheMad · · Score: 3, Funny

    like ? leave_alone : ;

    There, fixed it for you.

    --

    HA! I just wasted some of your bandwidth with a frivolous sig!
    1. Re:Goto is good, gosub is better by wumpus188 · · Score: 1

      like ? leave_alone : (void)0 ;

      There, fixed it for you.

    2. Re:Goto is good, gosub is better by JohanSteyn · · Score: 1

      Another fix, with corrected logic and using CamelCase... ('cos some programmers dig it like that)

          likeIt ? useIt : leaveItAlone;

    3. Re:Goto is good, gosub is better by jacquesm · · Score: 1

      To quote a certain Andrew T.: "ICantReadThis".

  79. Go open source by chx1975 · · Score: 1

    Pick a well knwon, good quality open source project. Read documentation, experiment with the product and then read the code. Pick a minor bug from the bugtracker and try to fix it. Ask for help if you can't. You will find out that those who try to contribute get help. Repeat and rinse. You will get better. Nothing helps more than writing peer reviewed code.

  80. suggestions by Anonymous Coward · · Score: 0

    1. Document everything. The consolutants where I work produced some sloppy code, but did a fair job documenting what most functions did. When it came time to port it to a new architecture and do some general cleanup, this head start was invaluable.

    2. Don't fall for fads. If you're in web development, remember that 80% of the market uses IE. Don't overcomplicate online applications with garbage like CSS and AJAX. If you have to contantly reload or need CSS to be usable, your design is broken.

    3. Write code that can stand alone. One thing I curse the consultants for is the use of global variables, which allowed them to setup processes that were all or nothing in a very specific order. Much of our cleanup has been decoupling these functions to recover from failures.

    4. For the love of God, implement some sort of error handling. I pass in a list object to every function, so I can follow what happened and only have to figure out the root cause.

  81. Write it write the first time by www.sorehands.com · · Score: 1

    If you write it right the first time, it takes less time to debug later. Measure twice, cut once. It takes much more time to find a bug then to write the code.

    Be a real programmer. http://www.sorehands.com/humor/real1.htm

  82. In the immortal words of my boss... by lordsid · · Score: 1

    The key to being a good programmer is a careful balance of laziness, hubris and impatience.

    --
    IMAGE VERIFICATION IS EVIL!
  83. Re:STOP: Get out NOW !! by pegdhcp · · Score: 1

    No, he is not wasting away his life, he is trying to join dreamers who are trying to change Second Law of Thermodynamics. When he understood that unfortunately, that was just a dream, -sorry R.E.M. was on the radio :)- it will be long past the point of no return....

  84. Re:STOP: Get out NOW !! by Anonymous Coward · · Score: 0

    "My code isn't the reason it crashed! It was the Windows!"

  85. Use a slow machine by www.sorehands.com · · Score: 4, Insightful

    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.

    1. Re:Use a slow machine by Anonymous Coward · · Score: 0

      You mean for Office, anymore.

      There, fixed it for you.

    2. Re:Use a slow machine by pjt33 · · Score: 1

      Use a slow machine with little free memory to test your code.

      Or, in other words, use Eclipse.

    3. Re:Use a slow machine by ishark · · Score: 1

      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. This is probably the best message I've read on slashdot in the last 6 months....

    4. Re:Use a slow machine by red_blue_yellow · · Score: 1

      Use a slow machine with little free memory to test your code.

      Or, in other words, use Eclipse.

      Hah! Apparently you've never used Netbeans!

      --
      A neutral communications medium is essential. It is the basis of science, by which humankind should decide what is true.
    5. Re:Use a slow machine by Anonymous Coward · · Score: 0

      Better yet, see if you can't use a VM.
      In fact if you have any control your testing and build machines should be VMs, that way ytou can be certain of a consistent setup.

    6. Re:Use a slow machine by Anonymous Coward · · Score: 0

      Hey, I do that at work!

      VS2008 on a machine with 1.5Gb with 20 projects loaded and referencing each other... runs like a pig and can't open any visual designers unless every project is open at once.

      And VB.net syntax makes me want to kill myself - but that's another story for another time

    7. Re:Use a slow machine by Anonymous Coward · · Score: 0

      it also helps you look busy for longer...

  86. That code is awful. Think of others. by Max+Littlemore · · Score: 1

    $foo = isset($_GET['id']) ? sanitize($_GET['id']) : 0;

    Look buddy, I got nothing against the ? : ternary, but the line ends with 0; which looks at best like someone with a droopy eye lookingh surprised and at worst someone bawling their eyes out. If you read code like that all day, you will get very upset. It's bad enough that so many lines of code end in );

    Seriously, the one important piece of advice I have for anyone who is gouing to write code in one of these langauges with brackets and semi colons all over the place is this: the language is designed to briong you down, you gotta work hard to make it happy. That is why a good for loop goes like this:

    int i;

    for (;
    // that's happy

    Thingy.condition()

    ;)

    // more happiness

    i += i &lt; thing.number() ?

    1:
    // not happy as such, but kind of cute

    something()

    ;
    // avoid closing brackets followed by semi colons at all costs.

    The trick is to remember that someone will have to maintain the code after you. It is your duty to make reading the code a happy experience.

    --
    I don't therefore I'm not.
  87. Don't reinvent the wheel... by billybob_jcv · · Score: 1

    ...but also know where your code came from. There are tons of code snippets, modules, libraries, etc available for reuse. Reusing code is good - as long as you know what you're getting. No, you probably don't need to code your own sort routines - but you should know how the sort routine you're using works, its limitations and its advantages.

    Don't status everything at "80% Complete" - your manager knows better, and you are going to end up right back on the support desk (or out on your ass) if the team can't trust you. Raising your hand and saying you need help is better than missing your milestone and leaving the rest of the team high & dry.

    Always remember that your beautiful code is NOT why the company is in business. The application is being built to *do* something - to help execute a business process, or control a machine or simply entertain someone - but it has some purpose. Even if you work for a commercial software vendor and your code is the product being sold - it is still being built to do something for the customers. Don't lose sight of that purpose - having working code that is reliable & maintainable really is more important than using the latest nightly build of the ubergeek framework.

    Finally, communicate with your teammates. Don't barricade yourself inside your cubicle for months writing your code masterpiece only to find out that the requirements changed 3 weeks ago, or that the guy in the cubicle next to you already has a function that does exactly what you need in the project he finished last month. The team CAN accomplish more than the sum of the individuals - if the team really acts as a team.
                       

  88. My life's lessons. by Anonymous Coward · · Score: 0

    1. Learn how to use polymorphism properly, it can be a very powerful tool when used correctly, but can make a huge mess of your program architecture when used incorrectly. What is the difference between an 'is-a' and a 'has-a' relationship? When do you use one or the other?

    2. Learn proper functional decomposition. Breaking your problem down into small pieces is important for solving the problem one bit at a time (however, they have to work together well when you put it all together!). The computer science mantra is 'divide and conquer' for a reason.

    3. Learn how to do threading/locks/synchronization correctly. You will make mistakes, and they will be hard to fix. Threading bugs are hard to prove they exist, they are hard to diagnose, they are hard to fix, and they are hard to prove that they are fixed. Threading/sychronization isn't as simple as wrapping a mutex around parts of your code, especially if you have threads doing work that is depended on by other threads.

    4. Regular expressions make quick work of string processing, in a concise, easy to maintain form. Take the time to learn them.

    5. Security is hard. Very hard. I suggest you first learn how hard it is, so that you can understand /why/ you need to be very careful. Then you can learn about /how/ to do it correctly. My favorite example of this is "RSA blinding" - if you can watch the power consumption of a cpu as it runs a cheap implementation of RSA, you can see it spike power draw when doing parts of the algorithm. You can then use the length of those spikes to get an idea of the approximate value of the inputs to that algorithm, where the inputs are chunks of the key. Now, you can reduce your brute-search attack because you know that some keys are unlikely.

  89. First step: by Anonymous Coward · · Score: 0

    Let me know who you work for so I can avoid a company that is now promoting its help desk employees to programmers... (cheaper than outsourcing I guess?)

  90. Best advice by Anonymous Coward · · Score: 0

    My best advice would be to never listen to the Support Desk people, they know absolutely nothing.

  91. Education by JustNiz · · Score: 2, Insightful

    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.

    1. Re:Education by Almahtar · · Score: 1

      Fuck college. I learned more with curiosity + search engines in Jr. High and Elementary school than college ever came close to.

    2. Re:Education by Viol8 · · Score: 2, Interesting

      Yeah , of course you did sonny. That'll be why you know all about Phong & gauraud shading, DB normalisation and tuning, digital signal processors, AI vision algorithms, network theory etc.

      Because I did all those for my BSc.

      But i'll admit , if all you ever do is write mickey mouse VB apps for a living you won't need any of the above.

    3. Re:Education by pantalanaga · · Score: 1

      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.

      This is absolutely true. Any 'real' company is going to require a CS or related degree. A good company will also pay for more education, so use it! Anecdotal advice from other engineers, googling, an inquisitive mind, and even experience are no substitutes for understanding the basics of computational theory. As stated in the parent post, if you can't get a whole degree under your belt, at least take a few credits. Your code will be better as a result.

    4. Re:Education by billybob_jcv · · Score: 1

      ...and you certainly learned all you will ever need to know about working in a team, making the move from coder to architect or, God forbid, becoming a manager. Look around your office and find that surly 50-something "programmer" sitting in the cubicle in the far corner. You know, the one who maintains that old COBOL interface that nobody else wants to touch. He doesn't have a degree either. He's bitter as hell because "those damn college kids" keep getting promoted past him.

      He's you in 25 years...

      Do you need a degree to be successful? Of course not. But having a degree might get you in the door a whole lot easier. Why give the recruiter another reason to put your resume in the "No Thanks" pile?

                 

    5. Re:Education by Shados · · Score: 1

      The amusing thing is that DB normalisation is in very, very few CS programs (and when it is, its usually in optional classes), and that by far the majority of people who know it (or well, about 1/2 of the things you mentionned) learned it outside of their degrees. Thats why when you go to virtually any interview to do high end business related programming, the interviewers have to ask you if you know anything at all about databases (especially the theoritical parts): because no one does.

    6. Re:Education by JustNiz · · Score: 1

      Databases were certainly covered in my British CS degree. Maybe its a US thing.

    7. Re:Education by Anonymous Coward · · Score: 0

      Sadly there are lots of people who "learned all that at college" yet can't actually implement any of it. I studied Physics at college, and learned all about phong & gauraud shading, db normalisation and tuning, digital signal processors, network theory, by implementing the code in High school after learning about them from books in a public library. Scan-line raster algorithms, montecarlo raytracing, all that.

      I didn't learn about compilers till college though, when I dated a CS major, but if you're het, that might be difficult. :-)

    8. Re:Education by Almahtar · · Score: 1

      He's you in 25 years...

      No, I have a degree. I just think, in hindsight, it was a meaningless gesture to get one.

    9. Re:Education by Almahtar · · Score: 1

      Oh sure, those things were taught at my Uni. All the kids in the mandatory databases class learned about normalization, how to tell if something's in third normal form, etc.

      I'll bet good money none of them really remember any of that stuff: they learned it for the test because they were forced to, and then forgot.

      I'll admit I forgot a lot of the stuff that I just had to learn solely because some prof wanted me to learn it. I remember almost everything I learned on my own, because I wanted to learn it. And don't be so belittling: we're not talking VB.

      I earned the degree, and looking back I really learned a lot less during college than I did on my own. Motivation and curiosity are amazing teachers.

      The only really new thing college taught me was how to drink. Yay.

  92. Additional Stuff by Borg+Bucolic · · Score: 1

    Besides the things previously mentioned... Plan (or think about) what the finished product is going to look like before you start...... When planning, sometimes a pencil and paper is much more efficient than a keyboard...... Commenting is everything. You would be amazed to find out later, you don't remember your own code....... Be consistent with your styling. Try to follow a standard in convention....... Be a researcher, don't reinvent the wheel. (someone has done it before, and usually better)....... Unless you have a cause, a single stretch of code should not run for pages/screens....... Don't go overboard on breaking up code. That is just as bad........ It is easier do document as you go. The little (but important) things are easy to forget....... Don't assume that input data will always be good data. Consider the results when (and it will) that occurs...... Don't assume any training or intelligence on the part of the end-user. (see previous)

  93. Basics by kylben · · Score: 1
    You know more than you think you do, but usually you know less than you think you do.

    Your co-workers know a lot less than you think they do, but sometimes know a lot more than you think they do

    Your boss knows less about programming than you could ever believe possible, it's not his job

    Take chances, the standards you think your code will be held to are far lower than you've been led to believe

    The standards of correct, well-designed, well-documented, and easily maintainable code are not the standards your customers and your competition hold your product to - software is more than code.

    Hold your own code to higher standards than your boss does, but get it done within the business constraints he sets.

    Be nice to the guy who is maintaining your code.

    Seeking the perfect design is a recipe for disaster.

    Interfaces should be inherited, implementations should be aggregated. Do it the other way around and you're digging a hole you'll never dig out of. Nor will that guy who is maintaining your code.

    Objects do not represent real-world objects, no matter what the books say. Objects either manage state or behavior, not both.

    Code flexibly those aspects likely to change, code rigidly those aspects unlikely to change. Novice programmers get that wrong more often than any other principle.

    Never write code that "you're gonna need someday". That day is likely never come, and when it does, nobody, including you, will remember what you already coded for it. And even if you or they do, it won't be the right approach.

    No principle, including all the ones here, is always true. Never violate them, except when you should.

    --
    Insightful and funny are really the same thing, except one has a punch line.
  94. Learn to learn by edp · · Score: 1

    Ideally, one should have a formal education before writing software professionally--there is a lot of theory that has been figured out that is useful to know in practice. However, given that that is not going to happen, then my advice is to avoid reinventing the wheel, or, worse, inventing a bumpy thing that the car rides on but is slow and inefficient and uncomfortable and breaks from time to time. Collect references where you can look up algorithms and theory--apply what other people have done instead of writing new algorithms. Most programmers' jobs are tailoring known algorithms to current situations, not writing new algorithms.

  95. Two Rules by NicknamesAreStupid · · Score: 2, Insightful

    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.

  96. Every journey begins with a first step by Anonymous Coward · · Score: 1, Interesting

    There have been quite a few good comments here.

    Like:
    -Don't take criticism personally.
    -You aren't your code.

    These are all very good comments. I would also like to point out that you are embarking on a long journey. Your not going to become a great programmer in a year. Not even in 2, 3, or 5 years. But you can improve and progress over time. To do that you should invest time outside of work on improving. I would first concentrate on your first language. After that I would start working on theory and some books like code complete, beautiful code, etc as well as reading programming blogs. There is a lot of crappy stuff out there but in time you'll learn how to sort through it which is a very necessary skill you'll need in general.

    For theory books you should start earlier then later reading a data structures book. Move on to an algorithms book and eventually check out compilers a bit too. Throw a good design patterns book in there. I've found that the head first design patterns book is really accessible. More so then the gang of four. You probably don't know what that means yet. But if are software engineer for long you'll at least hear that name a few times.

    This may seem a bit overwhelming and it is. But all of these things are useful tools. You'll probably never have to write a compiler. But you may need to write something that parses simple code and generates other code.

    Simple data structure knowledge is invaluable. You should know the big O notation for all of your basic data structure operations. It is very helpful to be able to recall it like your ABCs.

    You should also learn other languages outside of your scope. It'll help you to understand your main language more and probably give you new ideas as well as cement some common programming themes.

    Learn how to use more then one operating system. Learn the strengths of weaknesses of each so you can make the right decision when developing and chose the right platform. You can use tools on one to help with the short comings on others. (Insert blurb about basic 'nix command line tools here.)

    Next learn some operating system theory. It actually is helpful to learn how operating systems work when you are trying to trouble shoot weird problems.

    Like I was saying before this is going to be a long journey. Your working on becoming a professional/craftsman. This will not happen over night or even over the course of a few years. Enjoy your journey.

    Some people may scoff at this last suggestion. However, I would suggest going to a real college if you think you like programming. Get a computer science or computer engineering degree. Don't mess with a technical college. They really don't dig as far as they should into theory and won't help you get your foot in the door.

    Plus college was a really great experience for me. It opened my eyes to a lot of things in engineering and outside of engineering. Plus I made some great friendships.

    Good luck

  97. ego control, version control by loshwomp · · Score: 1

    1. Don't let your ego get in the way of learning from your coworkers and from yourself. You're all on the same team, right?

    2. Use version control. I don't want to start a war about the best system to use, but if your version control system isn't at least as good as Subversion, use Subversion. There's really no excuse. Subversion is free, it runs on anything you're likely to encounter, and you can create a repository on your local machine if your team can't be bothered to run a server. If you use Windows, TortoiseSVN is a great shell-integrated subversion client.

  98. Some tips by sukotto · · Score: 5, Informative

    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!
  99. You realize that those two demons just woke up. by HornWumpus · · Score: 1

    It's been a long time sense they almost got the 'Young Ones' and they are hungry and bored.

    --
    John McAfee 'It was like that time I hired that Bangkok prostitute; to do my taxes, while I fucked my accountant'
    1. Re:You realize that those two demons just woke up. by AB_Positive · · Score: 1

      Hungry, bored, and probably has tons of pirated Barry Manilow to torture us all with. Damn... Young Ones reference... back in the day my friends.

  100. Learn about security by ajv · · Score: 1

    ALL programs share one requirement: security.

    Learn about it (http://www.owasp.org), practice it, and do it well.

    Application security is also a very lucrative career path right at the moment.

    --
    Andrew van der Stock
  101. bad habits by Paua+Fritter · · Score: 1

    habits I should/shouldn't develop, etc as I take on my new craft.

    Stop wasting time hanging out on /.! You should be working!

  102. Encapsulation, and test coverage by cylence · · Score: 1

    In my 20 years of development experience, I think nothing is so valuable as writing discrete pieces of functionality wholly separate, hiding the implementation details from the interface. Always write code as if you'll have to completely replace it (you probably will at some point), with an eye to making that as painless as possible (IOW, you won't have to change other code just because you changed this chunk).

    I'd also recommend checking out the Test-Driven Development paradigm, which ensures you have complete test coverage for every line of code you write. It's not a panacea, but it really provides confidence that your code is correct, and makes it easy to ensure past mistakes are not repeated. I'm an extremely careful coder, and it still does wonders for my code quality, and often also my productivity/efficiency.

  103. Take some classes by Nitewing98 · · Score: 1

    Having worked for a "cowboy coder" (someone who wasn't trained in programming) in the past, I recommend you take some programming classes at your local university. There are subjects covered there that won't be in your company-sponsored classes. You need to understand the implications of large sorts, relational databases, writing modular and reusable code, etc.

    --

    Nitewing '98

    Everything works...in theory.

    1. Re:Take some classes by Lord+Bitman · · Score: 2, Insightful

      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
  104. Oblig. Hippy by Anonymous Coward · · Score: 0

    What's a FTOOMSH?

    1. Re:Oblig. Hippy by Anonymous Coward · · Score: 0

      I dunno, what's a FTOOMSH with you?

    2. Re:Oblig. Hippy by Bloke+down+the+pub · · Score: 1

      It's related to a numkl.

      --
      It's true I tell you, feller at work's next door neighbour read it in the paper.
  105. don't be a jerk by Anonymous Coward · · Score: 0

    Number one tip for all programmers anywhere. Have an opinion, don't be afraid to voice it, but don't be a jerk.

    Don't tell people that such and such is crap and they should feel bad for writing it, tell them you've got a better way and it can be improved.

    Don't ever be fooled into thinking you're better than someone else and that there's no chance that they can tell you anything of value.

  106. Reduce Complexity by rfreedman · · Score: 2, Insightful

    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.

  107. Programming vs CompSci + Engineering by Morgaine · · Score: 2, Informative

    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
    1. Re:Programming vs CompSci + Engineering by TheSpoom · · Score: 2, Informative

      I was going to say, I was a bit surprised that they were promoting someone who presumeably wasn't in coding before into a development position, but the OP isn't quite clear on exactly what background he has.

      While I agree that an education is important (enough that I am further pursuing mine), I also know that he could become a good hacker without it as well. Many people have done so, and have learned the foundation aspects through experience (and the community telling them so).

      I'm still mostly working on PHP code, and I learned PHP on my own while I was still in high school. I am a much better coder today, and I do ascribe some of that to my schooling (both community college and university), but a lot of it, perhaps the majority, can be ascribed to personal experience outside of an academic environment. There's nothing like being thrown in to sink or swim.

      --
      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
  108. No course about it. by Max_W · · Score: 1
    If you need a course to become a programmer you are not a programmer and never will be.

    Did Robert Frost need a course to become a poet? Albert Einstein to be a scientist?

    I have nothing against courses. They are quite useful. But if a course is all you need to become a programmer than I can tell you that you will be part of a problem, not part of a solution. A programming course should answer the questions which you already have.

    You sleep a programmer, think as a programmer, born and die as a programmer. Programming is a philosophy to make the world much better place. It is about being a part of a technical revolution.

  109. Some suggestions by mnemotronic · · Score: 1
    There's a lot of good stuff above this. Here's my 2 cents worth, and this is all IMHO-heavy.
    1. Read unto me Knuth of Donald. Know ye that tome deep in thine soul, most especially the volume third - "sorting and searching", and the majic that therein lies.
    2. There is no perfect solution, or perfect language, or algorithm, or environment, or processor.
    3. Be prepared (eager, actually) to learn a new language every 2 or 3 years, and a new paradigm ever 6 years or so.
    4. Scripting languages are not just for losers anymore.
    5. You'll never really finish a program - you'll just run out of time or motivation to work on it and have to let someone else butcher... errr..."complete" it.
    6. Programming is a right-brain activity. Good programmers are artists, but the world still needs cold, mechanical, methodical, plodding, software engineers to remind us we don't really need the "brew quad espresso" command line option. If you span the hemispheres, you'll do even better.
    7. The number of eyeballs on a problem increases the speed, precision, and beauty of a solution exponentially.
    8. You can never have too many CPUs, too much RAM, or too fast a disc drive.
    9. If you want to get really good, you'll need to eliminate any semblance of a social or personal life for the next ten years. Be prepared to hang out with alcoholics, coke fiends, and adrenalin junkies, and develop a nasty habit yourself. You might want to start saving for that therapy you'll want down the road.
    10. The editor religious wars are over. Just use Slickedit (There. That'll bring out the trolls).
    11. Any shop without a world-class version control system is asking for trouble. I don't mean RCS, CVS, PVCS or that ilk. Subversion at a minimum. Perforce if you've got the money. (Ack! More trolls!)
    --
    The Russians have won. They have made the world a cesspool of distrust, greed, fear and hate.
    1. Re:Some suggestions by Max_W · · Score: 1
      I am not so sure about "alcoholics". My best code was written after 5 - 10 km of running at the seaside or at a stadium. I think like with any activity good physical shape and clear mind are essential.

      Coffee is more realistic though.

  110. Write code for people, not computers by Anonymous Coward · · Score: 0

    1. Get good at reading code. Two reasons for this:

          a) you will pick up good design techniques by osmosis the more code you look at, and
          b) pragmatically, this is what you'll be doing most of the time as a team programmer.

    Get good at seeing overall patterns in the code, and learning how to quickly narrow in on the part that's important to the job at hand, while ignoring all the rest--otherwise, there's just too much to keep in your head at once.

    2. Always write code to be readable by humans. Logically structuring code so that others will be able to easily understand and modify it (and your code will *ALWAYS* be modified), is much harder than simply writing a sequence which will execute correctly in the computer. It is also crucial, given the scale and complexity of modern software engineering. Communicating with people is more important than communication with computers.

    3. Realize that your code will live longer than you think it will. Anything that's meant as a quick hack which isn't immediately replaced with something better will become entrenched, forgotten, and will be used without a second thought for years afterward. People will want to re-use it as a template for other code, or re-organize it into a form you never anticipated. Therefore, make sure it's always understandable, as easily modifiable as possible, and never check in code unless you are prepared to see it copied and pasted into future projects for years to come.

  111. Run. Run as fast as you can! by Anonymous Coward · · Score: 0

    The software business is a mess. Sure there are some pockets of brilliance, but in general things are chaotic.
    If you are working with an established product (i.e. one that has been around 10 years or more) it probably doesn't follow any established principles and it will be frustrating to constantly be compromising what you know is right because of poor design. I believe that most large companies are mired in bureaucracy, incompetancy and so called process. That is why most "big" applications ultimately "suck"

  112. To sum it all up... by oljanx · · Score: 1

    Let me just sum up what everyone above has said, and what everyone else will say: Write code other people can read. This means commenting often, using consistent naming schemes, remembering that white space is your friend, etc. Above all, do not try to prove your programming chops. We'll assume you know how to code by default, don't try to impress us by condensing a dozen lines of code into two.

  113. Documentation! by chris_sawtell · · Score: 1

    Be absolutely sure to remove all the useful 'notes to self' in your source code, just in case they confuse the people who have to maintain your code after you have jumped the boundary fence and gone on to the greener pastures elsewhere.

    It's essential that you express your ego by punctuating, frequently, any remaining comments or programmer documentation with vulgar 4 letter naughty words and the occasional ".". Commas, colons, semi-colons etc? They are only for 18th. and 19th century authors of true literature.

    Use the most hi-falutin' prose you can dream up in the user documentation. It will enhance your standing in the company. You know, use "utilize" instead of "use" and similar ad nauseam.

    Make sure you split infinitives and put adverbs before verbs, such as "To boldly go".

    In spite of the fact that all compilers allow for long strings as variable names, your excellent memory for details allows you to use identifiers such as slb2docm when those mere mortals with poor memories would have wasted time and energy with something like: sales_ledger_balance_to_date_of_current_month.

    Never ever even dream about your program handling error cases, because it's a total waste of time and intellectual effort. Equipment never fails, and people are perfect. After a while you will get complaints about this. Your thought is that your users are careless and need a good prod to wake them up. So you send an error message something like: "Er Um?\nYou're a clot!!\n?". Make sure to handle every error condition identically. Never, ever, anything more informative, because it will reduce the force of the aforementioned prod.

    You know you made in the precise image and likeness or your $DEITY and never ever make mistakes, so with absolute certainty, you know that you simply never ever need put ASSERTs in your code. That's for weens. :-) but many a true word is in jest.

  114. It all comes down to your editor by Anonymous Coward · · Score: 0

    Master `vi`
    `vi` users disrespect casual Emacs users and merely tolerate the few hardcore Emacs users.
    All other editors are for complete `tards and it shows in their code.

    Indent with 3, no less, no more spaces. Don't use tabs. Tabs in code is for 'tards.

    And braces need to line up like so:
    if ((/* some sort of condition */)
          && (/* some other conditions */)
          && (/* some ever better conditions */))
    {

    }

    People who tell you otherwise, or that style is a matter of taste...
    you got it! Tards.

    Stay the hell away from Windows programming. You know why.

  115. Backups and versioning by Foolicious · · Score: 1

    Don't be tempted to think that it's someone else's responsibility to handle backups and versioning. Always keep your own when possible, even if you're using some kind of enterprise source code mgt. This sounds paranoid and overkill, but you'll be amazed at how many things it can help you fix in a pinch.

    --
    Please don't use "umm" or "err" or "erm".
  116. Commenting by Brain+Damaged+Bogan · · Score: 1

    Never, ever under any circumstances should you comment your code. If other people can understand your code then you are easily replaced.
    string s1 = obf;
    string s2 = ever;
    string s3 = uscate;
    string [] s4 = new string[] { "ything", "ly", "can", "possib" };

    string result = s1 + s3 + " " + s2 + s4[0] + " as much as you " s4[3] + s4[1] + " " + s4[2]

    --
    -- Sex is the antonym of pringles. Once you pop it's time to stop.
  117. Start writing code in your free time by californication · · Score: 0

    I'm just curious, did you have any qualifications besides 3 years of working at the support desk? Do you at least write code in your free time?

    Most of the people in our support department would be terrible programmers. Some might be able to hack it, but they'd probably stick to ifs and for loops and make everything look like a huge main block.

    Then again, there is one guy in development who does write everything like a huge main block.

    If your only qualification is 3 years of working at the support desk, then you are lucky they hired you rather than someone with at least a B.S. in Computer Science. The best advice I can give you is start writing code in your free time immediately. Follow tutorials on common data structures, like stacks, heaps, pointers, etc. Once you have that down, start practicing OOP.

  118. Left-corner design by steveha · · Score: 3, Interesting

    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
    1. Re:Left-corner design by simbo1905 · · Score: 1

      The modern equivalent of 'left-corner design' is test first programming. Use a unit test framework and mock objects and write testable code that is so small that you can easily see, or isolate, all the bugs in it. Repeat at all levels of the software that you are building. Eventually writing the final app that brings it all together is a simple task as you will have written all of the building blocks of your app as testable components.

    2. Re:Left-corner design by jeremyp · · Score: 1

      An interesting methodology for programming. However, if you use it you must be aware of one of my favourite programming rules which is:

      "Do not be afraid to throw it away and start again."

      For instance, in your DSP example you might come to part 2 of the problem and realise that the way you implemented part 1 makes part 2 really hard to do. Also, sometimes it's hard to gain a complete understanding of a problem until you have tried to solve it.

      Older people will recognise this as a variation on Fred Brook's rule "plan to throw one away". I don't like that version because, as somebody else said "if you plan to throw one away, you'll end up throwing two away".

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    3. Re:Left-corner design by steveha · · Score: 1

      "Do not be afraid to throw it away and start again."

      I pretty much agree with most of your points. However, if you have done the left-corner design properly, you should have important building blocks ready to re-use when you do scrap some work and start again.

      The audio DSP engine originally had to write the same exact audio format that it originally read; if you fed it 2-channel (stereo) data, you had to get 2-channel data out. When I rewrote it to add the mixer feature, I had to add quite a bit of code. But my code for reading and writing wave audio was perfectly re-usable, as was the actual DSP function code.

      steveha

      --
      lf(1): it's like ls(1) but sorts filenames by extension, tersely
  119. Slow and methodical. by Anonymous Coward · · Score: 0

    The best thing to do, in all seriousness, is be slow and methodical. Make sure you understand everything every step of the way. This means that you're going to be an idiot for at least 6 months, but after that you'll have a solid basis. A lot of people try to avoid looking dumb at first, so they act like they understand everything, but in the long run that's a mistake.

  120. lazy by Jessta · · Score: 1

    Be lazy, really lazy, as lazy as possible.
    Don't write any code you don't absolutely have to.
    The less code you write, the less code you have to debug, test, etc.

    Code like the person maintaining your code is an axe murdering psycho that knows where you live.

    Write code like your too lazy to write any documentation and then write useful documentation(this goes back to the being lazy bit), only write documentation if it's going to be useful. useless obvious documentation just increase the chance that the mass of documentation will never be updated and the person who has to read it will curse you to hell.

    - Jesse McNelis

    --
    ...and that is all I have to say about that.
    http://jessta.id.au
  121. Read the definitive references by jthill · · Score: 3, Insightful

    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.
    1. Re:Read the definitive references by James+Youngman · · Score: 1

      This is all great advice.

      You can get the C++ standard in book form (and the C standard) from Prentice-Hall. But a version you can grep is even better.

      The advice about learning your editor well (whatever it is) is essential too. I've watched VI users waste hours because they don't know about the %s command and aren't interested in learning.

      As for TCP/IP, the problem with reading the RFCs is that often the best introduction to a topic is RFC 103 but 63% of that was superceded by RFCs 21897 and 11238474. Lots of the RFCs are short, to the point, and well written, but still I would suggest that the best intro to TCP/IP is "TCP/IP Illustrated, Vol. 1" by Stevens. In fact you would not be going far wrong by just reading everything that W. Richard Stevens wrote.

      The skim reading tip is good too - I basically learned Unix by reading a copy of the HP-UX man-pages from A to Z. I learned a lot about the Ada compiler before I found out it wasn't installed, but the end effect was that I could usually remember the name of the command that did what I wanted.

  122. "Keep it simple as possible, but no simpler" by Anonymous Coward · · Score: 0

    Be ruthless about eliminating complexity whenever possible.

    In the end, that's really the job of a programmer -- managing complexity. When there's less of it, your job is easier.

  123. Think about working on a team by __roo · · Score: 1

    We get this question on the Head First C# forum every now and then from people who read the book, finish it, and want to know what to do next to get a programming career. Here's the post I usually send people to. One thing I think new developers should think about is working on a team -- that's a skill that takes practice, and doesn't always come easy to developers. The better you are at it, the more successful you'll be in your career. (I've got a few tips in that post for getting that kind of experience. Contributing to an open source project is definitely a good start. Karl Fogel's excellent book, Producing Open Source Software, is a great way to learn about how to do that effectively.)

  124. If you don't know what this means.... by bboxman · · Score: 1

    Then you have no business maintaining said piece of code. RTFM, before you start maintaining. Some ops, in some machines, have side affects that aren't obvious from a single one-liner comment on the side.

  125. ? : ; *is* good by Anonymous Coward · · Score: 0

    As Scott Meyers says, use 'const' whenever possible.
    So I prefer:
        const unsigned num_days = leap_year ? 366 : 365;

    to:
        unsigned num_days = 0;
        if (leap_year)
            num_days = 366;
        else
            num_days = 365;

    So, yes, leave the ? : ; ternary operator is our friend.

    1. Re:? : ; *is* good by Count+Fenring · · Score: 1

      Hmmmmm. I spot a bug here; If an instance of the program runs for more than a year solid starting or continuing through a leap year, you're going to get an off by one (day) error ;-)

  126. It is what it is by felix+rayman · · Score: 1

    On the technical side, read a lot of code. Write a lot of code. Learn about data structures and algorithms. Read books and blogs about software development. Don't wait for permission to learn a new skill, just show up one day and start doing it. Experience counts, so does enthusiasm. All the really stupid mistakes have already been made, there isn't any reason to repeat them. Have fun. If you aren't, find a different job.

    On the non-technical side, be smart, and get things done. Be reliable. If you say you are going to do something, do it. Find out what your manager wants to get accomplished and accomplish it.

    Those are the main things...

  127. on the other hand.... by takano32 · · Score: 1

    don't forget there are people recognize what a bat product theirs are, too.

  128. Don't hesitate to ask by mst · · Score: 1

    Don't be afraid to ask questions! No matter how silly they may seem to you - if getting them answered will get your work done faster you will benefit in the long run. And learn.

  129. Develop your own prototyping tools by dino213b · · Score: 1

    My 2c: The best way to answer some tougher programming questions is to prototype specific tasks. Part of this process requires that you have an always-ready environment that allows you to do so. Your own prototyping tools would in this case simply be a ready environment which would permit you to just jump into code without worrying about prerequisites. Something as simple as a prepared template would do, or a tool like this one: http://www.youtube.com/watch?v=Yfxrt2pc3pg

  130. Unit tests and source code control by RationalRoot · · Score: 1

    When you merge you 3 months work back to the main branch, you will not check every change in every file.

    There is now code in your app that no human has ever seen Your change + My change may be just peachy, or may be broken.

    If you have unit tests, then you have a higher confidence level that Your change + My change play nice together.

    When you fix a bug, add a few unit tests to cover it.

    --
    http://davesboat.blogspot.com/
  131. Test! Test! Test! Test! by Engineer42 · · Score: 1

    Most important for a programmer is to know how to test your code.... AND DO IT!

    Any monkey can make code. Making code that works is the mark of a good coder.
    This doesn't come with time or experience. Even the most experienced coder makes coding errors (and lots of them), but what distinguishes the good coders from the bad is that the good ones FIND their mistakes before releasing their code!

    So, test continuously, test often, test everything, test every single module/function in isolation, test the modules/functions working together, then test everything again!
    Make automatic test programs that you can run at a moments notice (or even better have a test machine checking out your code frequently and run them). Run them at least once a day (no, I'm not kidding). Remember, the sooner you catch an error, the less 'cost' it carries.
    Use a code coverage tool to ensure you've tested all your code. Test methodically, not haphazardly 'poking' the code and calling that 'testing'.

    I've been coding professionally for 15 years now. It still amazes me to see how many 'old' coders think they're coding gods just because they know every in and out of a dozen languages, and yet their code still fails frequently because they don't bother to test it (they don't need to, "because they know their shit" *roll*).

    Learn to test your code well, and you're well on the way even if you don't know the language you're coding in as well as others.

  132. Disqualified by Anonymous Coward · · Score: 0

    Asking that question disqualifies you as a developer

  133. I'll probably get modded down for this but .... by Anonymous Coward · · Score: 0

    You may joke but sadly there are many open source projects where a core 'elite' of programmers seem to want to do just that. Many people believe that if their code is going to be read by lots of people then it should look 'clever' (read: incomprehensible). NO NO NO NO NO!!!!!

    Readable well commented code is better than 'clever' code that is nearly impossible to understand 100% of the time, and one comment at the top of a 15,000 line source file saying something along the lines of "this file is responsible for managing data" doesn't count as commenting in my opinion.

    Posted anonymously so that I don't get an angry horde of open source developers coming to kill me.

  134. Brush up on algorythm design techniques by Simonetta · · Score: 1

    I recommend brushing up on (or learning from the beginning) algorithm design techniques. These are formal ways to diagram how the code works before actually starting to write the program itself.

      Avoid the primitive one-dimensional flow chart technique and learn instead the two-dimensional Warnier-Orr style of algorithm design. Google for tutorials.

      Then, (as our programming teacher at Portland Community
    College used to tell us) get a big sheet of paper, a little pencil, and a really big eraser. Start with really simple programs and learn how to draw loops, branches, and linear instruction sequences. Get good with free-hand drawing of brackets. Draw lightly with the little pencil so that you can erase whole blocks of bracket drawings. When you master simple programs, learn to draw linked lists, binary trees, and recursive loops like the QuickSort and the Tower of Hanoi.

      Learn how to walk through the Warnier-Orr drawing and try every thing that you can think of to make your walk-through crash. When it does, erase that section of the drawing and re-draw all the brackets and symbols for that procedure. Every hour spent successfully crashing the algorithm is many hours saved debugging actual code.

        Do all this at home. You have a new job and your employers will question their decision to promote you to the programming crew if they see you drawing big brackets and symbols on a sheet of paper. Especially if you tell them that this is formal academic programmer training.

        It actually is, but they won't believe you.

        Good luck.

  135. read alot by simbo1905 · · Score: 1

    I started reading books on software design and best practice from day one when I was struggling to get my first program to compile. I am glad that I did as something always sticks and I never felt overwealmed by new challenges as I always wanted to apply some new techniques. Learning more than one language is a very good idea. So if you are writing serverside webapplications, say, then its a good idea to learn advanced javascript for the browser. Else if you are writing divice drivers in C then it is a good idea to learn advanced shell scripting for the OS. If your learning Java then learn Groovy. Its a good idea to learn a 'complimentary language' (e.g. an agile one that helps you out in your day job) in such a manner to learn to see more than one approach to any problem. The best advice I can give any programmer though is to take a touch typing course at a secretarial college and learn to type. Most programmers type with one finger and thats a bit of a bad industry joke really. Once you can type at full speed you can write really descriptive comments, method names and variable names. You will also be more productive. Sure you can get a typing game to train you to touch type but no-one ever completes those so I lugged my behind down to a secretarial college and forced myself to complete the course. My final advice is that once you get the hang of programming try to spend at least a helf day a month experimenting with fun looking opensource software in your favourite language. Your learn a lot from that that will help you in your day job and will also have fun.

  136. Validate. by K3ba · · Score: 1

    Never trust any input from anywhere. A large number of existing security vulnerabilities are because programmers couldn't be stuffed validating input. If you should be getting an integer, then make sure it is one and throw an exception (and log if appropriate) if you didn't get one. If you should be getting a string, make sure the string content fits with what you are trying to achieve, and isn't too short, and isn't longer than it should be. The above is especially true if you are passing on input from one area (say a customer) and passing it on to another (say an application server that will end up putting that input into a database). Never trust that other people's code is validating your input either if you are passing input to their code!

    --
    Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
  137. Lessons learned the hard way by pvera · · Score: 1

    A few things I learned from my colorful career as a programmer:

    1. Attention to detail is a life or death skill.

    2. If you ever get stuck figuring something out, once you do fix it, write yourself a small blog entry about it.

    3. Regardless of how weird the error looks, it happened to somebody else before you. Google it, I can assure you plenty of people before you wrote about it.

    4. Don't rush. You are s new programmer, it is expected that you will need a little more time to get things done. Play that to your advantage.

    5. Every successful programmer I know has very solid fundamentals. The fundamentals are critical, one of the most prized skills of a really good senior programmer is the ability to pick up new languages with not too much effort. Over the years I have noticed that every single shitty programmer I have run across had weak fundamentals and was instead focused in knowing just one language/platform/whatever.

    6. Learn the code macro capabilities of your platform's most common IDE or editor. Almost every major IDE, and all of the legendary "programmer" text editors, have this functionality. BBEdit allows you to write very powerful scriptlets in many scripting languages, VS.net has a feature called code snippets that is a fantastic time saver. EMACS has so much stuff that many see it as almost an operating system.

    7. Learn regular expressions now, it is a skill that pays off immediately.

    8. Learn proper ANSI SQL, it will make it much easier to switch between major RDBMS platforms.

    9. Don't worry if your "lead" apparently knows less about programming than you do. Sometimes your lead knows more but is drowning on non-programming work, some other times it's going to be a programmer that wasn't good enough as a programmer but it is somewhat usable as a first line supervisor. Or somebody's cousin.

    10. People love to pin problems on the programmer. Learn the politics of the game, there are subtle ways to protect yourself and deflect that kind of thing.

    11. Embrace Goddess Caffeine.

    12. Try to understand your customer. Mot all customers are dumbasses, and once they like you, they keep asking for you which is nice. When the customer is at ease with the programmer, the project manager can relax a little bit.

    13. Every time you are about to say "it can't be done," give it another minute, see if you can turn that around into "that won't work, but there's a way around it ..."

    --
    Pedro
    ----
    The Insomniac Coder
  138. some things to remember... by Lazy+Jones · · Score: 1
    1. the secret of success is getting started
    2. anticipate what others would see/think if they read your code, write comments/code clearly accordingly (e.g. Duff's Device is cool, but many people haven't seen it before, so please just add a Wikipedia link or just "// Duff's Device" ...)
    3. make sure that you're happy with your code, don't let your feelings towards your workmates/boss/your company affect the quality of your work
    4. don't trust other people's code too much, but look for errors in your own code first (it can be, but it isn't necessarily "some bug in a library")
    --
    "I love my job, but I hate talking to people like you" (Freddie Mercury)
    1. Re:some things to remember... by SpinyNorman · · Score: 1

      There's no good reason to use Duff's device - for a couple more lines of code you can make it readable (and just as fast). Also note that many modern compilers do loop rolling automatically, and secondly that if you followed the advice of that WikiPedia article and used this to copy rather than serialize you should be shot (memcpy will be MUCH faster - it's typically just a single "repeat move word" or similar assember instruction).

      A more readable of a manually unrolled loop is just: // Do whole chunks of 4 first
      for (; n >= 4; n -=4) {
        *out = *p++;
        *out = *p++;
        *out = *p++;
        *out = *p++;
      } // Do final 0-3
      switch (n) { // Fall-thru intentional
      case 3:*out = *p++;
      case 2:*out = *p++;
      case 1:*out = *p++;
      }

      No tricky to read code, and just as fast as Duff's (in fact faster than the WikiPedia code since they appear to rely on the compiler optimizing % 8 to use shift not slow division). I just used chunks of 4 as an illustration - in practice you'd use larger chunks to reduce the loop overhead.

    2. Re:some things to remember... by Lazy+Jones · · Score: 1

      You're right, but I was just using it as an example for rarely-used mechanisms that are not immediately obvious even to some experienced C programmers. Another example is the "50462976 trick", which is horrible to see with the number in decimal instead of hex. Sure, it's clever and it's impressive, but you're not being nice to your workmates by using it in that way without any comments.

      --
      "I love my job, but I hate talking to people like you" (Freddie Mercury)
    3. Re:some things to remember... by SpinyNorman · · Score: 1

      Seeing as that response is advocating using the 0/1/2/3 (0x03020100) values as indeces, it's hard to call giving that number in decimal anything other than deliberate obfuscation - certainly not clever.

      If you want to have machine-indpendent access to a 32 bit int, then how about the OBVIOUS way:

      union {
        uint32_t val;
        char bytes[4];
      } n;

      Just write one variant, and read the other. (e.g. n.val = x; n.byte[2] is 3rd byte, regardless of int byte order)

      Or to answer the poster's actual question about determining endianness (i.e. int byte order):

      int i = 1;
      if ((char *)&i)[0] == 1) { // little endian - low byte first }

      Doh!

  139. Re:STOP: Get out NOW !! by Anonymous Coward · · Score: 0

    App Dey

    Perhaps your first task should be ask for a spell-checker. :P

  140. You're doomed by Buscape · · Score: 0

    Your best hope is that there's a real programmer there to mentor you. The programmers that arrive at my shop, 1 in 3 can be mentored, and the rest are a waste of a seat. 1 in 10 can actually write usable code out of the chute.

  141. New Year's Eve Party by bencollier · · Score: 3, Funny

    Wouldn't have been the Millennium would it? :-)

    1. Re:New Year's Eve Party by Nefarious+Wheel · · Score: 1

      Wouldn't have been the Millennium would it? :-)

      No, it was long before that. Apologies for the long post, but I think it's worth it...

      At a now-defunct Silicon Valley firm called "Logisticon" at 2am over a loooong day supporting idiot sysadmins (my attitude has improved since then) and after a few beers at Dennys, the pager started spinning. Several hours later -- and after a near infinite supply of Denny's coffee (yep, a 2am regular there) and after telling the fry-cook computer operator across the country how to read register values from the front panel (Turn the key to the horizontal position -- yes, if you're laying on the floor, you're horizontal, make it look that way) and a long sequence of instructions at that level, we determined that the problem wasn't in the software at all (this was on a brain-dead GA16/440, JumboGA.

      But the customer dragged their feet when we said we'd have an engineer on site the next day, even though we insisted it was all under warranty. "You can't land. There's a hurricane in the Gulf of Mexico and Miami airport is closed. In fact there's two feet of water in the computer room right now.".

      I passed the phone back to the support manager and went home.

      --
      Do not mock my vision of impractical footwear
  142. Never assume that your code works by tsverrir · · Score: 1

    A few minutes spent testing while you are writing your code can save you hours later when someone finds that the system isn't doing it right...

  143. your a new person every 6 months by mlush · · Score: 1

    You will not remember or recognize the code you wrote 6 months ago. You will not remember how that neat little hack worked or why you put in that odd little exception. Learn to comment the unobvious (and when commenting the obvious why you did it is more useful than what the code is doing).

    Find an editor that does auto-formatting for your language (and use it!), it makes the code easyer to read and more pragmatically when the formatting goes wrong it means you have missed out a bracket of a ; or something and can spot/fix it without having to execute the program.

  144. Always code.. by Anonymous Coward · · Score: 0

    Always code as if the person maintaining your code is a physco who knows were you live.

  145. Communicate by Anonymous Coward · · Score: 0

    If you are on a team, you most probably have more experienced people all around you. Leech off of them for as much as you can. That's where you will learn most of your worst/best practices.

    And yes, read some specifications on the environment you'll be using. Language, servers and other technologies. You don't need to know these documents off by heart (they are on paper for later reference) but skim through them at the least. Ok printing the iso specification for c++ is by choice :) It was mine heh.

    Also drill yourself on 'finishing' your work. Cleaning up source files before submitting is never such a bad thing.

  146. Just do a good job. by Lally+Singh · · Score: 1

    Simple answer, 3 parts:

    1. Document more than is necessary. B/c your estimates of what's necessary will always obsolesce over enough time.

    2. Test cases. Tests that make sure the code runs, tests that you can run later to see what broke what.

    3. Don't be a savage. Use real identifier names (i,j,k are only ok in very specific cases), well indented code, version control, etc. Code Complete was suggested above, it's a good place to start. If your shop doesn't do version control, that's no excuse for you not to.

    --
    Care about electronic freedom? Consider donating to the EFF!
    1. Re:Just do a good job. by Anonymous Coward · · Score: 0

      if your shop doesn't do version control find another shop.

  147. Pay attention to the bugs and read stacks of books by James+Youngman · · Score: 1

    First, in order to become a good programmer, you should expect to read about one hundred times more code than you write (in terms of finished code). Read both your colleagues' work and code from elsewhere (open source stuff, stuff in books, etc.).

    When you are reading a program, try to decide if it is good code or bad code. If it's bad code, decide why. As you start to move beyond "well, it's not done the way I would do it", then you will be in a place where you can learn new ideas and techniques just from reading somebody else's code. When you see code you think is bad or even just hard to read, decide why and figure out how to avoid doing that yourself.

    There are a lot of second-rate programmers in the world. They get that way by avoiding the chance to learn from other people, and through not learning from their own mistakes. Try to set your work up so that you do learn from your own mistakes. For example, eventually one of your colleagues will find a bug in code you wrote. If at all possible, fix it yourself. Then go look for similar cases in the rest of your code. If they don't want to give your he bug to fix, ask them to explain what you did wrong and how you can avoid doing it again. Once of the best experiences in my programming life was doing this for a couple of years while working on a life-critical system. I learned a lot about how to write better code, and how to write programs so that the compiler catches the bugs for me.

    You should read some books that will give you ideas about how to think about program designs, approaches and how to approach the nuts and bolts of the field. However, the best reading list depends quite a bit on your chosen language. Here's a rough list (slanted towards C and Java, so if that's not your bag other books may be better choices):

    • Programming Pearls - Jon Bentley
    • The Practice of Programming - Kernighan + Pike
    • Writing Solid Code - Steve Maguire (or Code Complete I guess)
    • Design Patterns - Gamma, Helm, Johnson, Vlissides

    These are also good but are more narrowly focussed:

    • Effective Java - Joshua Block Effective C++ -
    • Scott Meyers Refactoring: Improving the Design of Existing Code - Fowler, Beck, ...

    I would also suggest that you make a to-do list of things to learn or find out about. A big item on there should be to expose yourself to a small number of programming languages that differ quite a lot from the language you mainly use at work. An example of such a diverse set of languages might be: Visual Basic, Java, C, a scripting language (e.g. Python or Perl), LISP, and a functional language (e.g. Haskell or ML). The idea here is to squish your brain into a configuration where you can think about your existing problems in terms of a selection of programming paradigms.

    If you are lucky your employer will recognise the need for everybody to get better at their job and help pay for these books. My earlier employer didn't, but I made a habit of buying a good book every month or so and reading it. I'm a better programmer for it. My current employer pays for books, but I find I buy different kinds of books for home and work (e.g. at work I bought "Python in a Nutshell" and at home I recently bought a stack of compiler books).

  148. Code for open standards by BhaKi · · Score: 1

    As far as possible, code for open standards and avoid using (unimplementable) proprietary extensions unless you are forced to use them. This will ensure that the usefulness of your code won't be in control of a single vendor.

    --
    The largest prime factor of my UID is 263267.
  149. comments yes but a suite of unit tests is better by Anonymous Coward · · Score: 0

    I agree with the "comments first" approach; but better yet is the "tests first" approach. Build all of your non-ui code using jUnit or testNG with mock objects. Then you effectively document the expected behaviour of your code with sample code (the tests) that show all of the expected inputs and outputs for the scenarios you thought of, the bug fixes you made, and the enhancements you put in.

    Writing unit test code before you write your application code will force you to think about "what it does" before you think about "how it does it" which is the starting point of any design. Coding the test cases first guides you naturally into creating modular code compiled to interfaces. IoC frameworks such as spring, picocontainer or hivemind are a big help when working this way. Maven the build tool supports the tests first approach and can publish a website of reports based on the tests run to show what code is covered by the tests. (The examples above are java but there are similar frameworks in other languages, it is the approach that is important not the particular tools to support the approach).

    The pay off to the effort in setting things up to work "tests first" is that you get less defects and more modular code that you can refactor with confidence. You know your code is working after you change it when you see all of your old tests passing. Rather like the 'tortoise and the hare' you seem to start off making slower progress but you finish the race ahead of anyone else when you have code that you can keep on adapting and changing in response to the inevitable late in the day changes, fixes and enhancements.

  150. My personal mantra by daveime · · Score: 1

    If you can't see both ends of a loop or condition, then what's inside is too damn long. The minute you have to start scrolling or trying to match braces across multiple pages of code, you lose track of what loop / condition you are inside of.

    Never be afraid of using something like GOTO HandleAnError;

    If you are making a set of say 20 tests, and need at any point to abort the remaining ones if one fails, then having 20 levels of nested conditions is NOT the way to go.

    Likewise if your indenting is such that you have to horizontally scroll your editor to even see the start of a nested nested nested statement, then it is again far too nested already.

    Simply make a test - did it fail ? If yes, then GOTO the error handler - otherwise continue with the next test etc.

    It's clean, unamibiguous, and saves scroll work with your mouse and a lot of time in mentally unwrapping all the nested levels.

    Oh, and finally, don't EVER believe your boss when he tells you it needs to do "X AND Y, but never Z" ... because chances are three weeks later he will come back and say "make it do Z also".

    Code defensively, as if you know you will have to come back and modify it later ... don't ever assume a project is finished, because in my experience, it NEVER is !

    Oh, and good luck.

     

  151. Slashdotted before being a programmer? by startxxx · · Score: 0

    Dude... You been slashdotted before you even wrote your first code... what do you worry about?

  152. Code should be readable without comments by iothal · · Score: 2, Insightful

    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!

  153. KISS by WoollyMittens · · Score: 1

    The best advice and the least followed: K.I.S.S. - Keep It Stupidly SImple. Resist the urge to delve fist-deep in complicated frameworks.

  154. hours by jDeepbeep · · Score: 0

    One thing I've seen people fall into is the whole "Im leaving exactly at 5" thing. Now when you've got something that really needs to get done, do not be afraid to sink a little more time to get things to a natural break point before you leave the office. Makes it easier, for you, to walk in the next morning and start in a clean way. It also sends a message to the boss object and the new coworker *pool that you actually give a fsck about what you do.

    --
    Reply to That ||
  155. Use good mentors and find good examples by fortapocalypse · · Score: 1

    You'll be a better developer if you work under good developers, challenge them, and seek to understand why they do the things they do.

    In addition, look at major open-source projects in the language you'll be using if they exist. For example, as a Java developer, I often looked at Apache Jakarta projects as a reference for the "right" way to setup a project (with continuous integration, tests, documentation for new developers, etc.)

    One thing I wish that I would have done is to blog everything I learned in a major free hosted blog server (hosted by a large company that would hopefully not go away anytime soon). If you do this though, you might just want to keep records as text files while you are working and then blog them later. But don't blog anything with company specific data in it! If your company has an internal wiki server, you could use that for private documentation usually, or worst case store it in text files only, and then be sure to periodically make a local copy of it and all of your code that you write to have a personal copy, if you can. Early as a developer you'll need to provide source to places you apply for work, and it is good to have your work for your own purposes as well.

  156. I think he meant App DAY by Anonymous Coward · · Score: 0

    He gets to code for a day and see the number of bugs that can be introduced.

  157. Some Other Tips by MCord · · Score: 1

    1- Master OOP 2- Learn about Patterns but don't be patter happy! 3- User Version Control 4- Unit Test 5- Write readable code. 6- Automize repetitive work as much as possible.

  158. Cardinal Rules by jonadab · · Score: 1

    Here are some things that I consider to be inviolable rules for programming...

    1. Never EVER design a user-interface around what you already know how to program. Design how the UI is supposed to work, and then learn whatever programming you need to learn to make it work that way. This is an inviolable rule as far as I'm concerned. Getting this wrong is how you end up with nightmarishly bad interfaces, like unresizeable dialog boxes too small to contain the information you put in them. Don't do stuff like that. Ever.

    2. Don't hardcode numbers, unless they are physically incapable of being changed (e.g., pi).

    3. If the application is going to be distributed outside the company, you probably don't want to hardcode strings (that the user will see), either. Some strings are for internal use by the application itself (e.g., part of a file format), or for communicating with other software (e.g., part of a protocol); those you can probably hardcode. Also, the "can't find configuration file" error message string will have to be hardcoded.

    4. Error messages should start with an oversimplified end-user-oriented headline, consisting of 2-4 non-technical words, and the headline should be *unique* to that specific error message, because it's the only thing the user is going to remember and report when there's a problem. Including some technical detail may also be appropriate, depending on the situation, but you can't count on users to report the technical details back to you in bug reports, so make sure the friendly headline uniquely identifies the specific error.

    5. It is *theoretically* possible to write too many sanity checks and send too much information to the log file, but as a beginning programmer, you are certainly going to err in the other direction, guaranteed. For now, it's best to assume that more sanity checks and more logfile entries are automatically better. When you reach the point where you have to start rethinking that and cutting back, it will be a milestone in your programming career.

    6. Comments should tell *why* the code does a certain thing. Don't comment on what it does. That's redundant. Any competent programmer can tell *what* the code does, just by reading it. But the reasoning behind it may not be apparent even to you, when you look back at your old code in a few months, let alone to someone else. Explain _why_ in the comments.

    7. Don't hardcode filenames or paths, ever. Even the config file location should be possible to override in some fashion (e.g., via command line argument or environment variable).

    8. It is *theoretically* possible to make an application too configurable, but I am not aware of a single documented case of this actually happening in the entire history of computing. If you aren't sure whether anyone will want to change a certain thing, it's best to assume that someone will want to change it for some reason.

    9. Options are for advanced users; default settings are for end users. Don't let end users tell you what should or shouldn't be configurable, and on the other hand don't let more advanced users tell you what the default settings should be. If the advanced users want something different from the default behavior, they'll be competent enough to change the settings. Design the defaults around end users, so they don't *have* to change any settings. Also note that you may want to create a UI for some of the simplest options, but it's okay to let more advanced users edit the config file for the more esoteric stuff, especially if the config file has comments explaining what the options do.

    10. Don't get caught up in theoretical purisms. Sometimes the object-oriented approach is best, but sometimes a more functional approach works better. A good programmer chooses the approach that fits the problem at hand.

    --
    Cut that out, or I will ship you to Norilsk in a box.
  159. The 1st step is important by Anonymous Coward · · Score: 0

    As a new programmer, I guess the first thing is to learn how to program.

  160. Talk to users and test, test, test by Anonymous Coward · · Score: 0

    One of the biggest issues I see from any software (OS's on down to utilities) is that the coder doesn't have any idea who the user is or how they expect to interface with the program. I have seen common words re-defined by programs (MS is the worst at this) and common conventions ignored. Try and get a few basic business courses such as marketing, management & accounting so you can somewhat speak the language. Also I would try and get someone in the department(s) you are coding for to be intimately involved in the project from design to final acceptance testing so any issues can be caught early. Good luck and remember that you aren't really coding for your boss but for the user. (That would be me in a lot of cases)

  161. ok by amn108 · · Score: 2, Interesting

    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.

  162. Question everthing by k33fb · · Score: 1
    The answer is like getting to Carnegie Hall: Practice. There are two schools of thought, both think that they are the "proper" way to do it:
    1. Design first, Write a spec, then code to the spec. The code will need explaining with comments.
    2. Write the code in conjunction with unit tests. If the code looks complicated or unclean, refactor (i.e. re-work) it. Nested statements are a sure sign that you can refactor out a new method/ function. Give them a sensisblle name then only does what is says on the tin. If you get the refactoring right, you'll not need many comments as the code becomes self-descibing.

    I was firmly in camp 1, until a more experienced developer "showed me the light". I think my code has improved 10-fold since then, but who knows, as I gather experience & tools change I might go back to the first camp (though I doubt it right now!). Whichever camp you start off / end up in the following always apply:

    • Practice practice practice practice. Not just with your work langauge but with other ones, and not just with similar langugae "paramdigms" (e.g. if you use java, have a look at perl & scheme at home)
    • Requirements you are given will never be correct or complete (except in very, very, very, exceptional circumstances). Accept this, but do what you can to improve the requirements gathering process
    • Learn from more experienced developers. Don't just get a quick answer, find out how to do things better
    • Be analytical of you own code & always look for improvements (unless the deadline looms :-)), do the same with the code of others
    • Coding is a journey, I'm still learning and hope to be until I retire (still 20 years to go....)
    • Never underestimate the stupidy of the end user
    • Oh, did I mention, never underestimate the stupidy of the end user. No Really.

    Even after 5 years of coding I write code that I think WTF was I thinking when wrote it after a couple of weeks away from it.

  163. How To Be A Programmer by tom_o_oem · · Score: 1

    "How to be a Programmer: A Short, Comprehensive, and Personal Summary" by Robert L. Read is an excellent and wide ranging paper that the author released with a GNU FDL licence. Here's the pdf http://samizdat.mines.edu/howto/HowToBeAProgrammer.pdf

  164. Tell me why it isn't done the obvious way by Nurgled · · Score: 1

    Agreed wholeheartedly. I really only ever write two types of comments. The first type is the sort of comment that gets fed into javadoc, doxygen, etc: API documentation. Even then, you generally don't need to say too much if you've designed your library well. The second is comments admitting that something sucks and explaining why it sucks.

    Sometimes, though ideally not very often, something prevents you from doing it the way you would have liked to do it: lack of time, design flaw in a library, deployment constraints, bugs in other components, etc. That's the sort of thing I like to see in comments. Tell me why it's not done the "obvious" way, otherwise I'm liable to waste time trying to change it to the obvious way.

    Generally this latter sort of comment will start with something like FIXME:, HACK: or TEMP:. At a previous employer we had a tool that would grep the entire codebase for this sort of comment and produce a report of all of the craziness so that it'd stay on our radar and eventually be fixed one way or another. Even though I don't have that tool at my current employer, I still make a point of writing the comments in this way so that in theory such a tool can be used.

    1. Re:Tell me why it isn't done the obvious way by ckaminski · · Score: 1

      Recursive grep

      http://aplawrence.com/Unixart/recursivegrep.html

      Hamilton C Shell (Windows) used to have a great feature, where you could specify fgrep to recurse the current directory:

            fgrep [string] ...\

      Something you could easily add to a cron job.

      [Why windows has that brain-dead "AT" scheduler versus a real cron engine boggles my mind]

  165. Abstract/Generalise by ChrisH619 · · Score: 2, Insightful

    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... :)

  166. Plan, Cover the entire pipeline, *Start* with OOP by Qbertino · · Score: 1

    Well, as someone who has been programming for the last 22 years I could write an entire book on this subject. But from the top of my head I have three things you should definitely bear in mind, whatever programming area you are about to move in to.

    1) Plan. If a project goes wrong and it's the programmers fault, in most cases it's due to the lack of planning. If you don't know how to plan a software project or a software programm: Learn it and apply it whereever you go. There is an entire subsection of our profession dedicated to this particular issue. Quite a bit of it is academic masturbation, but there is a reason this field of expertise exists.

    2) Cover the entire pipeline of software production. If you don't know how to automate the tasks you need to do 10 times a day, how do you expect to be able to automate other peoples tasks with your software? Learn about your tools, toolkits and appstacks at every level and learn to cover the entire pipeline of software production with what you do. That includes versioning, building/compiling (if you're using compiled stuff), sync & deploy (if you're doing web-stuff), deployment, testing and debugging. Read my comment on the web-admins stack here to get a picture of how deep you should be able to dive in your field of expertise.

    3) *START* with learning OOP. If you haven't programmed yet, you have an advantage. You can start learning the OOP way right away and won't have to deal with academics and crappy literature that can't explain OOP to people who are used to the procedural way of doing things. OOP isn't hard and it's also not the holy grail it's presented as, but it's a good approach and methodology and the only way to do software in certain fields (such as business logic). As a sidenote: It's a myth that people not used to OOP are spoiled for their life. It is true however, that there are very few people out there that can properly explain OOP to old-school programmers. You avoid that shortage by learnign OOP right away. Look into procedural stuff later on. Also because the people doing that are helpfull and usually don't have their head up their ass as much as the former. :-) ... I actually recommend that you look into starting your programming with Java - however bizar that may sound. It probably will help you in the long run.

    Good luck.

    --
    We suffer more in our imagination than in reality. - Seneca
  167. Describing your functions before writing the code by greyparrot · · Score: 2, Insightful

    It worked even for COBOL. If you don't know where you are going, it doesn't matter how you get there.

  168. Clothing makes the programmer by wvwalt · · Score: 2, Funny

    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.

  169. There are four main things... by RaigetheFury · · Score: 1

    While there are realistically about 50... the main 3... the ones that best identify if you are a good programmer... or "that guy"...

    4) Understand the coding tags you are using. Not just that they "work". This is the biggest source of problems when upgrades happen. Just because it "does it" doesn't mean it should be used for it.

    3) Use standard code writing utilities. There's nothing worse than opening a file to see that 10,000 lines of code is actually 1 single line. We had a russian developer who used this crazy tool. It didn't format to any standard... and yeah... it was ugly.

    2) Indention indention indention. People who don't indent make me sad. Their code is unreadable and typically it's to hide their inept abilities and security holes.

    3) COMMENT YOUR CODE! Not just for others to follow your logic but for YOU to follow your OWN logic when you come back to it in a year and go "WTF was I doing here!?!".

    If you do the above... chances are you'll end up being a very good developer. Other people have posted a LOT of great books and resources for coding. After you've mastered the above, if you are doing web applications you should look into the following

    SQL Injection Attacks (Learn how to prevent them)
    Relational Database Design
    Frameworks (Tomcat, MachII etc) a lot of time these frameworks will save you days of work. Steep learning curve though.
    SVN's

  170. For your sake, remove the phrase.. by Rytr23 · · Score: 1

    "It works on my machine" from your lexicon. It only makes you seem like a jackass to everyone else.

    --
    So many injustices..so little time..
  171. Code to read by univgeek · · Score: 3, Informative

    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!
  172. Re:STOP: Get out NOW !! by djdavetrouble · · Score: 1

    So, what was it today? White widow? Kush? Blueberry?

    Keep on Slashbongin.....

    --
    music lover since 1969
  173. Code in C... and nothing else... by GNUPublicLicense · · Score: 3, Funny

    Learn C (need to understand the computer memory model), and that's it. All the rest is bullsh... and fashionable stuff.

    1. Re:Code in C... and nothing else... by Zarf · · Score: 1

      All good programmers should know some C. If you want to be serious, you should know at least two radically different Assembly languages. I would offer a really good programmer should know ASM and JASM today. I personally learned ASM and MIPS when I was a new programmer. It has helped me tremendously ... even when I was just doing web development. Understanding what the machine is doing at the byte level helps in understanding i18n issues.

      --
      [signature]
    2. Re:Code in C... and nothing else... by geekoid · · Score: 1

      BS.
      There are many areas of programming where ASM knowledge is worthless. Those days are gone.
      Sure, if you are programming robotics, or firmware, or drivers, yeah, C and ASM is a must.
      Pretty much everything else is just simple data entry of some sort.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    3. Re:Code in C... and nothing else... by Zarf · · Score: 1

      In today's world the only thing you need to know to be an excellent programmer is how to use a wii-mote all this "code" and such is just quaint~

      --
      [signature]
    4. Re:Code in C... and nothing else... by GNUPublicLicense · · Score: 1

      You are right... Actually, coding properly in C, is coding properly the memory model of computers. So when learning the C syntax, what's important is to have a mental picture of what's done in the computer memories (RAM/cache/page). So C syntax is maybe very simple, the learner shoud be careful in mastering the computer memory model at the same time.

  174. It works for me by Slash.Poop · · Score: 0

    The first three rules of programming I adhere to are as follows:

    1. The end user is dumb
    2. The end user is dumb
    3. The end user is dumb

    I use those rules to remind myself that if it can be broken the user WILL find a way to break it. THINK about it before you write it. Make it "user proof". Something that I personally find useful is purposefully trying to break it. Not just writing it so it works and saying that I am done. No, do everything and anything to it. Even the most off the wall, could never happen scenario. Then study why it broke.

    Also, there is no problem with re-using code. Everyone I have every encountered encouraged it. That leads you right into making code as generic as possible. This way you can re-use segments over and over. If you know you need to make 25 or 500 of something then write a generic builder.

    Finally, do not re-event the wheel. Study the API. Chances are what you are trying to do is already written in some form.

    At least that is what I do.
    Happy Coding

  175. from my perspective... by Anonymous Coward · · Score: 0

    I'm not going to read through all 355 comments, so this might be duplicated, but I'm typing it in anyway.

    I'm in a similar position right now. I haven't been given a title or anything, but I'm essentially writing pipeline tools and as the only programmer in the studio anything code-related falls to me.

    One thing I've found is that it's always a good idea to, within the limits of your time and ability, code with the intent of making things easier and more intuitive to the end user. This usually means writing code that's harder / takes longer for you. For me, for example, I'm about to code up a UI front-end to some tools in our 3D software. The easy way to go would be to make a few buttons and have users hold to a workflow. Instead, I'm going to take the time to make a more intuitive UI based on a library of functions I've been developing. If I'm successful, then people won't have to worry about workflow because everything they need will be visible to them in nicely-named boxes and radio check buttons.

    Oh, and there's no such thing as too many comments.

    The note on explaining it in English first is a good one (or whatever your native language happens to be) -- I find that coding is less a science, and more the art of language translation.

  176. Security by daveoj · · Score: 1

    Learn enough about security risks in code... by enough, I mean enough to know that it's -as important- to write secure code, as it is to produce software that does what it's supposed to in the first place.

  177. Some simple advice by Anonymous Coward · · Score: 1, Funny

    Remember "Profanity is the one language all programmers understand".

  178. Get a copy of Code Complete by CharlieG · · Score: 1

    Get a copy of Code Complete - read it, and take it to heart

    The big one - READ - study GOOD code, and understand WHY "clean code" is (There is another book for you "Clean Code")

    Understand that you are NOT only programming for the computer, but that you are programming for the future programmer who comes in and looks at the code. (BTW there is a real good chance that the programmer who will be looking at that code in 6 months, or 5 years will be YOU) Code comments should not explain what, but why.

    Find a few good blogs by experienced programmers - read them - particularly if they are the experts in the Business matters that you are working on.

    --
    -- 73 de KG2V For the Children - RKBA! "You are what you do when it counts" - the Masso
  179. "Code For The Next Guy" by webphenom · · Score: 1, Informative

    I have been a programmer for more years than I care to think about. My motto for the longest time has been "Code For The Next Guy". Invariably, the code that you write today will likely be maintained or enhanced by someone OTHER THAN YOU tomorrow. So, when coding, keep that in mind.

    Some guidelines...

    - Whitespace is your friend. So is proper indentation of your code. Make your code easy on "The Next Guy" to READ.
    - There are 100+ ways to code a solution to a problem. The issue is that about 99 of those ways suck. Don't reinvent the wheel. Like a previous poster stated, read code from other developers, follow a programming standard and stick to it.
    - Document code that needs documenting. If you are implementing an algorithm to solve a problem that might not be clearly evident to "The Next Guy", document that. Do NOT bother documenting the obvious, such as "Increment Counter" when you are incrementing a counter variable. If "The Next Guy" doesn't understand that, there will be issues.
    - Make your variable names meaningful. You can get away with single character variables in a "for" loop, but that's about it. In the same vein, however, don't be ridiculously verbose with your variable names. A variable named "companyName" is much better than "coNm" and even better than "cn". A variable named "nameOfTheCompany" is overkill. Your variable should clearly denote the contents that are being stored.

    I could go on an on, but you get the point...

    "Code For The Next Guy"...not for yourself.

    --
    ----- Open Source = More Secure (mmmmkay)
  180. First and Foremost.... by borgheron · · Score: 1

    Listen to your elders... or, at least, those who have been in the business longer than you have. :)

    GC

    --
    Gregory Casamento
    ## Chief Maintainer for GNUstep
  181. From a programmer with over a decade of experience by Zarf · · Score: 2, Informative

    ... 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:

    • Could I have done that better?
    • How would another developer have done this?
    • How would a programmer on a different platform have done this?

    Once a year I stop and spend some time thinking hard about:

    • How would I have worked the last few year's projects with today's technology?
    • How will things change this year because of what happened last year?
    • How can I position myself and my company to deal with the next year?
    • What should I learn this year and when should I learn it by?
    • What conferences should I attend?
    • How will all this affect my employment prospects?

    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]
  182. What? by ratboy666 · · Score: 1

    A developer will separate the "UI" from the application. The developer can write a UI -- if that's what the boss wants deployed... blame the boss, NOT the developer.

    I've had people tell me "the UI must look EXACTLY a certain way", for no particular reason. Can't tell them its a bad UI; they pay the bills.

    --
    Just another "Cubible(sic) Joe" 2 17 3061
    1. Re:What? by amn108 · · Score: 1

      No, the developer will not, and usually does not, separate the UI from the application. Neither on the code level nor the level end-user is able to access. You are plainly wrong. A have peeked at a whole lot of lines of code, and much too often developers assume that the functionality their software hides will forever be tied up to the puny widgets they, in their "infinite wisdom" cooked up to access that functionality. Very few products bare the signs that the developer wished to explicitly separate the UI logic from the function logic. Also the run-time is usually too rigid for the user to change anything of UI relevance. And the "target audience" is a rough approximation which has little reality value, since it is proven again and again that users are different. Now tell me again, what you were saying?

      Also, the developer can write an UI, as much as a painter can build a house, all if that is what the boss wants. Unless that developer understands that this is not the U.S. Army with an absolute non-possibility of disobeying orders, but rather a software company where people combine their talent to product a good product. I am sorry if you feel a pawn in a big game, and are unable to give a hint to your boss that he most probably has as much (zero) competence in UI design as you yourself. You are afraid you will get fired, because you told him something that is closer to the truth than he wishes for? I understand the fear, but a good boss will heed to a good advice nevertheless. If you are good, change a company. Everyone has a choice. A good developer is maybe not proficient in UI design, but he would know what he can do and what he cannot do, as well as what his contract says he is supposed to do. You are high up in the clouds of confusion here, I am afraid.

      I am sorry to say this, but depending on what kind of people that tell you how the UI must look, and I am assuming your boss here, I hope your products never reach me. I am happy they pay your bills though. But I do not regard your boss as an authority in the matters of UI design, even if you "do".

    2. Re:What? by ratboy666 · · Score: 1

      Of course UI is separate from application -- what is the point of MVC? (as a refresher - Model-View-Controller. Model is the application, View is how it looks, and Controller effects state changes in Model).

      Windows applications have "resources" -- including dialog, bitmaps, strings, etc. Haven't you ever used "rc" to bind different resources to a program?

      My "boss" is the client who pays for my services. If the client doesn't want to use standard resources and controls... they can request a different "look and feel". To give you some examples (from the last two years):

      "I want it to look like Skype". "I want it to look like a keyboard, and drag functions around".

      Now, I will concede your first point -- if the developer uses the "Visual Basic" model. The philosophy being "the UI *IS* the application". But I don't really consider this software development. You wouldn't pay me to do it for you (well, you may, but it would be foolish -- you could get someone at 1/3 my rate to do it for you).

      --
      Just another "Cubible(sic) Joe" 2 17 3061
  183. Listen to the customer by berbo · · Score: 1

    The technical part is easy - that just tells you how to get the job done. The hard part is getting the correct requirements.

    Doesn't matter if you're writing for your co-workers or for paying clients - Listen to what they are trying to do.

    When something isn't clear, don't be afraid to ask questions.

    When it still isn't clear, ask who really does the work (but don't put it that way). 90% of the business intelligence in this country is sitting on Excel spreadsheets handled by administrative assistants. Find them, befriend them. They are your only conduit to getting things done.

    1. Re:Listen to the customer by JustNiz · · Score: 2, Insightful

      >> The technical part is easy

      Not true. to hack some crappy code together is easy. To do an excellent job isn't.

  184. General Coding Advice from a 20 year programmer by CFD339 · · Score: 4, Informative

    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
  185. Do Something Fun by handy_vandal · · Score: 2, Insightful

    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
  186. backward (even bugward) compatibility! by CFD339 · · Score: 1

    If you write an object, method, function, or subroutine that has a scope outside your own code -- it can be linked to or called from anywhere else -- you can't ever change its parameter requirements or return results in such a way that previous versions will fail.

    You can get around this with overloading, you can get around it with version numbers on your newer declarations (yuck), or other such hacks.

    Don't write your code such that people who depend on it can't upgrade to the newer libraries simply because you've changed all the calls they have to make.

    F'ing Microsoft does this and it is painful as hell.

    if your original method was:

    int doSomething(int var1, int var2, int var3)

    and you need a fourth variable in a newer version, keep the old version around and either overload it (just create the new method with teh same name and the other variable) or give your new method a new name. Where possible, move the code from the old method to the new one, and just call the new method as the only code in the old one -- supplying the missing data.

    Yeah, I know it makes for a lot more code and more methods in your libraries -- but it makes version upgrades happen a million times more smoothly.

    --
    The problem with quotes on the internet, is that nobody bothers to check their veracity. -- Abraham Lincoln
  187. don't be pig headed. by greywire · · Score: 1

    That is to say, don't be adverse to doing it the way a more experienced programmer has asked you to do it. Its ok to except the wisdom of another programmer, you don't have to reinvent everything.

    Conversely, if you have the instincts of a good programmer (if not, you should be doing something else) and something strikes you as not ideal, don't be afraid to test it and see. And if you're right, don't be afraid to tell your superior what you've come up with. But do it with tact and respect.

    That, really, I think covers the biggest issues. Because anybody who's not willing to learn from others and anyone who's not able to test things and improve them where it makes sense to do so, all while maintaining good communication skills, is not someone who should be programming.

    --
    -- Senior Software Engineer, Attorney appearance services, locallawyerapp.com.
    1. Re:don't be pig headed. by geekoid · · Score: 1

      No one has instincts for programming. That have good training and wisdom.

      I am tired of people trying to raise programming to some level of mystic art. It is neither.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    2. Re:don't be pig headed. by greywire · · Score: 1

      Of course, that is true. True instincts are genetic influences and not thought patterns, so nobody could truly have an instinct about programming, or art, or any recent intellectual persuit.

      "instincts" in this case are based on training, experience, etc. Just like what is often referred to as "luck" is really not a random thing at all, but based on knowing when to be in the right places at around the right times to increase your odds of getting lucky.

      I can only assume (hope) this person has been programming for some time and has some experiences, just not professional ones.

      --
      -- Senior Software Engineer, Attorney appearance services, locallawyerapp.com.
  188. Read "Practices of an Agile Developer" by JRD3 · · Score: 1

    A very useful book is
    "Practices of an Agile Developer" by Venkat Subramaniam and Andy Hunt
    The Pragmatic Bookshelf
    http://pragprog.com/titles/pad/practices-of-an-agile-developer.

    Code Complete (recommended above) is also very good

  189. Automated tests! by SanityInAnarchy · · Score: 1

    * Version control everything

    Pay attention to your choice here. I've used Bazaar and Mercurial for some personal projects, and will be migrating to Git at work. (Notice a common theme? DVCS! (Distributed Version Control System))

    Version control has a profound impact on how you work. On small/personal projects, I recommend DVCS simply because it's easier to setup, and quicker to work with. Why waste time building a Subversion server, or signing up for one on Google Code? And if it's on Google Code, do you enjoy not being able to work when your Internet is out? Never mind the difference between commits happening instantly, and taking several minutes.

    On larger projects, DVCS is helpful simply because merging is easier. It's gotten to the point where I avoid branching in Subversion for anything that'll take less than a day, because it could easily take 20 minutes or more to merge those changes back in, assuming no one else is touching trunk in the meantime -- and I'll have to resolve a few dozen conflicts. With Git, merging is much quicker and easier, so I branch whenever I feel like it.

    * Test everything

    Hard to say whether the parent menant human or automated testing. You need both.

    In particular, read up on test-driven development, and behavior-driven development.

    Once you understand that, unless your company has a profound need for speed, use the language which most cleanly allows you to specify intent, not mechanism. (If working with a larger project, this may not be up to you, but there's always the occasional script.)

    Oh, and chances are, your company does not have a profound need for speed. Premature optimization is the root of all evil. Optimize after you have a performance issue, not before. (Given the choice between two equally pretty ways of doing something, you might choose the faster -- but if the faster-executing way is going to take 20 times more code, don't do it until you need it.)

    --
    Don't thank God, thank a doctor!
    1. Re:Automated tests! by ckaminski · · Score: 1


      Oh, and chances are, your company does not have a profound need for speed. Premature optimization is the root of all evil. Optimize after you have a performance issue, not before. (Given the choice between two equally pretty ways of doing something, you might choose the faster -- but if the faster-executing way is going to take 20 times more code, don't do it until you need it.)
      </quote>

      I disagree. I've been at places where the algorithms were so poorly designed that performance targets were impossible to meet. You *DO* need to do some up-front performance design. Optimization of individual algorithms or loops, maybe less so, but you do need to do planning, and possibly testing (especially database queries) to be confident you'll get close, never mind hit your targets.

  190. Technical aspects are only part of it .... by samalex01 · · Score: 1

    The technical aspects of being a developer within a company are only half of it... you also need to learn how to deal with upper management who has no clue about what you do or what IT does in general. I wish every manager who deals with IT would be forced to read The Mythical Man-Month. Most don't understand that software development is a mental job, not a physical one, and everyone's mind works differently. For example I work best coding for two hours then taking a 10-15 minute break, but my boss looks at this as wasted time. I can't tell you how many times I've stared at a problem for hours, stepped away for 10 minutes for a soda break, and come back to figure it out in seconds. NOt taking the break actually wastes time! Also deadlines are important, so be firm on when you can finish a project. If you think it'll take X amount of time and no less, make sure they know it... and if you get into the project and find that you need more time, let them know quickly as opposed to the day before the deadline. I've worked many a late hour because I wasn't up front about a deadline or didn't voice my objections to unreasonable dates. But every company is different. Some have younger management who understands what IT does, but most aren't. And it makes matters worse when you don't have an IT manager or programming lead who doesn't stand up for the folks under them. So sometimes it literally becomes dog-eat-dog... when that happens i suggest finding another gig. Hope this helps --

  191. Best advice I can give by Skrap · · Score: 1

    I've been working on very well-known projects for many years, and the best advice I can give is to avoid shared mutable state.

  192. Some hints by Meowfaceman · · Score: 2, Funny

    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?

    1. Re:Some hints by geekoid · · Score: 1

      Well now, someone is going to get it from there fellow coders.
      First rule about what a programmer actually does is don't talk about what a programmer actually does.

      I hope you enjoyed your index fingers while you had them~

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  193. Talk to your customer by Anonymous Coward · · Score: 0

    You know, the poor sucker who will be using it or the other one who has to try to get some information out of it.
    Your boss didn't and is relying on specifications assembled and eviscerated by a PHB.
    It's amazing how many IT applications were written to satisfy the Pres or VP and don't work because nobody ever consulted the actual user.

  194. Learn how to test by jasontromm · · Score: 1

    Even before you learn how to code, you need to learn how to test software. One of the most brilliant programmers I ever worked with was a lousy tester. He didn't know the first thing about bounds checking and what could happen when people fed him bad data. His programs always worked when he got good data, but tended to blow up when you sent him unexpected data.

    That's the first thing you should learn.

    --
    "Politicians always tell the truth, when they're calling each other liars."
  195. One advice by Anonymous Coward · · Score: 0

    only one thing to add to all recommendations:

    "THE USER IS STUPID"

    never asume that the user can think like you, or reason like you, that's a common error because it leaves a lot of things out for the final product that cause a real pain later.

  196. A few suggestions (from a 30yr veteran) by SpinyNorman · · Score: 2, Insightful

    - 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!

  197. Code Reuse by nied · · Score: 2, Informative

    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.

  198. Some suggestions. by jb523 · · Score: 1

    Whatever you do, don't listen to anyone on Slashdot.

    But seriously, whatever you end up doing, there are a few things that are of value on most any project:

    1. Always try to make your code readable and easy to understand for someone that's not inside your head.
    2. Naming things well is critical. No amount of documentation or inline comments will make code with bad naming easy to work on, and when your code is well-organized with useful names, documentation and comments become much less important. Hint: if you have a hard time naming something, it's usually (but not always) an indication that it's not as well organized as it could be.
    3. Always try to spend a certain amount of time reworking your code to make it easier to understand. 5, 10, 30%---as long as it's something. This will help with #1.
    4. Always try to think about how you can test what you wrote. It will help your designs, it will reduce your bugs, it will help you relate to your QA, and it will help with #1.
    5. Learn to let go. While you can take pride in your coding skills, don't get attached to your code.
    6. Software development is a social skill. Become very good at these: working collaboratively, understanding other people's frustrations, finding ways of working with/around people effectively when you depend on them, articulating your ideas in an e-mail, and explaining to other people what you're doing and why you're doing it. Someone that is a decent programmer and has all those skills is a thousand times more valuable on any software team I've been on than someone that knows everything there is to know about software but doesn't have those skills.
    7. Always try to find a way to make things less painful for your team, or at least yourself. Software development always has certain pain points, and there are usually things that you can do to reduce some of it. RCS/SCM, continuous integration, automated deployment, automated functional testing, a wiki for documentation, an IRC/campfire server for collaboration with people not in your office... all of these are things that can (but won't necessarily) reduce pain on your project. While you might have to pick your battles, never resign yourself completely to the status quo of your software development process.
    8. Everything else is in the details, really. If you continue to learn (new languages, new frameworks, new app servers, new operating systems, new software development methodologies, new tools, etc.), and you keep to these basic guidelines, nothing else is particularly important, whether you're coding Java, C++, PHP, Ruby, Basic. If you're not learning anything new on your project, then try to work with your managers/clients/etc. to change that. Whether you put Java code in your JSPs, whether you prefer underscores or camel-case, whether you put SQL inside strings or use an ORM, whether you write your unit tests first, or last, or not at all, whether you like to put an 'I' in front of your interface names, or a str as a prefix for your String variables, or never use curly braces for one-line 'if' clauses, or swallow your exceptions---these things don't really matter in the long run. You'll probably change your mind on some of your most strongly held positions, and more importantly you need to be able to work effectively with people that hold very strongly to the opposite position.

  199. Don't use Copy & Paste ... by angel'o'sphere · · Score: 1

    And don't program on/for/with .NET ;D

    angel'o'sphere

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  200. Usenet by JeffSchwab · · Score: 1

    1. Use revision control, e.g. Subversion.

    2. Use a formal bug-tracking system. At the very least, numbered text files full of issue descriptions.

    3. Start spending some time in the relevant Usenet groups for the languages and technologies you'll be using. This will expose you to the gamut of good and bad practices, let you hear multiple sides to every argument, and put you in a position to make up your own mind about what conventions you care to follow.

  201. RTFM! by zarlino · · Score: 1

    No seriously, my advice is: Don't follow the "recipes", don't cut & paste code. Always have the REFERENCE docs open and get a real sense of APIs you will be using and their potential. That'll make you a better programmer.

    --
    Check out my cross-platform apps
  202. LordJump by LordJump · · Score: 1

    I won't waste your time pretending to be a programming professional, however I do have to tell you something critical which you no doubt already know. COMMENT, like a madman! Six months from now your own code will be as foreign as a strangers to you. You need to remember why you did what you did, but you won't. COMMENT within the source.

  203. Start counting from zero by Lobais · · Score: 1

    Depending on which kind of coder you want to be, you can also get inspired for an attitude at http://www.catb.org/~esr/faqs/hacker-howto.html?PHPSESSID=22f7378d0d1ea654962a22bf13166a5a#attitude

  204. One Golden Rule by Anonymous Coward · · Score: 0

    My one golden rule for any scripting or coding is to ask myself the following question.

    "Can anyone else look at this code and understand what it is doing and how?"

    If the answer is no then it's not good coding, even if it does what you want. Remember that it might be you that has to return to it in a year or more and you don't what to have to spend hours just working out what you did.

    (Sorry, don't have time to create a login right now)

  205. Re:STOP: Get out NOW !! by kdemetter · · Score: 1

    You are wasting your life away. Go into something exciting, fun, and PROGRAMMING is not any of that. Especially if you are an idiot, like most so-called programmers are today.

    Well , i guess it depends on the job i guess. In my job i have plenty of programming , but there's also a good part research and design ,and that's exciting enough.

  206. Starting point by Anonymous Coward · · Score: 0

    Drug use and excessive caffeine consumption. The best skill to add to your repertoire is probably surreptitious web browsing.

  207. Code stank by try_anything · · Score: 1

    I've worked on code with blocks that size that were not documented as you describe. Finding the corresponding start or end of a block was a big pain in the ass. And you know what? It was a trivial pain in the ass next to the problem of tracing through those garguantuan loops. I document ends of classes and namespaces (} // class Foo) just for convenience, but if you need to document if, for, and while blocks that way, then the code needs to be rewritten. If you have a hundred big loops, then it's better use of time to rewrite one of them than to document all of them.

    1. Re:Code stank by The+Moof · · Score: 1

      I agree that large number of nested loops/conditions need to be rewritten However, we're not always working in a hypothetically perfect situation where we inherit the code and have the time and resources to rewrite it.

      Plus, I've noticed that Visual Studio periodically likes to really mess up indentation once in a while, so the blocks don't always match up.

  208. Just memorize this by blueforce · · Score: 1

    "But it's what you _asked_ for."

    --
    If you do what you always did, you get what you always got.
  209. If you must take college classes... by MoriTeuercen · · Score: 1

    Take factual courses, not process courses. Avoid anything called "software engineering" or "development" anything or "testing" anything. Be doubtful of the usefulness of "proof" of correctness, unless you are working on mission-critical systems. Interesting classes are likely to be assembly language, programming paradigms, data structures and algorithms.

    All those facts you would get in college also exist in books, and generally on Wikipedia, which is why the education isn't necessary.

    Everyone has their own personal cult; no one is right for everyone all the time. Many of them are better than 90% of what is actually done in the field.

    Read books, including all the ones listed here. Also, Implementation Patterns, by Kent Beck. Later, or really, the first time you don't know how to structure something, buy Design Patterns, by Erich Gamma et al. Put it on your shelf, then buy Head First Design Patterns and read it instead.

    Don't be afraid of "Head First" or other intro books; often they will provide the framework to understand the lists of available tools later.

    Learn what tools your group uses, and then learn other tools as they become useful. Profilers, unit test frameworks, IDEs and debuggers will all cut down on the knowledge you need to remember at any given time in order to be effective.

    Most of all, try things out. Don't be afraid to make mistakes, just make them big so they are found. If you don't understand something, try to use it. If you don't know how to proceed try the doing that really stupid thing that couldn't possibly work; either it will or you'll learn enough about the problem to find a different way. Don't get bogged down in either the high-level stuff, or the low level stuff. Eventually you'll realize they aren't that far apart, but in the meantime swap often.

  210. Remember by geekoid · · Score: 1

    It's not your code, it belongs to the organization that pays you to code.
    In other words, drop the ego and protection about it.

    Don't be afraid to release. This is the number one thing I see new programmers do. Work on something, not share and then be afraid to release it into the wild.
    Show experience coders what you are doing, schedule code reviews with the experienced coders.
    Remember code reviews aren't about beating you up, they are about explains different ways of doing things.

    Learn to talk to your 'customers'. ask questions so you can find out what they want and what they are trying to accomplish. This may not be what the ask for. Use common sense.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  211. Corporate Dev by Usquebaugh · · Score: 2, Insightful

    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.

  212. Re:STOP: Get out NOW !! by xonar · · Score: 0

    I am stoner, hear me RooR ;]

  213. Humility by Masters+Champion · · Score: 2, Interesting

    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.

  214. Be open minded, not just OSS minded... by TheNetAvenger · · Score: 1

    Be open minded, not just OSS minded...

    One mistake I see a lot of new programmers make is to follow an belief system, and refuse or be reluctant to expand into other areas outside their belief system.

    Even if you don't have an immediate use for a technology or programming model/language, don't run from it. There are a lot of things to learn from tools that you may never use in production.

    This goes from OSS classics to even .NET and WPF/XAML concepts that are new programming paradigms.

    Absorb as much as you can, and AS A PROGRAMMER, accept all things as viable options and 'part of your profession'.

    The second words of advise, don't limit yourself to programming. With the current markets many employers expect employees to not only be programming geniuses that can do everything themselves, but also manage the servers (web development for example) and be security gurus. The more of these roles you 'understand' the better you are, even if you don't get stuck in these roles, as you will know when the people in the roles are screwing up the operations or making your job harder for no reason.

  215. Re: General Coding Advice from a 20 year programme by geekoid · · Score: 1

    When commenting, write the INTENT of the class/function/method. So when a different programmer looks at it, they know what it is suppose to be doing.
    Always remember, in 6 months, you'll be a different programmer.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  216. Know when to fold it by $criptah · · Score: 1

    All replies on this site are nice and they have a point. Don't worry. Be happy. Read books and learn as much as you can. However, there is one more point: Know when to get out.

    Let's face it, not everybody is cut for software development. If you succeed then great. If you feel like you're not enjoying yourself at work then it is time to go. Many people do not know how to do it and as a result we have a large number of dissatisfied IT workers who basically drag everybody else down. Don't be one of them.

  217. There will be a tomorrow by Anonymous Coward · · Score: 0

    Document first, then code. Then when you get overwhelmed by the long hours and unrealistic deadlines and confused by feature creep, you will be able to remember what you are actually supposed to be doing. And later, you will be able to do maintenance because you will have the documents specifying intent. If you try to document AFTER coding, you won't.

    Document like you will be gone tomorrow. My business partner died and left me thousands of lines of code with no documentation. It took a year to find out that the subtle bug wasn't in the software but actually in the design of the hardware. And if you leave a project, and come back later, you might actually be gone. You will be a different person by then, and won't understand what you had in mind unless you remind yourself.

    Unless you are using a braindead language that cares about it, use lots of white space to make your code clear.

    And keep in mind that the coding is the easy part. Designing a clean approach, careful error checking and handling, fail safe, fail soft, and fail over, great human interface and the like is where a good program comes from. The actual coding can be assigned to a student if the design and documentation are good.

  218. Think how end users will scriw it up... by gwn · · Score: 1

    This might sound mean... but always look at what you are doing with the question "what can the end user do to mess this up?" For years I have watched programmers bang their heads against unexpected responses from users. Often accompanied by exclamations of "not even an idiot would do/type/click/think/attempt that!" So the summary watch phrase would be "expect the unexpected".

  219. Jim's Rules for Commenting Code by jthill · · Score: 1

    Your comments are written to answer questions that the people reading your code cannot readily answer for themselves.

    Your procedure is:

    1. Anticipate those questions.
    2. Rewrite your code, completely, until as few questions as possible remain. If you skip this step, you're a poser hack.
    3. Answer those questions.
    4. Now go back and do it again, treating your comments as you did the code.
      • Eschew excess verbiage!
      • Eschew excess verbiage!
      • Eschew excess verbiage!

    Needless words are a complete and utter waste of time. If you're stuck in some PHB-driven environment that insists your comments provide unneeded answers, find some way of marking what matters. Right-justify the real comments, whatever works.

    Whitespace is a language. Find the arbitrary parts in whatever style you're matching and make your use of them mean something that helps readers. Indent variable definitions differently, to subtly highlight them. One blank line or two?

    Make it mean something. Don't document that meaning, because (a) if you have to document it, it's raising questions not answering them and (b) you're not perfect and the poor you will always have with you.

    re the verbiage rule: the rest of Strunk & White is gospel also. Likewise Orwell's "Politics and the English Language".

    --
    As always, all IMO. Insert "I think" everywhere grammatically possible.
  220. get an engineering degree by Anonymous Coward · · Score: 0

    "training", "mentoring" just don't cut it. this is exactly why the state of the art is so bad. Software development is about designing and building things. Too many here and elsewhere wouldn't think of hiring a self-taught engineer or other professional but somehow think their mission critical applications can be assembled by someone with some help desk experience and no design/engineering education.

  221. State of a state machine by sbeckstead · · Score: 1

    If you do this someone will hunt you down and kill you in your sleep.
    I had to maintain code for a state machine for a disk platter verifier (old style 9" platter IBM monster fixed format) written in C and the moron programmer used 'i' as the state variable. The code was 35,000 lines just for the state machine.
    Try finding every place 'i' gets changed by grepping for 'i'.
    Oh and just for grins and giggles the code only ran on a modified 80186 SBC in a multi-bus embedded computer and the compiler was MS C 3.0 and the development system was across the street from the class 100 clean room that the only machine capable of running the code existed in.

  222. Why oh why by Anonymous Coward · · Score: 0

    So why did I go to school for 4 years in CS and take Cal 3 where I had to hand graph 3D models when I could have just gotten "trained" by my company?!

  223. The basics by Anonymous Coward · · Score: 0

    Learn your tools, all of them, even those you don't know you have.Among these are:
              * Compiler, learn as many options as you can.
              * Debugger, no need to say more.
              * Leak tester, along with other memory problems
              * Profiler, not only for efficiency but to debug with too.
              * Version control, if you company doesn't use any then get one of the free ones and use it yourself, religously.
              * Any tools that come with your OS ( grep, diff ... ).

    Use some common sense. I wish I could strangle every programmer that used a diff or "made changes" for revision comments. Don't reduce the effectiveness with your own stupidity.

    Don't hope for good training from the company. A company will send a C programmer to a week long C++ course and expect them back as experts, at a university you will spend a year learning C++ ( even when it is a second or third programming language ). You're better off buying a book.

  224. Re:Always think about maintenance - offtopic by owlstead · · Score: 1

    Well, you can as easily list all classes within a package as classes within another class.

    You know, it started off with one or two commands. Then it grew, er, slightly. Yes, I might want to refactor and put the classes in a separate package as top level classes. Fortunately these are my runtime functional debug classes, and the class implementations themselves are deliberately sparse.

    Things like this are hardly significant issues, until you spend an hour or two wondering why your code change does not do anything at all, without any warning :(

  225. Read by slapout · · Score: 1

    Read thedailywft everyday. Don't do any of that.

    And don't waste all day reading slashdot.

    --
    Coder's Stone: The programming language quick ref for iPad
  226. Static code analysis, Unit testing + code coverage by owlstead · · Score: 1

    Create clear code, and everything that's still not clear: document it. In code comments (doc++/JavaDoc) is easier to maintain than other documents, so try and keep to that. Use an IDE with automatic code completion and background compiles (Eclipse for Java, Visual Studio is playing catch up for C#/C++), because this is the 21st century.

    Once you are through with the basic basics, see if you can install a static code analysis package. With Java, I really like the combination Eclipse + Checkstyle. I think Lint is the one best known for C/C++. Ask a local Guru to setup a nice configuration for you that reflects the company style in use.

    A static code analyzer works by looking for semantic (what code *does*) rather than syntax errors. It will also look for abuses or possible problems with your coding style. You can catch hints that even an expert would think of (at least not all the time).

    Also learn about Unit frameworks for testing your classes. Personally I think you should use a code coverage tool with that so see how much code you are actually testing. Creating reliable code is about programming defensively and about using the correct tools to go with that. You test human interfaces by giving the code to your local sales dept, there's no way you can come up with Unit tests for that kind of behavior.

    All these hints are pretty useless if you don't have a good support structure within the company though. Contacting the right people will probably be the best way to start. But they will be busy, so have clear questions ready or you will be put off.

  227. Two Words... by bwcbwc · · Score: 1

    Change management.
    Unless your team's change control processes are highly automated and difficult to circumvent, almost all bad code that makes it into production is caused by either:
    a) a very simple, last minute change that "doesn't need to be version controled (or tested or code reviewed), I know it's right."
    b) compiling/packaging the wrong version of a file, either one that is missing a required change or one that contains incomplete changes.

    Actual mistakes in coding usually trail these two issues, since most coding errors are usually caught during testing or during the design and code review process. Most organizations due better at testing and code/design reviews than they do at version control and SCM.

    --
    We are the 198 proof..
  228. Well, I wouldn't start here by dkixk · · Score: 1

    Personally, I really like Peter Norvig's eassy, "How To Teach Yourself Programming in Ten Years"

  229. CodeMaster by Anonymous Coward · · Score: 0

    Write a block of code and then bask in its glory.

    Then attempt to re-write it but shorter and better.

    Loop :P

  230. Thank you for the response by globeadue · · Score: 1

    Thank you all for your response, I've got a good list of books to read, and a wealth of suggestions and pointers. Now off to go grab copies of them and read up.

    --
    ..just because you can, doens't mean you should...
  231. Anonymous Coward by Anonymous Coward · · Score: 0

    Always write your code as if someone else is going to be editing it. This includes tabbing everything neatly and writing as many comments as possible! And don't just write lazy comments either, write clear and descriptive comments as if someone else can understand what your code is doing, without having to reverse-engineer it.

  232. Prepare to read by Anonymous Coward · · Score: 0

    Buy a large bookshelf.

  233. Bill, by Anonymous Coward · · Score: 0

    is that you?

  234. what's the big deal with writing a few comments? by neonsignal · · Score: 1

    Yes, I'll second that. For example, a well written and generic sort routine will be called "sort", and will handle just about anything that is thrown at it. You write a call to sort, and it is redundant to have a comment that says "sort container X". But it makes a lot of sense to say why X is being sorted, or why at this point in the code, or how it fits into the bigger context.

    The comments act to describe the bigger picture; like paragraph breaks in code to describe the semantics of a group of lines. Or abstracts summarizing a whole class, so that there is no need to read the entire code just to understand roughly how it works.

    The primary reason we don't have the compiler checking our comments is not because we don't want to, but because we don't know how to. A little bit of English can convey a lot more meaning than a whole swathe of code, though less precisely. You can live and breathe code, and still not be aware of the programmer's intention without a little hint from the comments.

    Every generation seems to make this assumption that code can be 'self-documenting'. Code can be a wonderfully precise way of describing some concepts, almost mathematical. But that doesn't mean that all concepts can be contained in a self-documenting piece of code.

    You work on programs of hundreds of thousands of lines of code, and uncommented code really does become unmanageable. It isn't that hard; another 20% extra effort as the code is written...

  235. Fellow Pirate by htmlprofessional · · Score: 1

    Yarr, if you wish to be a true master coder, you must become a pirate. Review as much code as you can and pirate the parts you like. If there is something you see which you don't understand, take the time to research it!

    When starting you'll make things harder then they need to be. That's ok, it's just the learning process. If you realize that there is a better way of doing something, stop what you are doing and do it the right way (even if it means a bit of a rewrite).

    You'll find many coders which have been coding for longer then two years, will tell you how their code is the bomb and how you should code like them. Be wary of their advice, but listen to what they say and if it makes sense to you, try it.

    Don't get cocky after two years and think your code is the bomb. Always try new things and keep learning. If you do something one way and you see someone else do it a different way, always sit down and ask your self why one way is better then another.

    I personally love to code and find creative ways of solving complex problems. On the other hand, I've had a couple friends that tried coding for a while and eventually realized that they didn't really like it. Try it out and see if it's a good fit for you.

  236. Data structures & algorithms by Anonymous Coward · · Score: 0

    It sounds like you have little training in computer science, since you're coming into programming via the Help Desk. So I'd urge you to learn about data structures and algorithms. Learn which data structures are good at doing which things. Then choose accordingly when writing your apps. After that, you can back-fill with classes. Try to talk your company into paying for a CS degree.

  237. Coding practices by StewBaby2005 · · Score: 1

    Write your code as if you were a maintenance programmer that got paged at 3am because the critical batch update crashed. IOW, write it clearly and document concisely so the poor dumb schmuck who get's called to debug it has a hope of figuring it out

  238. Do it with gusto and passion! by patrick24601 · · Score: 1

    Do not believe in finites, infinites, right or wrong. In regards to your business logic... If someone says this will always happen this way, be ready for it not to happen that way. If someone says says this will never happen, be ready for it to happen. Plan for bad data. Plan for a connection to another system, database, etc. to fail. Handle it gracefully. Nothing you do in application development is right or wrong so long as it accomplishes the business objectives. There may be better, more efficient ways to do things. But give 10 programmers one business problem and they will solve it 10 different ways. Programming is an art not a science. I would avoid anybody else that tells you otherwise. Do not get attached to a programming language or any code you've written. Don't get pissed off if you burn away a week of your life code some amazing code and then find out it was all for not because of a requirements change. It can be frustrating. But it is just 1s and 0s and in the big scheme of life it is just unimportant. Schedule your life first, then schedule your coding around it. Doing it the other way is just unhealthy. Physically and mentally. When you do code do it with extreme passion. Don't do anything halfass. Always strive to learn something every single day. Be the go to guy at work. Patrick http://stopdoingnothing.com/

    --
    "Action is the thing that escapes most people. Great ideas are a dime a dozen. Great actions are few and far in between.
  239. Things that will make you a better programmer by 1iar_parad0x · · Score: 1

    You can still write good code without having a CS background. Sure, if you designing an operating system, designing a compiler, or delving into some low-level code, more engineering know-how is required. However, I've found my Math/CS background only to be mildly useful when writing database apps...

    Here are some things you can do to become a better programmer...

    Mentorship
    Find someone (preferable a group of people) you can talk shop with. Nobody loves solving someone elses problems, but most programmers like to discuss best practices. Pick apart other people's code. It could be an open source project or maybe just the source code to some guy's game you found online. Maintaining code allows you to see other people's mistakes. Writing good code is hard, writing maintainable code is even harder. You can learn a lot about design by being on the other end of the development process (i.e. maintanance). Sometimes mentorship is just reading good code.

    Read, read, read...
    All the coding in the world will get you only so far. You need to consult the wisdom of experts. Some other good books are:
    Object-Oriented Software Engineering: Practical Software Development using UML and Java by Timothy Lethbridge and Robert Laganiere
    2nd edition
    website for book
    They even have a DVD with an entire semester's worth of lectures (based on the book) available for $50 online.

    Applying UML and Patterns
    by Craig Larman
    3rd edition
    sample chapters here
    There's a series of videos (about 3 hours in length) that describe many of the details in the book.

    Anything by Martin Fowler
    Martin Fowler's website

    You may wish to also check out:
    A seminar on the Object Oriented Design with a focus on the Unified Process (or something close to it)

    Methodology, methodology, methodology

    The above books will introduce you to many of the existing methodologies in software engineering. It's not so important what methodology you choose; what is important is how you implement it. While many people may disagree with me on this. Engineering methods can be taught, problem solving skills can be acquired, and math skills can be learned. You might not be the next Edsger Dijkstra, but you can learn to write very good code on schedule and under budget. It may be hard to write code at home when you've been writing code at work all day, but try working through a project from beginning to end with perfect documentation (yes, make use cases...) utilizing all the right tools (i.e. version control, bug tracking, make tools). Doing this will make you a better programmer. Learn to take a few minutes each day and write out what your going to do. I often start writing code for the day by opening up notepad and figuring out what I'm going to do in psuedo-code. After, I just flesh out the notes and spend the rest of my time testing. Some guys like to do this on paper. Many professional organizations start out a days worth of coding drawing UML (or some close approximation to it) on a white board. The key is to plan before you code. Don't just jump in front of your IDE.

    --
    What do you mean my sig is repetitive? What do you mean my sig is repetitive? What do you mean....
  240. Kids... by Anonymous Coward · · Score: 0

    *Opens .vimrc, checks options*
    :set backup
    Kids these days.

  241. Simplicity by ddoctor · · Score: 1

    The best advice I can give is: PLEASE, PLEASE, seek SIMPLE solutions to everything.

    Look for patterns in the problem domain that map elegantly to capabilities in the solution domain. e.g. "this looks like a grid" database table/spreadsheet/array. Try to look for solutions that involve the least code, and will cope best with change.

    Don't do overarching "this will solve everything" framework solutions. Avoid the "inner platform effect" (see thedailywtf.com)

    A bunch of other things:

    If you find yourself saying "this is just a quick hack, we'll fix it later", then that's a bad sign. Find a better solution.

    Ask questions. Ask lots of them. Don't worry about being annoying. This will help you in not repeating peers' mistakes, and in not duplicating code. Work closely with more experienced staff members. Learn from them.

    Leave your pride/ego at the door. Don't get attached to your code. Accept criticism. You still need to stand up for what you believe to be right - more senior people can still make crappy solutions. But, remember the politics and pick your battles.

    Stir things up... but just a little. People get set in their ways, and this stifles innovation and improvement. As the new guy, you have a unique perspective, and your fresh ideas can help. In this game, there is no "one way" to do things, but established teams and experienced engineers often fall into the trap of thinking there is.

    Whenever you find a solution, look for another one. Your first thought isn't always the best solution.

    Learn from the team culture, norms, "this is how we do it around here". Fitting in is often (not always!) more important than doing things right (e.g. a solution cohesive with the rest of the codebase can be better than an otherwise superior solution). But, be sure to make a distinction between what you think is right, and what your team norms are - this is important, because both will influence how you solve problems now, and in the future.

    Remember, not everything is best solved by writing code. Integrating existing components, or using existing components can save a lot of time.

    Also, remember that there are thousands upon thousands of dumbshit hacks in the software engineering world. Beware of them and please do not become one of them. Focus on your skills and continually train yourself.

  242. Good Rule by Jaime2 · · Score: 1

    Always remember that just because it passes all the unit tests and gets through QA, it doesn't mean that it is good code. The first level of acceptability is "Does it work?". Make a concious effort to make your code maintainable and extensible.

  243. VB scum detected!! ALERT! by TiggertheMad · · Score: 1

    The logic in the spec isn't 'like it (then) use it', and it makes no mention of leaving it alone in the case of not liking it, so your syntax is incorrect. Please re-read the spec.

    Also, camel case is often favored by VB programmers. While it would be an assumption to call you a VB programmer, I will risk that rather than suffer a VB programmer to live. Please report to the nearest self-immolation center for immediate incineration. Thanks for your co-operation, and have nice day.

    --

    HA! I just wasted some of your bandwidth with a frivolous sig!