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

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -