A Java geek
  • Me
  • Books
  • Speaking
  • Mentions
  • Focus
  • Newsletters

objenesis

A collection of 1 posts
Java

Playing with constructors

Immutability is a property I look after when designing most of my classes. Achieving immutability requires: A constructor initializing all attributesNo setter for those attributes However, this design prevents or makes testing more complex. In order to allow (or ease) testing, a public no-arg constructor is needed. Other use-cases requiring usage of a no-arg constructor include: De-serialization of serialized objectsSub-classing with no constructor invocation of parent classesetc.

May 4, 2014
A Java geek © 2008-2026
v. 9744a65fcb2ff5057d025d26766c50d6f934fc0b/13747693232
Latest Posts