Slashdot Mirror


Ask Slashdot: How Would You Teach 'Best Practices' For Programmers?

An anonymous reader writes: I've been asked to put together a half-day workshop whose title is "Thinking Like a Programmer." The idea behind this is that within my institution (a university), we have a vast number of self-taught programmers who have never been taught "best practices" or anything about software engineering. This workshop's intention is to address this lack of formal training.

The question is, what should be covered in this workshop? If you have an idea -- that also has an example of best practice -- please share!

It's really two questions -- what "thinking like a programmer" topics should be covered, but also what examples should be used to illustrate best practices for the material. So leave your best thoughts in the comments.

How would you teach best practices for programmers?

27 of 220 comments (clear)

  1. Learn math by Master5000 · · Score: 5, Interesting

    There is no way around it. Never seen a great developer without strong analytical skills.

    1. Re: Learn math by Reverend+Green · · Score: 3, Insightful

      Imho grammar is at least a important as math. If a person speaks like an illiterate rube, chances are he'll program like one too.

    2. Re:Learn math by PolygamousRanchKid+ · · Score: 4, Funny

      I think a combination of the "Wizard of Oz" approach and Cognitive Behavior Theory would be very effective here.

      Never seen a great developer without strong analytical skills.

      I've never seen great developer, or actually, someone who thinks that he is a great developer, who didn't look, smell and act like one.

      Do not shave your neck any more.

      Stuff yourself with unhealthy junk food; preferably, while working at your keyboard.

      Think that you are a super-genius and all your colleagues are idiots. Convince yourself that your code never has any bugs, and the problem must be somewhere else.

      Showers and baths? Forget it. The whole world is in a drought, and you need to save water.

      Get yourself into meaningless arguments about trivial things like vi vs. emacs. Refuse to stop arguing, even when everyone else has left the room.

      In short, you don't need to be a great developer! Just play one on TV!

      --
      Schroedinger's Brexit: The UK is both in and out of the EU at the same time!
    3. Re:Learn math by Anonymous Coward · · Score: 2, Insightful

      Logic is a branch of mathematics.

    4. Re:Learn math by Immerman · · Score: 3, Informative

      Other way around - mathematics is a strict subset of logic, which also applies to realms well outside mathematics.

      --
      --- Most topics have many sides worth arguing, allow me to take one opposite you.
    5. Re:Learn math by arth1 · · Score: 3, Insightful

      There is no problem finding good mathematicians that knows jack shit about logic

      Name one.

    6. Re:Learn math by Z00L00K · · Score: 5, Insightful

      Always break down the problem into small parts that are easy to manage and test.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    7. Re: Learn math by jimtheowl · · Score: 2

      "These topics are too subjective to be tied to logic"

      Correctness and performance are directly tied to logic.

      "Sadly, this is why programming is still an art"

      That is not sad at all. Musical theory requires understanding some physics and mathematics. No one would ever despair at the thought that great musicians are creating art.

      ".. using the two in the same sentence is disrespectful to logic."

      That very sentence lacks the latter. Do you think that logic is offended?

    8. Re:Learn math by TheInternetGuy · · Score: 2

      There is no problem finding good mathematicians that knows jack shit about logic

      Name one.

      Hey, now... you can't just go around demanding that random people on the internet be ready to back up their claims with sources, or facts even.

      --
      If my comment didn't sound as good in your head as it did in mine, then I guess we all know who's to blame
    9. Re:Learn math by 14erCleaner · · Score: 2

      Get yourself into meaningless arguments about trivial things like vi vs. emacs. Refuse to stop arguing, even when everyone else has left the room.

      God intended Man to put the opening bracket on the same line as the if statement. No corporate drone's so-called "standards" can convince me otherwise.

      --
      Have you read my blog lately?
  2. Back to basics by Calydor · · Score: 3, Insightful

    Indentation and comments.

    Stopping for a moment to ask yourself if you NEED to load a 50 MB library for two lines of code.

    --
    -=This sig has nothing to do with my comment. Move along now=-
    1. Re:Back to basics by Strider- · · Score: 5, Insightful

      Oh hell no. So-called “self-documenting code” isn’t. You can write the most comprehensible, clear code in the history of mankind, and that’s still not good enough.

      The issue is that your code only documents what the code is doing, not what it is supposed to be doing. You wouldn’t believe how many subtle issues I’ve come across over the decades where on the face of it everything should have been good, but in reality the code was behaving slightly differently than what was intended.

      --
      ...si hoc legere nimium eruditionis habes...
    2. Re:Back to basics by JaredOfEuropa · · Score: 4, Insightful

      The issue is that your code only documents what the code is doing, not what it is supposed to be doing

      Mod this up. I aim to document my intent, i.e. what the code is supposed to do. Not only does this help catch bugs within a procedure, but it also forces me to think a little bit about the purpose of each method or function. It helps catch bugs or inconsistencies in the software architecture as well.

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    3. Re:Back to basics by Anonymous Coward · · Score: 2, Insightful

      Don't comment your code. Code your comments.

    4. Re:Back to basics by swillden · · Score: 2

      The issue is that your code only documents what the code is doing, not what it is supposed to be doing.

      You can document that with good names. No need to add comments that are likely to become actively misleading.

      Javadoc-style comments are useful (and, actually, if you're writing appropriately-small functions provide all the space you should ever need for documenting the rationale), but inline comments are a code smell. If you feel the need to type a comment explaining what a small block of code does, that's a hint that the block should be factored out so that you can name it something that documents its purpose. Then the function call will be self-explanatory -- and your code will be more modular and probably more testable as well.

      You wouldn’t believe how many subtle issues I’ve come across over the decades where on the face of it everything should have been good, but in reality the code was behaving slightly differently than what was intended.

      I would absolutely believe that because I've been there more times than I can count... and most of them were cases where the code was commented but the comments were wrong. This has happened to me so many times that when wading into complex new code I often make a pass first and delete all of the inline comments. And I treat those that remain with skepticism and never believe them without double-checking the code.

      The problem with comments is that they bitrot more than the code does, because code often gets changed without careful updates of the comments.

      Note, however, that when I'm teaching beginning programmers, I teach them to comment the hell out of the code. Beginners forget that their primary audience isn't the compiler, it's other programmers. Once a programmer has a few years of experience under his or her belt, though, it's time to start treating comments as a hint that the code needs to be improved until the comment is unnecessary.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
  3. Fuck Off With Your Workshop Bullshit by NicknameUnavailable · · Score: 2, Insightful

    The basic summary is: you don't know how to code or you would know it takes a decade of trial and error to get good, even after learning the basics. It's sure as shit not going to happen in a half-day workshop and teaching "best practices" will at most create a zealot who doesn't know what the Hell they are doing and is adamant about not learning. Code workshops don't work, best case scenario you're a lazy low-or-moderate-ability programmer, worst case you're a marketing hack.

    TL;DR: Stop tricking idiots into giving you money, you parasite.

  4. Electric shocks by raynet · · Score: 4, Funny

    The most efficient way to teach best practices is to give the programmer electric shocks for every error, and more for bugs caught in testing. For approved commits you may award them with treats.

    --
    - Raynet --> .
  5. CERT Secure Coding Standards by achowe · · Score: 2

    Start with the CERT Secure Coding standards, especially for C programmers it covers many of the "gotchas" to watch out for.

            SEI CERT C Coding Standard: Rules for Developing Safe, Reliable, and Secure Systems (2016 Edition)
            https://resources.sei.cmu.edu/...

    Apparently they them for other languages like C++, Java, Perl.

  6. Easy by 110010001000 · · Score: 2

    With a bat.

  7. I think you mean standard practice by Pinky's+Brain · · Score: 2

    Stumbling towards a steaming pile of shit with flavor of the day development strategy, flavor of the day framework and flavor of the day lingo and absolutely never with any structural ways to avoid the most common security flaws we have been aware of for multiple decades. That's what you have to teach them.

    They want a job, knowing best practices isn't conducive to that.

  8. Sytematic program design. by AeiwiMaster · · Score: 2

    A couple of years ago I took a MOOC called "systematic program design."
    Even though I was a self tough programmer and had been programing for 25 years,
    i still learned something new.

    They used this book
    https://www.amazon.com/How-Des...
    I recommend you check it out and google the course name.

  9. Be aware that other people cannot read your mind by Anonymous Coward · · Score: 2, Informative
    Before you change anything ask yourself the question "Will this affect someone other than myself?"

    If the answer is "yes":

    1. a) Have you updated the docs?
    2. b) Have you consider users who may be reliant on the old way?
    3. c) Have you considered the people that have to support, sell or market your software?
    4. d) Does the change need to be verbally communicated in meatspace to other people in your org?

    Basically, never assume that checking in code is the final step

  10. Humilty, but you can't teach that by petes_PoV · · Score: 3, Interesting

    we have a vast number of self-taught programmers who have never been taught "best practices"

    Arrrrgh! The worst sort.

    These people tend to be rank amateurs. But with the "experience" that makes them think they are actually professionals. Almost none of them are. And most never will be.

    Most people, even people who make a living from programming, are much worse at it than they think they are. They are impatient, they are hit-and-miss, most can't think clearly and an unfortunate number share in the twin misconceptions that "if it compiles cleanly, it works" and that testing is merely a stage that comes between coding and release to production (and is not there to fix problems, merely to tick boxes).

    Personally I would focus this workshop on the cost of the errors made - and target it at the senior people there. Drum it home that "good" software - best practices is not about how many million lines of code you can write in a day, nor about how complex you can make an algorithm. It is about being able to hand your work off to others and the ease with which they can understand what it does.

    --
    politicians are like babies' nappies: they should both be changed regularly and for the same reasons
  11. Re:Not that difficult to say but hard to do by Immerman · · Score: 2

    9. Distrust your darlings - if you've done something very clever that you're quite proud of, it's probably a good idea to give it a good hard looking over with a critical eye (or better yet, have someone else do so), and see if you haven't made a grossly over-complicated solution in search of a problem, when something much more straightforward could do the job better.

    I'd disagree with (6) though - it needs more thought between "read" and "ask".

    --
    --- Most topics have many sides worth arguing, allow me to take one opposite you.
  12. Teaching explicitly what experts hold tacitly by michaelderaadt · · Score: 2

    During the 1980s, there was much research into the psychology of experts and that included programmers. Soloway et al found that experts exhibit tacit problem solving skills that they apply automatically. I completed research work a few years back looking at the effects of teaching such skills explicitly to novice programmers. If you're interested, here's a good starting point... http://crpit.com/confpapers/CR...

  13. Re:Not that difficult to say but hard to do by pjt33 · · Score: 2

    Point 5 could be strengthened. Don Knuth doesn't act like he knows it all (source: personal experience), so certainly no-one else should.

  14. Re:There is a huge problem with math though ... by arth1 · · Score: 2

    They fail at math, not because they are bad, but because

    Oh, in many cases they fail at maths because they are bad.

    It's politically correct to pretend that there is no such thing as aptitude and that everyone is equal. This is a blatant lie, and everybody knows it's a lie, but everybody plays along, because either you benefit from the lie, or it is the least dangerous move if you value your future and career opportunities.

    I worked as a maths tutor for people who struggled, and in some cases, they had not been properly taught the underlying fundamentals and "seen the light". Those were very teachable; finding out just where the blockage was would generally lead to going through years of missed teaching in weeks.
    Others... lacked ability, and the job was making them do the most of the abilities they had, and perhaps become good at particular tasks. But they would never understand it and intuitively be able to apply it for new situations, just be able to do tasks.

    Much like a colour blind person can never truly understand the colour differences he (most likely) isn't seeing, someone without the ability to see the logic and abstractions of maths will never truly understand what she (most likely) isn't seeing. Yet both can function well in society despite their handicaps. But part of that is acknowledging that there is a handicap, and that the correct response then isn't go give up and blame the handicap like too many do, but to learn to compensate for the handicap as much as possible.

    As for aptitude deficiencies, they vary, and seem mostly based on different levels of abstraction. While most are able to understand concepts like calculus or dimensional transformations, some struggle. A few have a hard time with algebra and statistics, and yet others are unable to intuitively grasp a concept of zero. At the other end, a majority seem unable to grasp relativity, and especially being able to abstract time as a local phenomenon where words like "before" and "ago" loses all meaning.

    Teaching can help people cope with the different levels of aptitude, but not change the underlying brain any more than you can teach someone to distinguish colours they just cannot see.