From: Phillip Gawlowski Date: 2009-12-30T02:46:09+09:00 Subject: Re: Creating my own method for sorting an array On 29.12.2009 18:32, Marnen Laibow-Koser wrote: > Yup. It's more fun to program with good tests. You can go faster, and > you can see things work right away. Hahahaha. No. Tests are a safety net (and a rather thin one), that a beginner doesn't need. It's a good habit to get into, yes. After a beginner knows what this "programming" thing is, and thus can understand what tests are, and how to write a good test. A *test* is another level of abstraction that a beginner at programming doesn't need, and doesn't understand as yet. And an improperly written test is worse than no test at all: It makes you believe that your code is correct when it isn't. > Anyway, if he's really a new programmer, he shouldn't be writing sort > algorithms. Why not? It's the most basic algorithm there is, allow fancy-pants things like recursion to be explored with (comparative) ease. > I didn't say a word about design patterns. All I recommended was tests. > These actually make it less confusing, since you can more clearly see > what's going on. Tests *are* a design pattern. > And we'd all be better programmers if we thought about good practice as > an integral part of the craft, not something bolted on later. Every apprentice, in any craft, learns the basics of a craft first, and *then* moves on to the complex things. Would you expect a carpenter to be able to plan a table before s/he is able to hold a drill properly? >> Yeah, the way I tell if I have a working program is (generally) to run >> it. > > The tests run it for you. Have you ever actually tried this? Sounds > like not. Tests don't run a program. They check if a part of a program, an atomic piece, is correct as defined by the test. > For "hello world", yes. For anything more complex, no. And a sort > implementation is certainly complex. You don't need tests for something complex. Nor do you need them for something "simple". You need them for something that requires *correctness*. > I did give him some guidance. Now, since you brought it up...what > guidance have *you* given him? Good guidance: Not to listen to know-it-alls unable to grasp what's appropriate for a given situation and what isn't. -- Phillip Gawlowski