class - c# and functional purity -
i've been having use c# lately, don't have experience in. conundrum keep finding myself in is, when building class, having state dependent on state initialized before it
class foo{ public bar_ {get;} public dum_ {get;} public foo (){ bar_ = buildbar(); dum_ = builddum(bar_); } }
its bit redundant builddum carry parameter if it's going use accessable member. on other hand explicitly pointing out dependencies function relies on
i guess asking: best way handle situation?
both ways fine. current version of builddum
made static
, in case it's fine method not access member variables, because cannot anyway:
private static dum builddum(bar b) { ... }
if make builddum
accesses bar_
directly, should make access _dum
, i.e. should non-static void
:
private void builddum() { ... _dum = ... }
Comments
Post a Comment