-
Notifications
You must be signed in to change notification settings - Fork 10
Coding Conventions
Janaka Ranasinghesagara edited this page Jan 25, 2026
·
4 revisions
When contributing to the MieSimulatorGUI, please follow the coding conventions detailed below. These guidelines represent the established style observed in the core simulation engine (e.g., Calculate and MieSimulation classes).
-
Camel Case: Naming convention where the first letter of each word is capitalized with the exception of the first letter. Example:
thisIsCamelCase -
Pascal Case: Naming convention where the first letter of every word is capitalized. Example:
ThisIsPascalCase -
M-Prefix Pascal Case: Member variables prefixed with a lowercase 'm' followed by the variable name in Pascal Case. Example:
mMemberVariable
-
Source and Header Files: Must be lowercase.
-
Example:
miesimulation.cpp,miesimulation.h, .
-
Example:
-
Classes and Functions: Must be Pascal Case.
-
Example:
class Calculate,void DoSimulation(),double CalculateG().
-
Example:
-
Member Variables: Must use M-Prefix Pascal Case.
-
Example:
mWavel,mQSca,mMinTheta.
-
Example:
-
Local Variables and Parameters: Must be Camel Case.
-
Example:
stepTheta,para,curMus.
-
Example:
-
UI Methods (Qt Slots): Should follow the standard Qt underscore convention.
-
Example:
on_button_clicked.
-
Example:
-
Constants and Macros: Must be Uppercase Underscore Delimited.
-
Example:
CALCULATE_H,M_PI.
-
Example:
Code should be indented with 4 space characters, if a tab character is used, make sure your source-code editor replaces tabs with 4 spaces.
An opening brace { should appear on the line after the start of a statement block and the code inside the brace should be indented 4 spaces. The closing brace } should be inline with the opening brace on it's own line.
Spacing improves the readability of the source-code, follow these guidlines for spacing:
- Use a space after commas between function arguments:
void Function(int a, int b). - Use a space after control statements like
if,while, andfor:for (unsigned int i = 0; ...). - Use a space before and after binary operators:
x = a + borrefRelRe = para->scatRefRealArray[r] / para->medRefArray[r]. -
No space between a function name and its opening parenthesis:
CalculateG(curS1, curS2, para).
The following snippet demonstrates the conventions used in the project:
#ifndef SAMPLE_H
#define SAMPLE_H
class Simulation
{
public:
Simulation(void);
double mResultValue; // Member variable with 'm' prefix
void RunProcess(Parameters *para)
{
double localStep = 0.1; // Local variable in Camel Case
for (int i = 0; i < para->nTheta; i++)
{
if (i % 2 == 0)
CalculateInternal(i);
else
{
mResultValue += i * localStep;
UpdateLog();
}
}
}
private:
void CalculateInternal(int value);
};
#endif