Object-Oriented Design Frequently Asked Questions


Which version of Python should we use?

In December 2008, Python 3.0 (a.k.a. "Python 3000" or "Py3k") was released. This release is incompatible with previous releases. Though it is somewhat more elegant than previous versions, we will not use it this term. Instead we'll use older versions such as 2.6 which are still in common use (and installed in the labs).

Where do I find answers to questions about Python ?

Tutorials, references, and links kan be found at http://www.python.org.

An excellent starting point is the Python Tutorial.

How does one check whether an object c is of "type" C ?

  1. For builtin types, one can use the operator type(). For example:
         >>> type(2)
         <type 'int'>
    If we declare a class C and create an instance c as shown below, type() will give rather general information:
        >>> class C:
        >>> c=C()
        >>> type(C)
        <type 'classobj'>
        >>> type(c)
        <type 'instance'>
  2. If we want to check whether c is an instance of class C, we can use the test
        >>> isinstance(c, C)
    This will evaluate to True if c is an instance of class C or any of C's sub-classes.

    In recent versions of Python, it is possible to test for basic types with isinstance as in isinstance(1,int), isinstance(1.2,float), isinstance((2,3),tuple), isinstance([3,4],list) and isinstance([1,2],list).

How do I generate nice HTML from Python source code ?

  1. Colorized pretty-printing for file code.py can be done with
    enscript -Whtml -Epython --color code.py -o code.html
  2. An API document for file code.py can be generated with
    pydoc -w code
  3. The more advanced Epydoc allows one to generate API documentation for Python modules, based on their docstrings and in addition supports a lightweight markup language called Epytext to format docstrings, and to add information about specific fields, such as parameters and instance variables.

Which IDE (Integrated Development Environment) should we use for Python development ?

A simple editor (with Python syntax hightlighting) should be sufficient for the simple assignments for this course.

Which tool do we use to draw UML diagrams ?

A plethora of tools is available. In COMP 304 we focus on the "essence" of OO design and build only relatively small designs. For these reasons, using a huge, sophisticated tool may (1) take a long time to learn and (2) distract from the "essence" of the problem.

Some useful tools:


MUST we work in teams of 2 ?

You must work in a team of exactly two people (for some of the assignments). Previous experience has shown that after the initial transient chaos of finding a partner, this works really well. Try to find a team partner after class or by sending a message to the entire class on WebCT. Remember that "pair programming" requires you to actually work together (same place, same time). You may form different teams for different assignments.

Hans Vangheluwe, Winter Term 2009.