Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: blmblm@myrealbox.com Newsgroups: comp.lang.java.programmer Subject: Re: generics puzzle Date: 18 Oct 2011 17:45:57 GMT Organization: None Lines: 76 Message-ID: <9g5salFh1jU2@mid.individual.net> References: <9g2f24Fi0vU1@mid.individual.net> <45bfae98-a142-469b-9b8b-9aa8a59391f1@n13g2000vbv.googlegroups.com> <9g5i0eFnnbU2@mid.individual.net> <9g5nnhFahuU1@mid.individual.net> X-Trace: individual.net zybzefPJG0ghYxgFvyGPZAnQMj/nG8wcql1Ad7kx9r8k/m0eTR X-Orig-Path: not-for-mail Cancel-Lock: sha1:KcH39t+Uw9EympEKI2gttlr2Q0o= X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8962 In article <9g5nnhFahuU1@mid.individual.net>, Robert Klemme wrote: > On 10/18/2011 04:49 PM, blmblm@myrealbox.com wrote: > > In article<45bfae98-a142-469b-9b8b-9aa8a59391f1@n13g2000vbv.googlegroups.com>, > > Robert Klemme wrote: > >> On Oct 17, 12:41 pm, blm...@myrealbox.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.