Note that there are some explanatory texts on larger screens.

plurals
  1. POQuote needed: Preprocessor usage is bad OO practice
    primarykey
    data
    text
    <p>I believe, that the usage of preprocessor directives like <code>#if UsingNetwork</code> 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 <code>IsUsingNetwork</code> 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.: <code>IService</code>, <code>ServiceImplementation</code>, <code>NetworkingServiceImplementation</code>).</p> <p>Can somebody please provide <strong>citations of OO-Gurus</strong> or <strong>references in books</strong> which basically reads "Preprocessor usage is bad OO practice if you try to configure behaviour which should be configured via an IoC container"? </p> <p><strong>I need this citations to convince coworkers to refactor...</strong></p> <p>Edit: I do know and agree that using preprocessor directives to change targetplatform specific code during compilation is fine and that is what preprocessor directives are made for. However, I think that runtime-configuration should be used rather than compiletime-configuration to get good designed and testable classes and components. In other words: Using #defines and #if's beyond what they are meant for will lead to difficult to test code and badly designed classes.</p> <p>Has anybody read something along these lines and can give me so I can refer to?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload