TDD by Example con Python 3

Después de leer Test Driven Development- By Example (Addison-Wesley Signature Series) me quedo un sensación mixta de intranquilidad.

Seguí los ejemplos del libro, la primera parte usando C#; aunque el libro usa Java y la segunda parte con Python 3.1, haciendo algunas adecuaciones al código del libro. De hecho, primero lo intente con IronPython para seguir con el tema de .Net, pero con Python 3.1 y IDLE me fue más fácil hacer trabajar el código.

TDD es una técnica avanzada que en su expresión ortodoxa no es seguida ni por el mismo Beck. Es fácil caer en callejones sin salida y el desarrollador debe tener un plan top-down  implícito basado en su experiencia y dominio técnico. Por otro lado su aceptación y referencias de éxito son evidencia de su validez.

La primera parte del libro me pareció incompleta, llena de manitas de puerco, visión nocturna, multiplicaciones por el número que pensaste, y conjuros de magia negra.

la segunda parte es de más alto nivel de abstracción pero muestra claramente los fundamentos del marco de xUnit. El uso de Python aquí parece apropiado ya que permite desarrollar la estructura básica de xUnit de manera clara y directa.

En resumen, Test Driven Development- By Example es un buen libro para desarrolladores expertos.

Referencias

Test Driven Development- By Example (Addison-Wesley Signature Series)

http://dinsdale.python.org/dev/peps/pep-0008/

http://docs.python.org/3.1/tutorial/index.html

http://www.python.org/

http://www.swaroopch.com/notes/Python

http://www.wrox.com/WileyCDA/

http://www.wrox.com/WileyCDA/Section/Browse-Titles-for-Code-Downloads.id-105127.html

http://www.wrox.com/WileyCDA/WroxTitle/Python-Create-Modify-Reuse.productCd-0470259329,descCd-DOWNLOAD.html

http://pybites.blogspot.com/

null nil

Language null true false
Java null true false
Python None True False
Objective-C nil, or NULL, or [NSNull null],
depending on context
YES NO
C NULL anything except 0 0
Lisp NIL T NIL

Objective-C is psychotic. It’s a Smalltalk dialect built on top of C (and for the most part, it got the good bits of both and left out the bad bits). Obj-C lets you instantiate arrays like [NSArray arrayWithObjects:@"Hello", @"World", nil], using nil as an end-of-array marker because C’s varargs implementation doesn’t know how many args you passed. So it has this extra “null” object that’s not really null.

extended traceback printer

The standard Python traceback module provides very useful functions to produce useful information about where and why an error occurred. Traceback objects actually contain a great deal more information than the traceback module displays, however. That information can greatly assist in detecting the cause of your error.

There is a Python recipe that, while not an interactive debugger, makes it easier to debug Python scripts within SciTE.

Here’s an example of an extended traceback printer you might use, followed by a usage example.

import sys,traceback
defprint_exc_plus():
    “””
    Print the usual traceback information, followed by a listing of all the
    local variables in each frame.
    “””
    tb=sys.exc_info()[2]
    stack=[]
    
    whiletb:
        stack.append(tb.tb_frame)
        tb=tb.tb_next
    traceback.print_exc()
    print“Locals by frame, innermost last”
    forframeinstack:
        print
        print“Frame %s in %s at line %s”%(frame.f_code.co_name,
                                             frame.f_code.co_filename,
                                             frame.f_lineno)
        forkey,valueinframe.f_locals.items():
            print“t%20s = “%key,
            #We have to be careful not to cause a new error in our error
            #printer! Calling str() on an unknown object could cause an
            #error we don’t want.
            try:                   
                printvalue
            except:
                print“<ERROR WHILE PRINTING VALUE>”
        
try:
        iflen(sys.argv)>1:
                length=len(sys.argv)
                foriinrange(1,length):       
                        sys.argv[i1]=sys.argv[i]
                delsys.argv[length1]
                execfile(sys.argv[0])
except:
        print_exc_plus()

TQM tea

Uploaded on Apr 11, 2009

A Total Quality Management training video produced by final year MEng students at the University of Edinburgh. The aim of the video is to explain the main principles of TQM in a tongue-in-cheek style to improve the tea making process in a tea shop business.

Hortonworks adds a Hadoop sandbox

Those who want to try the much-hyped Hadoop but haven’t got a cluster or two to spare can now test the data processing platform on their desktops, thanks to a new release from Hadoop distributor Hortonworks.

Those who want to try the much-hyped Hadoop but haven't got a cluster or two to spare can now test the data processing platform on their desktops, thanks to a new release from Hadoop distributor Hortonworks.