From: Marnen Laibow-Koser Date: 2009-12-30T02:32:45+09:00 Subject: Re: Creating my own method for sorting an array Alex wrote: > On Tue, Dec 29, 2009 at 11:47 AM, Marnen Laibow-Koser > wrote: > >> > I don't see how that is a stupid exercise. I reckon this is not >> >>> lists. That's the recursion part. >> > Way to kill the enjoyment of programming, dude. This guy is a new > programmer, and you're talking to him about tests? Yup. It's more fun to program with good tests. You can go faster, and you can see things work right away. Anyway, if he's really a new programmer, he shouldn't be writing sort algorithms. > When I started out, I > certainly didn't care a single bit (GASP!) about how well-written my > programs were, or if they followed good design patterns and whatnot. > Exposing him to this stuff is just going to make it even more confusing > than > it needs to be. 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. 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. > > >> >> > When I started learning software development I >> > certainly got more kick out of a working program than a working unit >> > test before hand. :-) >> >> It's the working test beforehand that lets you know when you have a >> working program. It really is best to write the tests first. Read up >> on test-first development and apply it religiously -- it really is worth >> it. >> > > 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. > True, a new programmer could write a test to ensure that his "hello > world" > program works right, but isn't that a little silly? For "hello world", yes. For anything more complex, no. And a sort implementation is certainly complex. > > >> > >> -- >> Posted via http://www.ruby-forum.com/. >> >> > > Seriously, guys... He's trying to write a sort algorithm. I wrote many > of > them when I was starting out, trying to figure out what was going on. > What's > the problem here? Let's give him some guidance, not talk about how dumb > it > is to write that, because no one would use it in "the real world." I did give him some guidance. Now, since you brought it up...what guidance have *you* given him? > You > know > what else no one ever used in the real world? That slot machine program > I > first wrote. All those "hello world" programs I wrote. All the > algorithms I > re-implemented, trying to learn how they worked. Does the fact that no > one > will ever use them make them worthless? Or maybe the experience I gained > from writing all that worthless code made me a better programmer. I'm sure it did. I know I've done similar exercises. But I did want the OP to realize that he shouldn't expect to ever do this in a real Ruby program. > > > Alex Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.