Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8962

Re: generics puzzle

From blmblm@myrealbox.com <blmblm.myrealbox@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: generics puzzle
Date 2011-10-18 17:45 +0000
Organization None
Message-ID <9g5salFh1jU2@mid.individual.net> (permalink)
References <9g2f24Fi0vU1@mid.individual.net> <45bfae98-a142-469b-9b8b-9aa8a59391f1@n13g2000vbv.googlegroups.com> <9g5i0eFnnbU2@mid.individual.net> <9g5nnhFahuU1@mid.individual.net>

Show all headers | View raw


In article <9g5nnhFahuU1@mid.individual.net>,
Robert Klemme  <shortcutter@googlemail.com> wrote:
> On 10/18/2011 04:49 PM, blmblm@myrealbox.com wrote:
> > In article<45bfae98-a142-469b-9b8b-9aa8a59391f1@n13g2000vbv.googlegroups.com>,
> > Robert Klemme<shortcutter@googlemail.com>  wrote:
> >> On Oct 17, 12:41 pm, blm...@myrealbox.com<blmblm.myreal...@gmail.com>
> >> wrote:
> 
> > Nice job of putting into words my vague idea about what's wrong;
> > thanks!
> 
> Thank _you_.
> 
> >> In your case since apparently you want to update internally why not
> >> just introduce
> >>
> >> public void update() {
> >>    set(modified());
> >> }
> >
> > I'm not sure I can say why this doesn't appeal to me -- something
> > about not wanting to clutter up GThing with unnecessary methods.
> 
> Why is it unnecessary?  It seems this provides a proper abstraction.  As 
> your example shows and concluding from what you write below you do 
> already have two or more uses for it.  So by having the method you can 
> actually reduce redundancy.  That's a common pattern: we find we do 
> something over and over again, we turn it into a method or procedure.

Yeah, maybe.  I'll look some more at my actual code.

> >> This will safely compile.  Basically this is what you did with
> >> setModified() in the wrapper class.  All other approaches will be
> >> hacky (i.e. involve explicit casting, using Object parameters or
> >> return values etc.).
> >
> > Yeah, maybe ....  In my "real" code (quotation marks because it's
> > a toy project embarked on for entertainment and a bit of education)
> > the method in the wrapper class does more than just call modified()
> > and then set().  I don't know that that matters much, though.  I do
> > have a couple of different "call sites" (to use another poster's term)
> > that need similar functionality, so maybe it *does* go in GThing.
> > Well, like I said, "entertainment and a bit of education", and for
> > me that seems to involve -- the coding equivalent of periodically
> > rearranging the furniture, maybe.
> 
> That's called "refactoring" - and is quite frequent with "real" code in 
> my experience. :-)  Certainly not something to be afraid of - with 
> proper tools it can even be fun. :-)

Well, I obviously think it's fun, or I wouldn't do so much of
it?  I do know the term "refactoring", but to me it suggests an
activity somehow more purposeful than what I feel like I'm doing.
Good to know, by the way, that it does happen with real code --
I've been away from professional programming for a long time and
don't keep up as well as I might with current practices.

(About tools -- I'm a long-time vim user, more than a little
fanatical about my text editor of choice, but more and more for
Java code I find myself also starting Eclipse to do some of the
things *it* does well, and finding more and more things in that
category -- automatic generation of imports and boilerplate code,
renaming of classes, etc.)

> I think you're on the right track: best learning experience is by having 
> a toy project and trying out different things.  That way you see what 
> works and what not - and you get the satisfaction of having found out 
> yourself.

True.  (For what it's worth -- I may be less of a novice than I'm
coming across as, having written my first program in 1970-something.
But the learning doesn't stop, or shouldn't?)

-- 
B. L. Massingill
ObDisclaimer:  I don't speak for my employers; they return the favor.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-17 10:41 +0000
  Re: generics puzzle Steven Simpson <ss@domain.invalid> - 2011-10-17 13:14 +0100
    Re: generics puzzle Tom Anderson <twic@urchin.earth.li> - 2011-10-17 15:14 +0100
    Re: generics puzzle markspace <-@.> - 2011-10-17 07:33 -0700
      Re: generics puzzle Steven Simpson <ss@domain.invalid> - 2011-10-17 16:26 +0100
        Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-18 14:48 +0000
      Re: generics puzzle Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-10-17 15:36 +0000
    Re: generics puzzle Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-17 08:58 -0700
      Re: generics puzzle Steven Simpson <ss@domain.invalid> - 2011-10-18 10:45 +0100
        Re: generics puzzle Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-18 09:42 -0700
          Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-19 13:25 +0000
            Re: generics puzzle Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-19 10:04 -0700
              Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-20 14:14 +0000
                Re: generics puzzle Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-20 11:11 -0700
  Re: generics puzzle Robert Klemme <shortcutter@googlemail.com> - 2011-10-17 09:12 -0700
    Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-18 14:49 +0000
      Re: generics puzzle Robert Klemme <shortcutter@googlemail.com> - 2011-10-18 18:27 +0200
        Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-18 17:45 +0000
          Re: generics puzzle Robert Klemme <shortcutter@googlemail.com> - 2011-10-18 22:15 +0200
          Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-18 18:59 -0700
            Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-19 13:28 +0000
              Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-20 17:21 -0700
                Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-21 16:27 +0000
                Re: generics puzzle Robert Klemme <shortcutter@googlemail.com> - 2011-10-21 20:34 +0200
                Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-22 18:50 +0000
                Re: generics puzzle Tom Anderson <twic@urchin.earth.li> - 2011-10-22 21:02 +0100
                Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-25 07:04 +0000
                Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-25 23:25 -0700
                Re: generics puzzle Tom Anderson <twic@urchin.earth.li> - 2011-10-26 21:56 +0100
                Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-27 08:59 +0000
                eclipse shortcuts again (was Re: generics puzzle) blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-29 17:05 +0000
                Re: eclipse shortcuts again (was Re: generics puzzle) Four of Seventeen <fseventeen@gmail.com> - 2011-10-29 19:49 -0700
                Re: eclipse shortcuts again (was Re: generics puzzle) blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-31 11:17 +0000
                Re: eclipse shortcuts again (was Re: generics puzzle) Four of Seventeen <fseventeen@gmail.com> - 2011-10-31 05:39 -0700
                Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-23 01:30 -0700
                Re: generics puzzle Lew <lewbloch@gmail.com> - 2011-10-23 08:56 -0700
                Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-24 02:46 -0700
                Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-25 07:05 +0000
                Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-25 23:29 -0700
                Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-31 11:14 +0000
                Re: generics puzzle Four of Seventeen <fseventeen@gmail.com> - 2011-10-31 05:34 -0700
          Re: generics puzzle markspace <-@.> - 2011-10-18 21:21 -0700
            Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-19 13:29 +0000
              Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-20 17:22 -0700
                Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-21 16:28 +0000
              Re: generics puzzle Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-10-21 06:22 -0300
                Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-21 16:29 +0000
                Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-23 01:20 -0700
                Re: generics puzzle Martin Gregorie <martin@address-in-sig.invalid> - 2011-10-23 09:51 +0000
                Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-23 03:28 -0700
                Re: generics puzzle Tom Anderson <twic@urchin.earth.li> - 2011-10-23 15:59 +0100
                Re: generics puzzle Eight of Seventeen <eights17@gmail.com> - 2011-10-24 02:46 -0700
                Re: generics puzzle Tom Anderson <twic@urchin.earth.li> - 2011-10-23 15:55 +0100
            Re: generics puzzle Tom Anderson <twic@urchin.earth.li> - 2011-10-20 21:00 +0100
          Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-19 13:26 +0000
          Re: generics puzzle Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-10-21 05:57 -0300
            Re: generics puzzle blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-10-21 16:28 +0000

csiph-web