Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

dave zebatinsky

Greenhorn
+ Follow
since Jul 07, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by dave zebatinsky

Hi Prasanna,

Bart's example is a good one.

In addition, when designing it can sometimes help to group a number of classes together that may share some common purpose with an interface that has no methods.

You may not actively use the common interface, but from a design aspect it can help to clarify a group of classes and provide less clutter in a UML class diagram for example. Also, you may use the interface later on when the implementing classes become more defined and they do start to exhibit common behaviour that you want to enforce in the interface contract.

A bit of a "wooly" reply, but the "marker" interfaces help me when understanding large class diagrams.

Cheers,

Dave
14 years ago
Hi Aneea,

Checked exceptions that have a direct superclass of Exception are those that need to be listed in a method's throws clause, whereas unchecked exceptions that have a superclass of RuntimeException do not need to be listed as they can be thrown from almost any method.

a checked exception can be IOException for example, and an unchecked exception can be illegalStateException for example.

Cheers,

Dave
14 years ago
Hi Ganesh,

The current thread would be the "main" thread used to start your program, i.e. public static void main() and anything else it calls.

The second thread is then created from your line "t = new Thread(this, "Demo Thread");"
In this line you have created a new thread t that has a name of "Demo Thread" and has the run() method of your "NewThread" object which implements the Runnable interface registered as the run method to be invoked when the thread t is started.

When you implement the Runnable interface you also have to override the public void run() method.

Hope this makes things a little clearer.

Cheers,

Zeb
Hi John,

Have you tried putting each of your read and write functions into separate methods, where each method can have its own try catch block enabling you to locally catch your exceptions.

e.g. you might end up with something like:

private BufferedReader get reader(){...}
private PrintWriter getWriter(){...}
private void closeReader(){...}
private void closeWriter(){...}

private void writeNextLine(){
try{
getWriter().println( ( Queue.parseExpression(getNextLine()) ).toString() );
}catch(IOException ioe){
//do exception stuff
}
}

private String getNextLine(){
try{
return getReader().readLine();
}catch(IOException ioe){
//do exception stuff
}
}

public void doStuff(){
writeNextLine();
// etc...
}

Just a thought...

Cheers,

Zeb
14 years ago
Hi Muhammad,

I think I understand what you are trying to do.

If you are in your final year, I would concentrate on your project, that is, use the most familiar tool to you to achieve a good final year project. If you try to learn a new skill such as java, you are introducing a new element of risk into your project, and you may find yourself in trouble towards the end of the year with a half built solution that may be rushed and not as good as it could be.

If you know what you need to do in Matlab, then I reckon that you should use that tool. At the end of the day you will be marked on the success of your project, not the coding tool that you have used to build it.

You can always pick up java afterwards in your own time without the burden of a project and its deadline.

Hope that this helps.

Dave
14 years ago
Hi Muhammad, I found this on a quick google:

http://www.ee.ucl.ac.uk/~mflanaga/java/

He has a range of java functions including fourier transforms etc.

Might be worth checking out.
14 years ago