Intro to Computer Systems :: Project 0 :: Programming Best Practices
Assignment
Write, document, and package a program to remove white space and comments from a text file. You will use this functionality in several programming assignments in this course. You may program in the language of your choosing. Popular choices include java, python, c, and c++, but you may use any language you are comfortable with.
Packaging, portability, ease of build, and documentation of your program is the main emphasis of this assignment, and this is reflected in the grading rubric:
30% Your program is cleanly packaged and organized
25% There are clear instructions on how to compile and run your program
20% Your program creates an output file in the same directory as the input file. 15% Portability of your program
10% Program functionality
Note: you will use this program in future assignments; it is worth your while to write it properly now.
Program Specification
User interface
• Your executable should take a filename (
•
•
• This is the first step in writing a compiler. Think about your experience in using a compiler; you don’t need to know where on the system the compiler lives, and it puts the compiled program in the same directory as the source program.
Functionality
1) Remove white space:
Strip out all white space from
2) Remove comments:
Remove all comments in addition to the whitespace. Comments come in two forms:
• comments begin with the sequence “//” and end at the line return • comments begin with the sequence /* and end at the sequence */
continued
Packaging and Documentation
• Your program’s source code and documentation should be zip or tar compressed into a single file, for example:
LastNameFirstNameProject0.zip
• Upon decompressing your assignment, one should see a README.txt and a src/ directory.
• The README.txt should include
§ specific instructions on how to compile your code
§ specific instructions on how to run your code
§ a description of what works and what doesn’t work in your code
• The src/ directory should contain your source code
• Your source code should be documented. Please document your code as you write it, not
as an afterthought.
Portability
• Assume your code will be compiled and run outside of your build environment. It should not rely on libraries, native compilers, or operating system hooks specific to your build environment.
• You should test that your code compiles and works outside of your build environment, ideally on a different operating system.
Example
Assume that you have a text file named myProg.in that looks like this:
After running your program, there should exist a file named myProg.out that looks like this: