Why is it that my engineering-slanted child is getting taught how to code, without getting taught how to test their code?
Let me just lay out the actual picture a bit here, not all kids are into coding, I have 2 boys, I have not at any point tried to force them to become engineers, I’m just a lazy parent. I have thus, done a fair few Computer-science (CS) homework assignments with my 2 boys. I never do any typing. This pictured keyboard was built by kid2 his older brother is not into such things, but that did not stop both of them trying to emulate their father. Unfortunately kid1 is just not really technical like his younger brother, you cannot win them all.
So my gripe - is multiple really. They get given an assignment, write battleships the game on C#. Okay so my last real C# coding was a bit of code reviewing 8 years ago and some coding almost 20 years back now. So I’m struggling to build this too, but the teacher has asked them to write the game with simplified and changed rules. The rules I objected to
- ships may touch
- the grid is 8x8, no battleship, cruisers only
- they somehow swapped the size of the submarine and the destroyer
Why, just why? Okay well, that’s not my gripe really I’ll get back there in a moment. Why teach kids to build something that does not actually do the job, the Biff and Chip reading books curriculum specifically pissed me off when I was young, I had similar book as a young-un and my gripe was that we were getting taught to read, write and definitely not to “say” short almost pointless sentences that actually had no meaning because they were often missing all of the parts of a basic sentence. In carpentry or woodshop, we teach kids how to sandpaper and varnish a piece of wood before we teach them to saw, before we teach them how to make joints, and then to finally build a cupboard. Each year we had a complete take-home and display or use it woodwork project, none of this half-working game of Battleships. We had a thing that was done, and we all know the definition of done includes one ingredient, and it’s not varnish. Why is coding done backwards? It’s like the chef who never tastes the food he/she makes, we can do better at this.
Coding Is Hard
He has already written a “partly” working program, but even my untuned C# eyes can smell the terrible stench of bad code just walking past, so I dive in and refresh my C# skills. These are my gripes.
- copy-pasta code : do not teach kids copy to copy-paste code and write a 40 lines long function when 10 functions of 4 lines each will allow you to refactor bigtime - at this point I pull out a actual paper copy of Folwer : Refactoring - yes that whole volume, I politely explain , that this is for reading later, and only to read up to chapter 1 and no furthur.
- They have not taught them to design their program - I spent a long time explaining how code is really really hard to write, and all the refactoring we had to do was because, it’s well hard. designs will very often be “emergent”. It’s impossible to write correct code the first time, and this leads to the clincher for me.
- The teacher is not a practitioner. So they teach it like in the book and have missed out so many key OO programming concepts like the correct use of base classes and interface classes.
- He does not know about NUnit. That should have been the first thing the teacher taught or at least mentioned as a way to write refactorable code safely, because hellooooooo it saves time because each line of code comes with maintenance cost, so why would you not want to refactor?
You cannot refactor without some kind of check or test.