Should we teach Unit Testing Along with Programming?
I have a hit and miss track record with Unit Testing. I grew up in the days when Delphi just came out and Universities were just starting to switch from teaching Pascal to teaching Java. When I was learning GWBASIC and others as a kid, our biggest concerns were running out of preceding line numbers. So I could understand why Unit Testing would not be a big thing to teach in my time frame. But we’re in 2020 now…
I’m watching as my oldest son is taking his first computer class. It’s in C++, probably because the instructor has more of a background in electrical engineering than website development– which is what he’s going for. The basics of coding are the same (for the most part) and if you learn one C variant the odds are that you’ll be able to move between them with ease.
What’s important is to get the mindset for how to code down now, so that they patterns that you follow in the future will be good ones. In short, we want well thought out code, not spaghetti code. Maintenance is a thing.
Given what I stated in the previous paragraph, why aren’t we teaching Unit Testing first?
Ok, ok… Maybe they need to know how to do conditionals, loops, and functions before they’re ready for Unit Testing, but why aren’t we teaching how to make sure that your code is setup in a way that you can unit test it, how to think about testing…
Or at least we should be providing a unit test suite to these labs that are handed out so that you could run your test against it and have it work correctly rather than having students submit assignments that don’t work. I mean, isn’t the point for them to learn rather than to play gotcha?
I can only think of a few reasons why we don’t do this:
- We were never trained on Unit Testing
- We’re too lazy to write the Unit Tests
- We wouldn’t have any idea how to grade the submissions if their answers were correct.
That last one is the sticky part, but it is also lazy. We could grade oh how they structured their code (the layout), whether their solution was a good/optimal one, or other things that would take time to resolve.
Maybe I’m too hard on the state of teaching coding today, but when there are many online places to learn, colleges need to keep up if they want to be considered seriously. The quality of the coder coming out of University should be high class, and that’ll take being more creative with how we teach the subject and putting more work in.