|
|
|
|
|
by FurrBall
4652 days ago
|
|
I look at Java code and it horrifies me. Java is great if your resource is memory. It turns into a horrible unsafe mess the moment your resources are not memory. //C++ RAII goodness.
void foo()
{
conn.open();
file.open();
printer.activate();
//do stuff
}
//Java's lack of RAII is disturbing
void foo()
{
try{
conn.open();
file.open();
printer.activate();
//do stuff
}
catch(Exception e) { }
finally{
try {
conn.close();
}
catch(Exception ee) {}
finally{
try {
file.close();
}
catch(Exception eee) {}
finally {
try{
printer.close();
}
catch(Exceptoin eeee) {}
}
}
}
}
|
|