Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

January, 2009

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Are You Smart Enough To Debug Your Own Code

    • 6 Comments

    I collected a whole bunch of links recently and have just started going through them in depth. One of them was a blog post called A Double Handful of Programming Quotes. The first quote in the list was this one:

    “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

    This is one of what I like to call a thinker. What does it really mean? At first it sort of makes one think that he is saying that people are not smart enough to debug their own code. Clearly that’s not right though. Is it? I think not. What I think he is really saying is that it doesn’t pay to be too “clever” or tricky in your code. It the code you right is some sort of tour de force that takes every ounce of your skill and knowledge then you’ll be in trouble if (when) something goes wrong. This may work when you are a new programmer working hard to stretch yourself and have a mentor or instructor with far greater skill than you posses but if you know it all like some of us do … Well maybe you shouldn’t be showing off too much.

    I’ve seen a lot of beginners write code that was too complex for them to debug themselves over the years. Often this happens because they try to write too much code at once before testing any of it. Or they get clever by using something they barely know and are bitten by unexpected side effects. As a teacher (or mentor) more experienced programmers see that a lot. most often it becomes a good learning experience. But for those learning on their own it can be a nightmare. That’s one of the reasons I believe most people are better off learning with others – a teacher, a senior developer or some other mentor who has gone before.

    This is also an argument for keeping things as simple as possible. Sure you have to do some tuning at times. And sometimes you have to use some advanced “tricks” or tools that push you to your limit. But if/when you do you should be pretty careful how you use them. (And maybe read the documentation as well.)

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    CWE/SANS TOP 25 Most Dangerous Programming Errors

    • 1 Comments

    It’s rare when you can get a bunch of software people to agree on much of any thing. Just think of all the programming language wars going on and the debates over what browser or operating systems to use. So when I hear that a bunch of experts have agreed on the most dangerous programming errors that gets my attention. What I found what the CWE/SANS TOP 25 Most Dangerous Programming Errors list.

    The impetus for this list was in large part better software security. Reliability was a concern as well of course. But security is getting a lot of attention these days and programming errors are responsible for a lot of security issues in software.  I don’t  underestimate the amount of security issues caused by people problems but we can’t fix them in code. We can however build more secure code. So this list will help a lot of organizations in the future. In my opinion education is a key piece and the people behind this list agree.

    Colleges and others who prepare programmers will use the Top 25 Errors as a foundation for curriculum that ensures their students know how to avoid the critical programming errors. One of the colleges that participated in developing the Top 25, UC Davis, has already established a secure coding clinic where student-written software is reviewed for the key programming errors that lead to critical security vulnerabilities. The Top 25 enables the clinic to prioritize errors in its review. Other colleges are beginning to emulate the secure coding clinics.

    Besides the list itself there is a lot of supporting information on this page though. There are quotes from experts explaining the importance of these errors and for programmers to learn about them and how to avoid them. I think this is a great list for students, even beginners, to know about and to ask questions about. For professional programmers or those who expect to become professionals this list is a must read.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Teach Yourself Programming in Ten Years

    • 4 Comments

    I remember when I finished first grade and I thought I was done with school. The reason I wanted to go to school in the first place was to learn to read and at the end of first grade I thought I had that down cold. What more was there to learn? I see some of that with programming as well. People take a first programming course and they think they’re done - they’re programmers! Well not so fast. There is more to it than that just as there was more to learning and even reading when I finished the first grade. Others come to me and tell me they want to learn enough programming to create a specific application (rarely one that is that easy) or the next Halo 3 (never that easy) or something. There is this cram school mentality that seems to overtake so many people. Unfortunately, programming like so many things takes a while to really, deeply learn.

    I ran across the article Teach Yourself Programming in Ten Years by Peter Norvig recently and it does a good job of addressing this very issue. Here is a key paragraph from that article:

    Researchers (Bloom (1985), Bryan & Harter (1899), Hayes (1989), Simmon & Chase (1973)) have shown it takes about ten years to develop expertise in any of a wide variety of areas, including chess playing, music composition, telegraph operation, painting, piano playing, swimming, tennis, and research in neuropsychology and topology. The key is deliberative practice: not just doing it again and again, but challenging yourself with a task that is just beyond your current ability, trying it, analyzing your performance while and after doing it, and correcting any mistakes. Then repeat. And repeat again.

    What is key in so many of these endeavors? Practice. Careful, deliberate practice. One can get that practice several ways – projects in class, projects while working for a living, projects for fun and competition (Imagine Cup is a great one for college students USACO is good for many high school students.), and more. But programming is still a skill – some would say an art or perhaps a craft – and it takes practice to get good at it.

    Some students like to point out some of the top programmers in the world did not go to college or dropped out (Bill Gates for example) but they neglect the fact that those people all practiced A LOT! They wrote code day and night. Plus of course they are really really smart. For most people I think formal training is a huge help and speeds up the learning process greatly. But in the end practice is what makes it work. That and a willingness to learn constantly. The article includes a recipe for programming success that lists more items than just practice BTW. I think it undervalues formal training but it does include it.

    The relative merits of formal training and practice and what the ratio should be makes for an interesting discussion. I really think the best people have some of both. What do you think?

Page 1 of 8 (23 items) 12345»