Due date: Thursday, April 22, when labs close.
memo.txt
In this assignment you will finish the error handing in Juno. Start with the source code for juno 7.5, which will also serve as the solution to hw9.
Doing this homework you will learn how to use Exceptions. And you'll learn about automated testing. That's even more important.
register eb Ethan BolkerUse the format at the bottom of JOI page 174 for your answer (in your memo).
Instructions here tell you how to comment your changes to Juno so that later on you will be able to count the lines of code that deal with error handling. The tool for that is class Profile:
>java Profile Shell Class Shell lines: 171 blank lines: 23 comment lines: 60 code lines: 88 error handling lines: 17So for this file, 17/88 = almost 20% of the code is devoted to error handling. Note that (23+60)/171 = almost 50% of the source file is devoted to comments or to blank lines that make the code easier to read. That fraction is typical of well documented code in industry.
Use the Profile tool to answer these questions about Juno when you have completed the error handling:
You can assume that all the Exception classes count as error handling
code even though we haven't flagged lines there with the
//EEE
comment that Profile looks for when it counts lines.
You do not have to read the code in Profile.java. All you need is Profile.class. Of course you can read it if you want to.
Finally: what fraction of the Juno source do you estimate you have written in the last few homeworks?
From: Ethan BolkerSubject: why isn't Profile smarter? Date: Thu, 22 Apr 2004 16:06:29 -0400 (EDT) If I'd wanted to do more work I could have allowed java Profile Class1 Class2 Class3 ... or even java Profile *.java but I didn't. You can improve Profile to do that if you like - and to have it sum the results and compute the percentages. Or you can do the files one at a time and do the totals yourself. That's what I recommend. > From: a classmate > To: eb@cs.umb.edu > Subject: RE: hw10 > Date: Thu, 22 Apr 2004 19:46:30 +0000 > > > Is there a way to test the fraction of comments and real codes just one time > by running: > > java Profile something. Or we need to test them one by one? >
We have written the test script for the newfile command: it's in file newfileTest.in. File newfileTest.out is the output from the command
java Juno -e < newfileTest.incaptured in an xemacs *Shell* buffer. (If you redirect the output with
java Juno -e < newfileTest.in > newfileTest.outthen the ordinary output goes to the file but the error messages still appear where you are running the application.)
From: Ethan BolkerSubject: what does remove remove? Date: Tue, 20 Apr 2004 14:23:01 -0400 (EDT) remove should remove only text files. rmdir (which isn't there and which you should not write) would remove only directories. > From: a classmate > To: eb@cs.umb.edu > Subject: hw10 > Date: Tue, 20 Apr 2004 11:19:25 -0700 (PDT) > > hello Prof. Bolker, the help for remove command tells that it > removes a TextFile. But currently remove also removes directory. Do > we have to fix it so that it removes only text files.
From: Ethan BolkerSubject: empty textfile? Date: Wed, 21 Apr 2004 12:49:23 -0400 (EDT) Excellent question. The command mars:> newfile foo should create an empty textfile. The TextFile class already provided the constructor you need. > From: a classmate > To: eb@cs.umb.edu > Subject: textfile > Date: Wed, 21 Apr 2004 11:45:38 -0400 > > Hello professor, > > Should the customer be able to create a textFile with no contents. Then the > size will be 0 and when we type it, it prints nothing. Or should we ask > customer that he is bound to enter some contents otherwise the file ill not > be created.
You should write input scripts and what you expect for output from each one before you write any code. In fact, you'll get lots of this optional credit if you just write those tests and don't write any code at all!