java - What is the best way to share variables between a large number of classes? -
i'm using java complicated calculations, , have lot of classes need access lot of same variables. these variables set @ different stages of calculations, in different classes. problem code getting quite messy being forced pass same parameters lot of different methods.
i looking peoples thoughts on best approach here be? 1 idea have make superclass these variables set in , extend class everywhere needed.
another option pass object holding information around method method seems overly complex. neither of these solutions feel cleanest approach me. thoughts or suggestions of design patterns/ideas may me appreciated. help.
i'm going suggest using wrapper
object best way this. make sure fields immutable (final
keyword in java). use builder
or prototype
pattern create new objects return.
Comments
Post a Comment