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. 8f592105c8c8496dd381db0f812a256124cd3f4e/10323071522
Latest Posts