How To Write Code In Our Environment

Each organization has a unique development environment that team members are expected to conform to. In our case, there are two environments we support and use: Linux and Windows/Eclipse.

Table of Contents
    Command line Java on Linux
    Eclipse on Windows
    Adding a New Project
    Stable versus Development Builds
    Third-Party Code Issues
    Coding Standards
    Unit Tests
    Acceptance Tests


Command line Java on Linux

back to list of contents

Eclipse on Windows

David says: This might be slightly out of date, but the concepts will still work via some set of eclipse commands. Also, the DevelopersPlayground is a handy way to do acceptance tests. Ask me if you have questions.

back to list of contents
  1. Using the "Team" Perspective, connect to the CVS repository. The Streams subtree lists all the CVS modules. Selecting a module and using the "Add to Workspace" item will import the code into Eclipse.
  2. Thereafter, use the standard Eclipse UI to edit, compile, and debug the code.
  3. Right-clicking on the project and selecting "Team / Synchronize with Stream" will open a merge/synchronize browser. The menu items are fairly self explanatory - for example, "release" causes a CVS commit of the changes; "catch-up" causes a CVS update; and so on.
  4. Be sure that you are following our Development Process when you are releasing changes.
  5. Instructions for running Tinyville in Eclipse are in the DataPrep/examples directory.
  6. Eclipse allows you to define which editor to use for different files, according to the file extension. This allows you to get the editor of your choice when you double-click on the file name in the Package or Search windows, for instance. For instance:
    1. Select menu item Workbench | Preferences.
    2. In Preferences dialog box select Workbench | File Editors.
    3. Press the upper Add... to add a new File Editor for “*.xml”.
    4. With this file type selected, press the lower Add... to add an Associated Editor of “Text Editor” in the Internal Editors list.
  7. We have an additional module "DevelopersPlayground" with various Eclipse specific tests and files. This module is stored in the general purpose CVS repository rather than the production-code repository because the module contains logins and passwords that should not be exposed to the outside world.

Special Case: Starting a New Project


Starting a New Project

back to list of contents

There are two things to consider when starting a new project/sub-project:

  1. Directories are used both for CVS modules and for Java packages. We separate the two uses by having a top-level directory for the module using a capitalized name (e.g., DemoProject). Under that directory we have the Java package directories (e.g., taxirus and taxirus/tests). Thus the full path will include both (e.g., DemoProject/taxirus/tests). This looks a little confusing until you get used to thinking "module name" versus "package name".
  2. The easiest way to create a new project is to do that in Eclipse via the New command then then use the Team | Share Project menu to put it in the repository.

Stable versus Development Builds

David says: I recommend you keep stable builds around, somehow; you never know when a customer will want a demo.... 

back to list of contents

We keep a number of different builds available for users to download. Developers need to understand what they are and how they are updated, all of which is documented on another page.


Third-Party Code Issues

back to list of contents

Coding Standards

back to list of contents

Unit Tests

back to list of contents

Unit tests (provided by the JUnit framework) are the preferred method for running tests on code fragments. They replace the "main in each class" technique for testing. A template for a test class can be found in the repository as taxirus.tests._templateUnitTest.


Acceptance Tests

David says: You'll probably want to implement something like this.

back to list of contents

Testing is an important part of our development process. Our Fireman automatic build process runs both unit tests (tests of individual classes and small collections of classes) and acceptance tests (a.k.a. integration tests) each time it builds the systems. 

The acceptance tests are Java programs (classes) that extend the urbansim.tests.AbstractAcceptanceTest class. We currently have:

Each of these tests consists of the same basic steps:

  1. Clean up from any previous runs of this test. The reason this is done first rather than last is that when tests fail, one often wants to examine the databases and files of the test. If the last action one took where to clean up, the interesting files wouldn't be around of examination.
  2. Copy and/or create new test databases. We can't just use the existing databases because the tests may modify the databases (intentionally or unintentionally).
  3. Set up database specifiers. (see below)
  4. Run the Code Under Test.
  5. Verify the results. Typically the test has a set of expected results and the verification consists of comparing the actual versus the expected. The results are stored both in individual files and in the databases. In general, the results should be an exact match. Unfortunately, DataPrep and UrbanSim are currently non-deterministic in various ways and thus the results may not match exactly. While we decide what to do about this, we are ignoring those "errors".

Running The Tests

On Linux, the tests can be run using the run-test.pl script in each acceptance_test_* subdirectory.

On Windows using Eclipse, the tests can be run using "Run as JUnit" on the main class.


$Id: howtodevelop.html,v 1.16 2002/04/10 20:49:04 bnfb Exp $