In DonaldKnuth's paper "StructuredProgrammingWithGoToStatements", he wrote: 
"Programmers waste enormous amounts of time thinking about, or worrying about, 
the speed of noncritical parts of their programs, and these attempts at 
efficiency actually have a strong negative impact when debugging and 
maintenance are considered. We should forget about small efficiencies, say 
about 97% of the time: premature optimization is the root of all evil." 

semoga bermanfaat



--- In jug-indonesia@yahoogroups.com, Daniel Baktiar <dbakt...@...> wrote:
>
> sebaiknya pakai if else, kalau tidak salah exception handling jauh (beberapa
> puluh atau ratus kali) lebih lambat.dan exception dibuat benar2 untuk hal
> yang pengecualian, bukan yang diharapkan.
> 
> kalau dalam hal ini definisi mapping hibernate membolehkan adanya null,
> berarti nilai null diharapkan dan bukan pengecualian.
> 
> 2009/9/1 Harry Christian <harr...@...>
> 
> >
> >
> > Hi JUGers,
> >
> > Mau tanya nih. Saya mengalami masalah klasik yaitu Null Pointer.
> >
> > Nah jadi ceritanya saya ada POJO yang berelasi dengan object lain.
> >
> > Contohnya :
> > private Employee emp;
> > private String deptName;
> >
> > public void setDeptName (String deptName)
> > {
> > // Cara 1
> > if(emp == null) this.deptName = deptName;
> > else if(emp.getDepartment == null) this.deptName = deptName;
> > else emp.getDepartment.setName(deptName);
> >
> > // Cara 2
> > try
> > {
> > emp.getDepartment.setName(deptName);
> > } catch (Exception e) {return;}
> > }
> >
> > public String getDeptName ()
> > {
> > // Cara 1
> > if(emp == null) return deptName;
> > if(emp.getDepartment == null) return deptName;
> > else emp.getDepartment.getName();
> >
> > // Cara 2
> > try
> > {
> > emp.getDepartment.getName();
> > } catch (Exception e) {return null;}
> > }
> >
> > Inti pertanyaan saya lebih efesien dan lebih cepat mana antara cara 1
> > (if else) ataukah cara 2 (try catch) ?
> >
> > --
> > ==============================
> > Thanks & Best Regards
> >
> > Harry Christian
> >
> > YM : callme_harry
> > Skype : harry_christian
> > Facebook : http://www.facebook.com/profile.php?id=696095562
> > Blog : http://www.harry-christian.blogspot.com
> > ===============================
> >  
> >
> 
> 
> 
> -- 
> Daniel Baktiar
> Senior JEE* Monkey -- willing to work hard in the Java beans brewery for a
> big bunch of bananas (http://dbaktiar.wordpress.com)
>


Kirim email ke