CS 580 Client-Server Programming Fall Semester, 2000 Assignment 2 Comments |
||
---|---|---|
© 2000, All Rights Reserved, SDSU & Roger Whitney San Diego State University -- This page last updated 20-Nov-00 |
Assignment 2 Comments
Names
Use Java Standard name
ClassName
methodName
this_is_not_java_standard
Some Bad habits
file1 file2 flag = getFile( blah) if (flag) then more blah else even more blah
Line Wrap
Just say no to line wrap in source code
If you have problem with line wrap in hard copy:
Place the following comment in a file:
//234567890123456789012345678901234567890etcMake the comment long enough to insure line wrap
Print the file using the commands/printer you use to print your assignments
Determine how many columns you have before you get line wrap
Use a few columns less than that
In your source code files you can place a comment of the max length for a guide
Test out your tabs
Threads
This does not start a thread:
Thread test = new Thread(); Test.run()
This does start a thread:
Thread test = new Thread(); Test.start()
But in a server this will do more harm than good:
Positional Data
public void main(String[] args ) { String port = args[1]; String file = args[2]; etc.Say no to positional data
For command line arguments use flags:
java Server -p 5555 -f myFile
Very Bad Coupling!
File cs325 = new File("cs325"); File cs419 = new File("cs419"); blah if (value.equals( "Exam1") ) blah else if (value.equals( "Project 2" )) blahs
If the instructor adds a new assignment the program has to be rewritten
The program must be rewritten for every course that uses it
Before the program could be used in a course, the instructor must know the name of every assignment, quiz, project and test
Testing
Manual verses Automatic Tests
Manual
Logging
Recall that servers
try { blah } catch (FileException readProblem) { // no code here }What happens when the exception occurs?
Logging & Debug Statements
try { blah Logger.log("a message"); System.out.println( "aMessage"); Blah System.out.println( "I made it here"); } catch (FileException readProblem) { System.out.println( "file exception occured"); }
Sort of works in development, but what happens when you deploy?
Use the Logging Debug Statements
When debugging:
SelectiveLogger activeLog = (SelectiveLogger ) ScreenLogger.register(); activeLog.debugOn();
In production:
SelectiveLogger activeLog = (SelectiveLogger ) FileLogger.register("fileName"); activeLog.debugOff();
Server Code:
try { blah Logger.log("a message"); Blah Logger.debug( "I made it here"); } catch (FileException readProblem) { Logger.log( "file exception occured"); }
Copyright ©, All rights reserved.
2000 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.
Previous    visitors since 20-Nov-00    Next