Take the 2-minute tour ×
User Experience Stack Exchange is a question and answer site for user experience researchers and experts. It's 100% free, no registration required.

I'm working on a project that aims to teach programming novices. I want them to follow specific guidelines of programming and get accustomed to those (due to the fact that these guidelines are generally accepted as 'best practices').

Therefor I wanted to use a program that can react to the various actions taken by the user while programming (e.g. creating an Object).

Should this program rather admonish 'bad' behavior or compliment 'good' behavior? Is there any (scientific) evidence that one of these ways (or a mixture of both) is considered more efficient or appropriate for certain situations?

share|improve this question
add comment

1 Answer

I would like to think that programmers would like to know when they're doing something "wrong", since poor code is usually inefficient (to write or execute), difficult to maintain, or both.

When pointing out low quality code, the ideal way would be to show them a better way to write it. There's a Haskell pastebin that I occasionally use that points out all sorts of things like unnecessary parentheses or recommends a different function than one I've used.

For instance, this is how I was writing a particular piece of code in Haskell:

withTransaction (
    (sequence_ $ map (PG.execute [sqlFile|sql/deletePhoto.sql|]) photos)
    )

This is the cleaner way of writing it that does the same exact thing:

withTransaction $
    mapM_ (PG.execute [sqlFile|sql/deletePhoto.sql|]) photos

I would have never known about the cleaner way if it hadn't been pointed out to me, and I am always happy to learn these kinds of shortcuts.

Sometimes what's wrong can't be demonstrated by showing a neat little block of code because it is a fundamentally bad design to begin with (such as using prototype on native objects in JavaScript). Ignoring these types of mistakes (provided you are able to catch them) won't help the user. As long as you show the user in a clear, objective way why their code is bad along with a better way of solving the problem, the user will benefit.

Sometimes the best way to learn is to make mistakes, but mistakes can be difficult to discern for a new programmer.

share|improve this answer
    
I'm afraid, users will be quite frustrated after some time, if I'm only pointing out 'bad' code (which will frequently be the case for beginners)... Apart from that, I totally agree with your opinion! –  Stefan Surkamp Dec 11 '13 at 21:02
    
I guess you could think of it like a spell checker. The spell checker shows you which words are spelled wrong according to its dictionary and allows you to pick from a list of possible matches. Do users get frustrated when incorrectly spelled words are pointed out to them? –  cimmanon Dec 11 '13 at 21:12
    
Well, of course, if you're willing to be corrected! ;) On the other hand, if you are a novice and quite insecure about what you do... getting corrected all the time can be quite discouraging, I suppose. –  Stefan Surkamp Dec 13 '13 at 9:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.