Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #6515
| From | lewbloch <lewbloch@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Getter/Setter - Serialization |
| Date | 2011-07-24 11:51 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <920e6278-32ed-44ea-8a61-d1c38f531816@m3g2000pre.googlegroups.com> (permalink) |
| References | <c591a234-aa23-4894-a693-e8b09756c934@15g2000vbw.googlegroups.com> |
On Jul 24, 8:07 am, Thomas Lehmann <thomas.lehmann.priv...@googlemail.com> wrote: > Hi, > > probably a silly question. I have a class and some members will be > initialized only when calling a 'create' method. I'm using Eclipse and > there I get a warning "Found non-transient, non-static member. Please > mark as transient or provide accessors." > > My question is now how to handle it correct. When I provide a setter > (assume a creation date) then I could set the creation date to another > as initialized when calling 'create'. That's why I wouldn't provide a > setter for this member. But obviously the warning want to tell me that Did you declare the attribute as 'final'? If you want to protect a member variable from change, that's often the best way. It has other benefits as well. > I might have problems with the serialization then obviously requiring > that the setter exists (and yes I'm intending to do serialization - > probably XML). > > Could you please give some helpful comments on this? Could you please give us an SSCCE? http://sscce.org/ As markspace points out, we need some context here. To grok serialization, you should rigorously study the material in Joshua Bloch's seminal book /Effective Java/, which thoroughly covers the risks and best practices involved. http://java.sun.com/docs/books/effective/ Chapter 11 -- Lew
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Getter/Setter - Serialization Thomas Lehmann <thomas.lehmann.private@googlemail.com> - 2011-07-24 08:07 -0700
Re: Getter/Setter - Serialization markspace <-@.> - 2011-07-24 08:30 -0700
Re: Getter/Setter - Serialization Thomas Lehmann <thomas.lehmann.private@googlemail.com> - 2011-07-24 09:33 -0700
Re: Getter/Setter - Serialization markspace <-@.> - 2011-07-24 10:26 -0700
Re: Getter/Setter - Serialization Arne Vajhøj <arne@vajhoej.dk> - 2011-07-24 20:35 -0400
Re: Getter/Setter - Serialization lewbloch <lewbloch@gmail.com> - 2011-07-24 11:51 -0700
Re: Getter/Setter - Serialization Roedy Green <see_website@mindprod.com.invalid> - 2011-07-25 00:47 -0700
csiph-web