assignment, part1: feedback and common mistakeshiard/feedback_tp1.pdf · assignment, part1:...

15
Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Upload: others

Post on 15-May-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Assignment, part1: feedback and common mistakes

INFO-0010

Samuel HIARD

Page 2: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Some statistics

106 registered students 97 received submissions• Project is mandatory for the oral exam

5 did not compile• 1 was easily fixable

5 compiled, but with warnings• Use « -Xlint » in your compilation to display warnings

1 contained only compiled classes• Functionality testing possible, but not source code analysis

Automatic testing on all working submissions• GuessTester• Search for keywords in source code (guidelines)

25 completely graded

Page 3: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Results

For the 25 completely graded:

For the rest:• Over 93 working submissions

• 56 worked perfectly (GuessTester)

• 8 worked perfectly except for « CHEATER »

• 29 to be manually tested

0

1

2

3

4

5

6

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

occ

urr

ence

s

Grade

Page 4: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Manual testing

29 submissions to manually analyze

11 were analyzed so far• 4 had a problem with port usage

• 3 were « let-me-do-the-oral-exam » submissions

• 1 had wrong parameter usage

• 1 never sends « \r\n » in the client

• 1 doesn’t accept « TRY XX »

• 1 had a lot of source code, but nothing works

Page 5: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Outline of the presentation

Selected examples illustrating mis-conceptions(incl. source code when relevant) are shown today.

These examples are sorted according to thefrequency of the problem in the submissions, whenavailable.

Page 6: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Report (64%)

Report is evaluated mainly on two criterias: Presentation

• Nice frontpage

• Justified text

• Numbered sections

• No misprints/errors

• Images non blurry if any

Content• Most important : software architecture and control flow

• If several classes, at least explain what each class does

• A diagram is always better than a lot of text

Page 7: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Exceptions (52%)import java.net.*;import java.io.IOException;import java.io.InterruptedIOException;

public class GuessingServer {public static void main (String argv[]) throws Exception{

ServerSocket ss = new ServerSocket(13105);//init of the socket

try{while(true){

Socket accepter = ss.accept();//accept the connection of a clientClientWorker client = new ClientWorker(accepter);//create a thread

corresponding to the clientclient.start();//start the thread}

}catch(InterruptedIOException iioe){//exception handler for the timeoutSystem.err.println ("Remote host timed out during read operation");

}catch(IOException e){//any other exception for the threadSystem.err.println("ioexception:" + e);

}finally{//closing the socket

ss.close();}

}}

ALWAYS catch Exceptions!

Page 8: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Comments (~47% )(Don't focus on the code, but on what the code looks like)

public class GuessingGame{private boolean inProgress;private String secretPositions;private boolean[] showFilter;private int lives;private final ArrayList<Character> proposedLetters;

static{PredefinedWords.addWords();

}

public BattleshipGame(){proposedLetters = new ArrayList<Character>();

}

private void pickAWord(){final Random randomNumberGenerator = new Random(new Date().getTime());secretWord = PredefinedWords.alWords.get

(randomNumberGenerator.nextInt(PredefinedWords.iCapacity));showFilter = new boolean[secretWord.length()];

}

public void newGame(){inProgress = true;pickAWord();lives = 6;proposedLetters.clear();

}

public boolean inProgress(){return inProgress;

}

Comments!At least one introductory block at the beginning of the fileAt least one block for each functionAt least one line for each code block bigger than 8 lines

public int lives(){

return lives;

}

public int proposedLettersNumber(){

return proposedLetters.size();

}

public String secretWordWithQuestionMarks(){

StringBuilder secretWordWithQuestionMarksBuilder =

new StringBuilder(secretWord);

for(

int letter = 0;

letter < secretWord.length();

++letter

)

if(!showFilter[letter])

secretWordWithQuestionMarksBuilder.setCharAt(letter, '?');

return secretWordWithQuestionMarksBuilder.toString();

}

public String proposedLetters(){

StringBuilder proposedLettersStringBuilder = new StringBuilder();

for(Character letter: proposedLetters)

proposedLettersStringBuilder.append(letter);

return proposedLettersStringBuilder.toString();

}

Page 9: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

TCP (~40%)

(This is the server)

byte msg[ ] = new byte [64] ;

//receiving header

int len = in.read(msg);

//Initializing the subroutine

RequestParser sub = new RequestParser(msg);

Respect the stream-oriented property of TCP

Do multiple reads if you use low-level primitives

Or use BufferedReader.readLine() !!

Page 10: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Naming (~38%)(This is the server)

ServerSocket ss = new ServerSocket(23011);

Scanner sc = new Scanner(System.in);

char rep = 'n';

while(rep != 'y'){

System.out.println("Waiting for a new connection to handle...");

Socket ts = ss.accept();

Worker w = new Worker(ts);

Thread t = new Thread(w);

t.start();

System.out.println("New connection handled.");

}

Use self-explanatory names for variables, methods and classes.

Page 11: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Time-outs (~28%)

serverSocket = new ServerSocket(Port);

clientSocket = serverSocket.accept();

input = new BufferedReader(clientSocket.getInputStream());

output= new PrintWriter(clientSocket.getOutputStream());

input.readLine();

Use Socket Time-outs (default : none)

Page 12: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

GuessingServer.java

Archive ( ~26% ) "You will ensure your main class is named (…) located (…) at the root of

the archive, (…).“

“You will not cluster your program in packages or directories. All java files should be found in the same directory.”

Icons from Windows 8.1™

archive.zip

MyProjectFolder

src

report

GuessingClient.java

MyReport.pdf

archive.zip

GuessingClient.java

GuessingServer.java

MyReport.pdf

Not sanctioned for this project

Page 13: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

Guidelines (~10% ) You will implement the programs using Java 1.8,

with packages java.lang, java.io, java.net and java.util.• import org.omg.CORBA.portable.UnknownException;

You will ensure that your program can be terminated at any time simply using CTRL+C, and avoid the use of ShutdownHooks• Runtime.getRuntime().addShutdownHook(new Thread() { …

The server listens on port 2xxx – where xxx are the last three digits of your Ulg ID• socket = new Socket(44444, port);

Respect the guidelines

Page 14: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

And the rest

Not useful to show example

Forget to synchronize the access to shared data (if any)

Inconsistent indentation (~15%)

Multi-threading (~5%)

Page 15: Assignment, part1: feedback and common mistakeshiard/Feedback_TP1.pdf · Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD

That's all for the first part

Keep on the good work!