Skip to main content
Copy edited (e.g. ref. <https://en.wikipedia.org/wiki/Xcode>, <https://en.wiktionary.org/wiki/macro#Noun_2>, and <https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle>). Introduced an abbr. used in an answer.
Source Link

Is updating a macro value in the Xcode preprocessors marcospreprocessor's macros violating open closedthe open–closed principle?

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)?

Is updating a macro value in Xcode preprocessors marcos violating open closed principle?

For example, for some xcode 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, it is violating principle. What if I define PAGE_MAX with macros? eg:

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

when I need to update the value, I open the project in xcode and go to "Preprocessor macros" session to change the value of XCODE_MACRO_PAGE_MAX in the UI, eg: from XCODE_MACRO_PAGE_MAX=5 to XCODE_MACRO_PAGE_MAX=6.

While I don't need to edit the .cpp, the macro replaces XCODE_MACRO_PAGE_MAX with the new value, which feels the effect as if changing the .cpp actually when changing the macro value, is it violating open closed principle?

Is updating a macro value in the Xcode preprocessor's macros violating the open–closed principle?

For example, for some Xcode 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? 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

When I need to update the value, I open the project in Xcode and go to the "Preprocessor macros" session to change the value of XCODE_MACRO_PAGE_MAX in the UI, 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 it violating the open–closed principle (OCP)?

Became Hot Network Question
edited tags
Source Link
wcminipgasker2023
  • 2.7k
  • 1
  • 14
  • 29

For example, for some xcode 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, it is violating principle. What if I define PAGE_MAX with macros? eg:

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 it in the Xcode -> Preprocessor macro sessionssession :

XCODE_MACRO_PAGE_MAX=5

when I need to update the value, I open the project in xcode and go to "Preprocessor macro sessions"macros" session to change the value of XCODE_MACRO_PAGE_MAX in the UI, eg: from XCODE_MACRO_PAGE_MAX=5 to XCODE_MACRO_PAGE_MAX=6.

While I don't need to edit the .cpp, the macro replaces XCODE_MACRO_PAGE_MAX with the new value, which feels the effect as if changing the .cpp actually when changing the macro value, is it violating open closed principle?

For example, for some xcode 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, it is violating principle. What if I define PAGE_MAX with macros? eg:

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 define it in the Xcode -> Preprocessor macro sessions :

XCODE_MACRO_PAGE_MAX=5

when I need to update the value, I open the project in xcode and go to "Preprocessor macro sessions" to change the value of XCODE_MACRO_PAGE_MAX in the UI, eg: from XCODE_MACRO_PAGE_MAX=5 to XCODE_MACRO_PAGE_MAX=6.

While I don't need to edit the .cpp, the macro replaces XCODE_MACRO_PAGE_MAX with the new value, which feels the effect as if changing the .cpp actually when changing the macro value, is it violating open closed principle?

For example, for some xcode 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, it is violating principle. What if I define PAGE_MAX with macros? eg:

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

when I need to update the value, I open the project in xcode and go to "Preprocessor macros" session to change the value of XCODE_MACRO_PAGE_MAX in the UI, eg: from XCODE_MACRO_PAGE_MAX=5 to XCODE_MACRO_PAGE_MAX=6.

While I don't need to edit the .cpp, the macro replaces XCODE_MACRO_PAGE_MAX with the new value, which feels the effect as if changing the .cpp actually when changing the macro value, is it violating open closed principle?

Source Link
wcminipgasker2023
  • 2.7k
  • 1
  • 14
  • 29

Is updating a macro value in Xcode preprocessors marcos violating open closed principle?

For example, for some xcode 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, it is violating principle. What if I define PAGE_MAX with macros? eg:

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 define it in the Xcode -> Preprocessor macro sessions :

XCODE_MACRO_PAGE_MAX=5

when I need to update the value, I open the project in xcode and go to "Preprocessor macro sessions" to change the value of XCODE_MACRO_PAGE_MAX in the UI, eg: from XCODE_MACRO_PAGE_MAX=5 to XCODE_MACRO_PAGE_MAX=6.

While I don't need to edit the .cpp, the macro replaces XCODE_MACRO_PAGE_MAX with the new value, which feels the effect as if changing the .cpp actually when changing the macro value, is it violating open closed principle?