Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Re: [joist-cvs] CVS update: joist/java/org/joist/database UserManager.java

Project highlights: Architectural Overview

joist
Discussion topic

Hide all messages in topic

All messages in topic

Re: [joist-dev] Re: [joist-cvs] CVS update: joist/java/org/joist/databaseUserManager.java

Author dlr
Full name Daniel Rall
Date 2000-09-27 22:02:31 PDT
Message Ed Korthof wrote:
>
> On Wed, 27 Sep 2000, Daniel L. Rall wrote:
>
> > Okay guys, I ran the numbers (bytes):
> >
> > Before After
> > ------ -----
> > javac: 8776 8728
> > jikes: 8533 8504
> >
> > Java compilers are not on par with gcc, unfortunately. I'm with you in
> > spirit. At the same time, it could be argued that you should know what
> > executeUpdate() returns. Shame on you! ;) j/k!
> >
> > Anyhow, it's a minor nit. Know that I understand trading resources for
> > maintainability, and appreciate everyone's vigilance. :)
>
> You're right -- I tried a simple test, and the byte code is indeed
> different -- if you store the results in a register, you get two extra op
> codes : istore_1 and iload_1. (javap -c produces interesting output,
> fwtw.) That's annoying.
>
> I'd say that as an efficiency issue, the difference is utterly irrelevant.
> But I am fine with your change. Perhaps I should know executeUpdate --
> but it's also true that there's an error message which tells me what the
> code is supposed to be checking. Given that, one could argue that the
> shorter form is equally easy to understand (fewer distractions can be
> good).
>
> OTOH -- so long as we're working in Java, I'm going to keep arguing that
> we should value readability above certain kinds of optimizations. ;-)

Good comments.
--

Daniel Rall <dlr at finemaltcoding dot com>

Re: [joist-dev] Re: [joist-cvs] CVS update: joist/java/org/joist/database UserManager.java

Author edk
Full name Ed Korthof
Date 2000-09-27 21:58:02 PDT
Message On Wed, 27 Sep 2000, Daniel L. Rall wrote:

> Okay guys, I ran the numbers (bytes):
>
> Before After
> ------ -----
> javac: 8776 8728
> jikes: 8533 8504
>
> Java compilers are not on par with gcc, unfortunately. I'm with you in
> spirit. At the same time, it could be argued that you should know what
> executeUpdate() returns. Shame on you! ;) j/k!
>
> Anyhow, it's a minor nit. Know that I understand trading resources for
> maintainability, and appreciate everyone's vigilance. :)

You're right -- I tried a simple test, and the byte code is indeed
different -- if you store the results in a register, you get two extra op
codes : istore_1 and iload_1. (javap -c produces interesting output,
fwtw.) That's annoying.

I'd say that as an efficiency issue, the difference is utterly irrelevant.
But I am fine with your change. Perhaps I should know executeUpdate --
but it's also true that there's an error message which tells me what the
code is supposed to be checking. Given that, one could argue that the
shorter form is equally easy to understand (fewer distractions can be
good).

OTOH -- so long as we're working in Java, I'm going to keep arguing that
we should value readability above certain kinds of optimizations. ;-)

thanks --

Ed
--
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
   | Ed Korthof | edk at collab dot net | 415-247-1690 |
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=

Re: [joist-dev] Re: [joist-cvs] CVS update: joist/java/org/joist/database UserManager.java

Author dlr
Full name Daniel Rall
Date 2000-09-27 01:06:48 PDT
Message Okay guys, I ran the numbers (bytes):

    Before After
    ------ -----
javac: 8776 8728
jikes: 8533 8504

Java compilers are not on par with gcc, unfortunately. I'm with you in
spirit. At the same time, it could be argued that you should know what
executeUpdate() returns. Shame on you! ;) j/k!

Anyhow, it's a minor nit. Know that I understand trading resources for
maintainability, and appreciate everyone's vigilance. :)

Ed Korthof wrote:
>
> is this really an improvement? i understand the value in shortening the
> code where appropriate, but the old version seems far more intuitive than
> the new one (to me, anyway -- i'd have to look at the javadocs for
> PreparedStatement to be sure of what's going on).
>
> maybe that doesn't matter, but there are times when i'd prefer code to be
> clear rather concise -- maybe i've just read too many obfuscated c code
> contest entries. fwiw -- in terms of the actual byte code generated --
> i'd guess these two are equivalent.
>
> thanks --
>
> ed
> --
> +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
> | Ed Korthof | edk at collab dot net | 415-247-1690 |
> +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
>
> On 26 Sep 2000 dlr at tigris dot org wrote:
>
> > User: dlr
> > Date: 00/09/25 23:33:28
> >
> > Modified: java/org/joist/database UserManager.java
> > Log:
> > One more less line.
> >
> > Revision Changes Path
> > 1.15 +2 -3 joist/java/org/joist​/database/UserManage​r.java
> >
> > Index: UserManager.java
> > ====================​====================​====================​=======
> > RCS file: /cvs/joist/java/org/​joist/database/UserM​anager.java,v
> > retrieving revision 1.14
> > retrieving revision 1.15
> > diff -u -r1.14 -r1.15
> > --- UserManager.java 2000/09/26 06:31:44 1.14
> > +++ UserManager.java 2000/09/26 06:33:28 1.15
> > @@ -61,7 +61,7 @@
> > * Manages users, including adding, retrieving, updating, and deleting.
> > *
> > * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
> > - * @version $Revision: 1.14 $
> > + * @version $Revision: 1.15 $
> > *
> > * Copyright (c) 1999 dataweb systems, inc.
> > * Copyright (c) 1999, 2000 Collab.Net, Inc.
> > @@ -253,8 +253,7 @@
> >
> > sqlStmt.append("null)");
> >
> > - int numRows = stmt.executeUpdate(s​qlStmt.toString());
> > - if (numRows != 1)
> > + if (stmt.executeUpdate(​sqlStmt.toString()) != 1)
> > {
> > throw new JoistDatabaseException("Failed to insert new user");
> > }
> >
> >
> >
> >

--

Daniel Rall <dlr at finemaltcoding dot com>

Re: [joist-dev] Re: [joist-cvs] CVS update: joist/java/org/joist/database UserManager.java

Author David Pellegrini <davidp at collab dot net>
Full name David Pellegrini <davidp at collab dot net>
Date 2000-09-27 00:39:31 PDT
Message +1

-davidp

Ed Korthof wrote:
>
> is this really an improvement? i understand the value in shortening the
> code where appropriate, but the old version seems far more intuitive than
> the new one (to me, anyway -- i'd have to look at the javadocs for
> PreparedStatement to be sure of what's going on).
>
> maybe that doesn't matter, but there are times when i'd prefer code to be
> clear rather concise -- maybe i've just read too many obfuscated c code
> contest entries. fwiw -- in terms of the actual byte code generated --
> i'd guess these two are equivalent.
>
> thanks --
>
> ed

Re: [joist-dev] Re: [joist-cvs] CVS update: joist/java/org/joist/database UserManager.java

Author brian
Full name Brian Behlendorf
Date 2000-09-26 10:01:53 PDT
Message Just a vote in favor of dlr's improvement.

    Brian

On Tue, 26 Sep 2000, Ed Korthof wrote:
> is this really an improvement? i understand the value in shortening the
> code where appropriate, but the old version seems far more intuitive than
> the new one (to me, anyway -- i'd have to look at the javadocs for
> PreparedStatement to be sure of what's going on).
>
> maybe that doesn't matter, but there are times when i'd prefer code to be
> clear rather concise -- maybe i've just read too many obfuscated c code
> contest entries. fwiw -- in terms of the actual byte code generated --
> i'd guess these two are equivalent.
>
> thanks --
>
> ed
>

--
-=-=-=-=-=-=-=-=-=-=​-=-=-=-=-=-=-=-=-=-=​-=-=-=-=-=-=-=-=-=-=​-=-=-=-=-=-=-=
CollabNet | open source | do what's right | now hiring

Re: [joist-cvs] CVS update: joist/java/org/joist/database UserManager.java

Author edk
Full name Ed Korthof
Date 2000-09-26 08:55:29 PDT
Message is this really an improvement? i understand the value in shortening the
code where appropriate, but the old version seems far more intuitive than
the new one (to me, anyway -- i'd have to look at the javadocs for
PreparedStatement to be sure of what's going on).

maybe that doesn't matter, but there are times when i'd prefer code to be
clear rather concise -- maybe i've just read too many obfuscated c code
contest entries. fwiw -- in terms of the actual byte code generated --
i'd guess these two are equivalent.

thanks --

ed
--
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
   | Ed Korthof | edk at collab dot net | 415-247-1690 |
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=

On 26 Sep 2000 dlr at tigris dot org wrote:

> User: dlr
> Date: 00/09/25 23:33:28
>
> Modified: java/org/joist/database UserManager.java
> Log:
> One more less line.
>
> Revision Changes Path
> 1.15 +2 -3 joist/java/org/joist​/database/UserManage​r.java
>
> Index: UserManager.java
> ====================​====================​====================​=======
> RCS file: /cvs/joist/java/org/​joist/database/UserM​anager.java,v
> retrieving revision 1.14
> retrieving revision 1.15
> diff -u -r1.14 -r1.15
> --- UserManager.java 2000/09/26 06:31:44 1.14
> +++ UserManager.java 2000/09/26 06:33:28 1.15
> @@ -61,7 +61,7 @@
> * Manages users, including adding, retrieving, updating, and deleting.
> *
> * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
> - * @version $Revision: 1.14 $
> + * @version $Revision: 1.15 $
> *
> * Copyright (c) 1999 dataweb systems, inc.
> * Copyright (c) 1999, 2000 Collab.Net, Inc.
> @@ -253,8 +253,7 @@
>
> sqlStmt.append("null)");
>
> - int numRows = stmt.executeUpdate(s​qlStmt.toString());
> - if (numRows != 1)
> + if (stmt.executeUpdate(​sqlStmt.toString()) != 1)
> {
> throw new JoistDatabaseException("Failed to insert new user");
> }
>
>
>
>
Messages per page: