Helsingin yliopisto Tietojenkäsittelytieteen laitos
 

Tietojenkäsittelytieteen laitos

Tietoa laitoksesta:

 

Some guidance for programming project of UNIX platform

The project work is a compulsory part of the course. If you don't complete the project, you cannot participate the exam but you have to restart the course.

The project work has to be completed at Thursday, May 27, 1999 (24:00). At that point of time you can get 20 credits for your work. If you are late, 2 credits are lost every day. After Wednesday, June 2nd (24:00) there is no hope getting your project accepted any more.

What kind of an application to create?

There is no prespecified topics, but you should choose something on your own. Present your idea to the excersice group advisor in excersice meetin number 4 for approval.

Your application should use two or more processes that communicate together, and in addition exploit some files.

Some examples follow.

In the implementation, there is no requirement for major network support. This course is not about sockets! You can assume that all workstations have access to a shared file system.

Write a description of your application and implementation highlights. Describe the user interface, usage of processes and files. Clarify what information is passed around, who is responsible of invoking things, and what is stored in the files.

Hand in your plan in excersice meeting number 6.

A careful plan saves a lot of trouble during the implementation!

Good programs need labour

Don't be a snob! Do what is required and leave extra features alone.

Well designed is half done:

Design the inerfaces between programs or processes properly. Well designed data structures and functions to manipulate them create a basis for a clear and efficient program.

Never copy pieces of code around. Use functions. Don't make your functions longer than 15 lines. Maybe you can extend the reusability of your function with a new parameter. Still, don't overdo it!

Sketch several solutions for your application before deciding which way to go. Evaluate the solutions before proceeding to a more detailed design. Use your advisor for evaluation support!

Read about efficient algorithms and data structures that are somehow close to your problem. Try to find a way to exploit the already existing, already tested algorithms.

Althogh your application may end up being small enough for a single module, make at least two separate modules just for getting the excersice of it.

Always work with best possible taste

Don't write too long sequences of code, but use a proper programming style with clearly structured programs. Use white space. Use the help of indent(1) and cb(1).

Avoid special features of the programming language or the programming environment. Don't use nonstandard features. No cryptic expressions! Your project work should compile without any warnings.

Your program should be robust. Test the input, and make sure no core dumps occur.

Use a sensible naming system

Use a variable for one purpose only!

Never use fixed computer names, absolute path names etc. in your programs. If you need to name such things, use environment variables, initialization files, or at least #define them in the header files.

Use #define for constants like table sizes, string lengths, etc.

The maintainability of your code is increased by introducing variables in the block where they are used. For example,

      if ( ... ) {
           int hide;
           ...
      }
It is easier to notice variables that are not used, and in addition, your program causes less dynamic memory management activities.

Use unique path names for named pipes. A user name is not sufficient alone, but causes confusion when several connections are creates.

Use /tmp for temporary files and named pipes. NOTE that Linux computers have a private /tmp directory that can only be accessed via sessions in that computer.

Implement your game so taht it repeats its basic task until an explicit closing command is given.

Remember the provided routines

All UNIX tools are allowed.

Make makes it

Prepare your application package so that it compiles, links and works fine with a single make command. This is an extremely compulsory step -- the evaluation of your project ends immediately here, if your makefile is missing or does not work.

In your makefile, have targets

As the computing centre UNIX environment and the Linux environment at the department differ, please make sure you mention, in which system you tested your product.

If you used something special, like shared memory, mention that explicitly.

Major danger: humans!

Start testing systematically from the beginning, in all phases of your work. Starting from the very first paper model. Try to find as many of the errors as possible as early as possible. Illogical design is the worst to correct late in the programming phase!

In UNIX philosophy, prototypes are essential: make a little working core and add more features later on. Naturally, you need to design the whole thing initially, but the implementation is easiest to do step-by-step.

Use gcc -Wall -ansi -pedantic for compilation. Fix your program till the compilation becomes clean.

If everything else fails, try debugging (gbx(1)). Some help can be found with prof(1) and gprof(1) as well.

Be careful not to loose your common sense with the debugger. Never enter the mode where you just fix the obvious without thinking what lead to the failure. A bus errors are not fixed by simply adding if (*P != NULL) all around the program. It just creates logical program errors more difficult to find.

Testing may be easier if you initially take up the idea of a log, and use a private debug option to create test output.

Documentation -- a necessity

This time, for final documentation, you need only to create a manual page and to comment your programs carefully. Take examples by reading man man nad man -s 5 man, and looking into directories /usr/share/man/man? or /usr/share/man/cat?.

When commenting your program, the following should apply.

Examples for comments can be found in text books and manual pages for library functions.

Write comments first, the program code follows easily.

Sending your project work for evaluation

The project work is evaluated by your excersice group advisor.

Bundle all relevant files to a tar package (man tar) and send the package via email.

Include the following.

In addition, provide your advisor with a paper copy of your program and header files.

The package for email is prepared for example like this

  1. Put all required files into a subdirectory "surname".
  2. Remove all object files and executables.
  3. Remove all other unnecessary files.
  4. Give the following command in a working directory one level above the directory "surname":
          tar cvf surname.tar surname
    
  5. Send the tar-package with any mail program to your advisor.

Evaluation criteria

The project work should be sent for evaluation within the time limits given, the applications should work flawlessly and according to their specifications. The documentation is also required.

The total maximum credits are 20,

Documentation and maintainability Functionality and usability THE END