CS 580 Client-Server Programming

Spring Semester, 2005

Assignment Index

© 2005, All Rights Reserved, SDSU & Roger Whitney

 San Diego State University -- This page last updated 1/24/05

Assignment 1

Due: Feb 3

Purpose    

Description    

Programming Language    

Source Code Repository    

Grading    

What to Turn in    

Purpose

  1. Practice making small steps

  1. Practice using source control systems

  1. Practice using unit tests

  1. Develop Library for future use

Description

Develop and test a library for Bencoding. You need to place your code in a source code repository. Java classes have to be in a package. Smalltalk classes have to use a namespace. C# code needs to use similar features. Bencoding is a method of coding data, that is strings, integers, lists and dictionaries. The following, modified from the bittorent spec, indicates how each data type is encoded.

strings Strings are encoded as follows:

  1.  <string length encoded in base ten ASCII>:<string data>

Note that there is no constant beginning delimiter, and no specific ending delimiter.

Examples:

Bencoding

String

4:spam

"spam"

0:

empty string

integers Integers are encoded as follows:

  1. i<integer encoded in base ten ASCII>e

The initial i and trailing e are beginning and ending delimiters. You can have negative numbers such as i-3e. You cannot prefix the number with a zero such as i04e. However, i0e is valid.

Example: i3e represents the integer "3"

lists Lists are encoded as follows:

  1. l<bencoded type>e

The initial l and trailing e are beginning and ending delimiters. Lists may contain any bencoded type, including integers, strings, dictionaries, and other lists.

Examples:

Bencoding

List

l4:spam4:eggse

["spam", "eggs"]

li1ei2ee

[1, 2]

le

empty list

dictionaries Dictionaries are encoded as follows:

  1. d<bencoded string><bencoded element>e

The initial d and trailing e are the beginning and ending delimiters.

Note that the keys must be bencoded strings. The values may be any bencoded type, including integers, strings, lists, and other dictionaries. Keys must be strings and appear in sorted order (sorted as raw strings, not alphanumerics).

Examples:

Bencoding

Dictionary

d3:cow3:moo4:spam4:eggse

 { "cow" => "moo", "spam" => "eggs" }

d4:spaml1:a1:bee

{ "spam" => ["a", "b"] }

de

empty dictionary

Programming Language

This is the first assignment on a client-server system that we will be working on most of the semester. Code you write in this assignment will be used in other assignments. Students can use Java, C# or Smalltalk on assignments. As assignments will be used later in the course, you need to select which language you will use in this course. This is not a course in which to learn a new language, so you need a working knowledge of one of the languages. I assume that graduate students and seniors know what is required to know about a language to implement a course project. If you are unsure if you know a language well enough for this class you should see me in private (or look for another course).

Source Code Repository

You are to keep your code is a source code repository. Students using Smalltalk need to contact me and I will create a Store repository for you. Students using Java and C# need to create there own repository. Later in the semester Java and C# students will be required to place their code in a CVS repository on rohan.

Grading

Item

Percent of Grade

Working Code

30%

Unit Tests

20%

Comments

20%

Quality of Code

30%

Working Code. How well your code meets the functional requirements listed above accounts for 30% of the grade for the assignment.

Unit Tests. Having unit tests that cover the functionality of your code accounts for 20% of your grade. The unit tests are to be scalable. Tests using just print statements are not scalable.

See http://www.junit.org/ for more information about JUnit. For C++ and C# you can get the equivalent testing framework at http://www.xprogramming.com/software.htm

Comments. Having the appropriate comments in your code will count for 20% of the grade.

Quality of Code. Having good quality of code counts for 30% of the grade. Quality of code includes formatting, names and modularity.

For more information about comments and quality of code see the lecture notes of past CS535 courses. For even more information see Code Complete 2, McConnell, Microsoft Press, 2004. Smalltalk programmers can look at Smalltalk Best Practice Patterns, Beck, Prentice Hall PTR, 1997

What to Turn in

Turn in the source code and your unit tests.