objenesis

A collection of 1 posts

A Java geek
  • Me
  • Books
  • Speaking
  • Mentions
  • Focus
May 4, 2014 objenesis

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. There are

Nicolas Fränkel
A Java geek © 2008-2025
v. 35ca60281bc8118cd52938b438a09e15a937ec67/10128942251
Latest Posts