vendredi 20 novembre 2015

Clean solution for optional yet required variables

Is there some kind of design pattern for the following situation?

Current design

Requirements:

  • lat and lon are always required.
  • place and name are optional (can be null).
  • When the optional variables are null, getPlace() and getName() should return the lat and lon as string.

The current situation seems kinda "dirty" to me, so i was wondering if there is "clean" solution. I could not find the answer myself.

Aucun commentaire:

Enregistrer un commentaire