Is it violation of Clean Code to call init method in constructor like this

后端 未结 6 2191
自闭症患者
自闭症患者 2020-12-14 21:05

My concern in the code below is that the param to constructor is not actually directly mapped to the class\'s instance fields. The instance fields derive value from the para

6条回答
  •  被撕碎了的回忆
    2020-12-14 21:29

    Although its not the most elegant way to do it, I don't see it as flawed from OO perspective. However, if you are not calling the private method initalizeCanvas from anywhere else within the class, then you can consider moving those three lines to the constructor itself.

提交回复
热议问题