Re: XStream versus XMLEncoder
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Wed, 05 Dec 2007 15:00:08 -0500
Mark Space wrote:
GArlington wrote:
....
Eclipse has option to generate getters and setters. And constructors
with (or without) parameters.
You do get a compile time error (or warning) if your private (I set
all vars private, unless they HAVE to be NOT private) vars are not
accessible.
And again, having all of the above (setters AND default constructor)
does not mean that YOU have to use them. In your program you can just
ignore them...
Not really. You still have to maintain them, write test cases against them, they still bloat your code and make downloads longer, etc.
This seems to me to be a basic POJO vs JavaBeans pattern discussion. Both have their place. Design the software the way it should be designed. Don't try to justify doing only one thing because "it's always no-cost." It'll cost somebody something.
In the ground of being behind Mark's advice is the notion that the class you wrote will be used.
Many of the gripes or suggestions for change with Java have to do with consumers of classes feeling like they don't have to worry about no steenkeen checked exceptions, or setters, or whatever. From the point of view of the *designers* of those classes is the concern that some client will, in fact, ignore that checked exception or call that setter. The designer may wish to close that loophole so that consumers of the class need not concern themselves with it, nor risk the consequences. Thus, declare a checked exception; consumer classes at least will not be surprised by them. Make the class members immutable; the client can ignore many threading issues and has no risk of constructed values suddenly, mysteriously changing to code for.
Client programmers may grumble that they know perfectly well how to construct an object completely before use, but just let their colleague forget to and they will curse the API writer's name for letting such a thing happen and how hard it is to debug and why, oh, why didn't they have the sense to make that member final?
--
Lew
.
- Follow-Ups:
- Re: XStream versus XMLEncoder
- From: apm35
- Re: XStream versus XMLEncoder
- References:
- XStream versus XMLEncoder
- From: apm35
- Re: XStream versus XMLEncoder
- From: GArlington
- Re: XStream versus XMLEncoder
- From: apm35
- Re: XStream versus XMLEncoder
- From: GArlington
- Re: XStream versus XMLEncoder
- From: Mark Space
- XStream versus XMLEncoder
- Prev by Date: Re: running external programs
- Next by Date: How to do file association through java????
- Previous by thread: Re: XStream versus XMLEncoder
- Next by thread: Re: XStream versus XMLEncoder
- Index(es):
Relevant Pages
|