[Tutor] software carpentry

Alan Gauld alan.gauld at freenet.co.uk
Sun Feb 26 16:46:09 CET 2006


> But the Software Carpentry Workshop was a revelation. It gives a great
> deal of advice based on empirical studies on effective programming
> practices. I´m partway through - it's a multiweek course. University
> lecturer Greg Wilson offers thorough notes to accompany the .mp3 lectures,
> all of which is downloadable:
>
> www.third-bit.com/swc/

I haven't come across this befoire, thanks for the link.

> convincingly argues that certain things which require more time up front
> save a great deal of time down the road. He stresses using a version
> control system, a debugger, test-driven development, and reading lots of
> code.

I'd agree with all of those, although for the debugger I'd substitute the
interactive prompt in Pythons case. I certaimly find it to be a very
powerful tool for finding out exactly what a library function does for
example.

> 1) Is subversion really a good tool for the beginning programmmer, or a
> single programmer? If not which version control system would you
> recommend?

I haven't used SV but it gets good crits.
For solo use I tend to use the ancient but simple RCS.
For group projects I often use CVS but I'm less keen on it.

Professionally I've used lots of tools and the best by far is ClearCase,
with almost magical version management capability, but unless you
have very deep pockets or, nore realistically, access to a corporately
purchased version, its probably unnattainable.

> 2) Which debugger should I use if I do most of my work in XP with IDLE? Up
> til now I've just been using print statements. who knew?

The IDLE debugger is good enough because in Python you rarely
need to dive that deep. Coupled to the interactive prompt and a few print
statements you shouldn't need anything more.

> for (well-written) code? Is it a good idea to look in the standard
> libraries for ideas, or code to modify?

Thats a tougher one.
The code in the libraries is good quality but it is library code and as such
is not necessarily representative of how you should write application code.
Libraries are designed to be both highly efficient and quite generic. These
are normally mutually exclusive qualities To achieve both requires some
fairly clever programming tricks and some compromises. If you were to
write your own code the wayt libraries get written you would probably
wind up writiong a lot more code than was necessary and possibly
implementing premature efficiencies which compromise maintainability.

So in summary: by all means read the library cpode but don;t necesarily
use it as a model for your own. Build the code you need, taking account
of good library practice around exception handing etc, but do not over
optimise it nor over genericise it. Do the simplest things first, add 
complexity
as you need it. If it becomes a frequent source of change thats the time to
consider revisiting the design and adding more generic capability or fine
tuning the time critical parts.

> How are large applications usually organized, and how do you find
> a specific part of it?

Using component or subsystyems or modules - different terms that all
encpompass the same concept of divide and conquer. Python has very
good support for modules at the file level and packages at the next level 
up.
And finally you can create whole collaborations of processes as happens
in Web Application Frameworks.

Component Diagrams combined with Deployment diagrams in UML are
a good way of documenting these relationships should you need to.
A basic example can be seen here:

http://www.smartdraw.com/examples/software-uml/package_diagram_encapsulation.htm

And for an 8 page short intro to UML:

http://www-128.ibm.com/developerworks/rational/library/769.html#N1014C

And in full detail in the UML specification (PDF format) here:

http://www.omg.org/cgi-bin/doc?ptc/2004-10-14

++++++++ REQUEST FOR FEEDBACK ++++++++
As a general question. I've been toying with the idea of doing a tutorial 
topic
on design & documentation using UML. Focussing on the aspects of UML
that I believe are genuinely useful for beginner porogrammers. Is there any
demand for that kind of stuff in my tutorial? Feedback is welcomed.
++++++++++++++++++++++++++++++++++++++

> How can you find code specific to certain tasks?

Google is your friend...

Alan G. 



More information about the Tutor mailing list