<br><br><div class="gmail_quote">On Tue, Apr 12, 2011 at 10:34 AM, Mark Sienkiewicz <span dir="ltr"><<a href="mailto:sienkiew@stsci.edu">sienkiew@stsci.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Alfredo Deza wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
But programming is hard too. So it shouldn't matter that UnitTest *might* be difficult to grasp. If you want to get better<br>
you might as well get used to learning things that are not easy to understand at first.<br>
</blockquote>
<br></div>
I mostly agree, but not with this part. You can't teach people by throwing all the complexity at them at once. If you want to make a beginner try to avoid testing whenever possible, force them to concentrate on the mechanics of using unittest instead of the benefits of testing.<br>
</blockquote><div><br></div><div>This was a personal opinion, not something that I mentioned in my talk. You are right though; you can't teach people by giving them all the </div><div>complexity at once, however... you are assuming that this crowd (and maybe others?) have the luxury of learning from someone else. </div>
<div><br></div><div>Not a single University teaches Python (in Peru, where I gave the talk) and most of the graduate students have to pick it up by themselves to </div><div>cope with the Python developer demand. If you are self-taught and start searching for "Python testing" in any popular search engine you can verify</div>
<div>that almost all the results talk about unittest.TestCase and show how to implement tests with classes and inheritance.</div><div><br></div><div>I was able to get *one* result that returned something about doctests. None talk about how to use assert in a test function and run some tests.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
For a beginner, you want a simplified system. Did you ever study introductory physics or calculus and solve the problem where you drop a ball from a certain height and find when it hits the ground? The problem is always "neglecting air resistance" because dynamic friction makes the problem too complicated for a beginner.<br>
<br>
But how can we make tests simple enough for a beginner? Consider this test that works in nose:<br>
<br>
def test_1() :<br>
x = add(1,1)<br>
assert x == 2<br>
<br>
A beginning programmer can understand this. They don't need to think about "fixtures" or "suites" or "test cases" or "runners" or even how object inheritance works. You can start teaching somebody to program in python, and on the first day they can write tests for their very first program.<br>
</blockquote><div><br></div><div>Absolutely, just as long as someone experienced is teaching a beginner. This would probably be the way I would approach teaching it to someone new. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Someday, when they become more experienced, maybe you can show them a benefit to unittest. But when that day comes, you don't have to persuade them that testing is a good idea -- they will already know that. Instead, you can concentrate on the question at hand: Why should I use unittest? What does it do for me that I can't do more easily in some other way? How does this complicated thing work?<br>
<br>
Nobody ever tries to present a "steep learning curve" as an advantage, because we know systems like that are hard to use and people want to avoid using them. People find new material much more accessible if you structure it as a series of smaller steps.<br>
</blockquote><div><br></div><div>This just doesn't happen in self-learning. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Mark S.<br>
<br>
</blockquote></div><br>