dos-donts

Quote needed: Preprocessor usage is bad OO practice

梦想的初衷 提交于 2019-11-28 07:33:32
I believe, that the usage of preprocessor directives like #if UsingNetwork is bad OO practice - other coworkers do not. I think, when using an IoC container (e.g. Spring), components can be easily configured if programmed accordingly. In this context either a propery IsUsingNetwork can be set by the IoC container or, if the "using network" implementation behaves differently, another implementation of that interface should be implemented and injected (e.g.: IService , ServiceImplementation , NetworkingServiceImplementation ). Can somebody please provide citations of OO-Gurus or references in

Quote needed: Preprocessor usage is bad OO practice

我们两清 提交于 2019-11-27 01:51:31
问题 I believe, that the usage of preprocessor directives like #if UsingNetwork is bad OO practice - other coworkers do not. I think, when using an IoC container (e.g. Spring), components can be easily configured if programmed accordingly. In this context either a propery IsUsingNetwork can be set by the IoC container or, if the "using network" implementation behaves differently, another implementation of that interface should be implemented and injected (e.g.: IService , ServiceImplementation ,