For example, for some xcodeXcode projects, if I have some places that defines a number at some .cpp files:
const int PAGE_MAX=5;
and a new requirement comes that needs to change PAGE_MAX, I need to modify the .cpp file, and it is violating the principle. What if I define PAGE_MAX with macros? eg:For example,
const int PAGE_MAX=XCODE_MACRO_PAGE_MAX;
but XCODE_MACRO_PAGE_MAX is not defined in other headers ,.c,or .cpp files, instead I add the define in the Xcode ->→ Preprocessor macro session :
XCODE_MACRO_PAGE_MAX=5
whenWhen I need to update the value, I open the project in xcodeXcode and go to the "Preprocessor macros" session to change the value of XCODE_MACRO_PAGE_MAX in the UI, eg:for example, from XCODE_MACRO_PAGE_MAX=5 to XCODE_MACRO_PAGE_MAX=6.
While I don't need to edit the .cpp file, the macro replaces XCODE_MACRO_PAGE_MAX with the new value, which feels the effect as if changing the .cpp file actually when changing the macro value, is. Is it violating open closed principlethe open–closed principle (OCP)?