{"id":20468992,"url":"https://github.com/neko-box-coder/simplecodingstyle","last_synced_at":"2026-03-19T16:01:54.032Z","repository":{"id":177865417,"uuid":"661023679","full_name":"Neko-Box-Coder/SimpleCodingStyle","owner":"Neko-Box-Coder","description":"My own personal simple coding style for all languages","archived":false,"fork":false,"pushed_at":"2025-04-04T23:53:05.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T12:04:47.131Z","etag":null,"topics":["code-style","code-style-guide","coding-style"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Neko-Box-Coder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-01T14:48:24.000Z","updated_at":"2025-04-04T23:53:08.000Z","dependencies_parsed_at":"2025-04-04T22:24:51.826Z","dependency_job_id":"89c88cb4-52de-4a93-a459-0489688aec74","html_url":"https://github.com/Neko-Box-Coder/SimpleCodingStyle","commit_stats":null,"previous_names":["neko-box-coder/simplenamingconvention","neko-box-coder/simplecodingconvention"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Neko-Box-Coder/SimpleCodingStyle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FSimpleCodingStyle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FSimpleCodingStyle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FSimpleCodingStyle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FSimpleCodingStyle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neko-Box-Coder","download_url":"https://codeload.github.com/Neko-Box-Coder/SimpleCodingStyle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FSimpleCodingStyle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28852750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-style","code-style-guide","coding-style"],"created_at":"2024-11-15T14:07:35.097Z","updated_at":"2026-01-28T21:31:44.783Z","avatar_url":"https://github.com/Neko-Box-Coder.png","language":null,"readme":"## 🖌️ Simple Coding Style\n---\nMy own personal simple coding style for C++, but most of them can be apply to many languages.\n\nThis is the style I used for all my personal repositories. And also for other people to reference \nif needed.\n\nThe intention of this coding style is just to keep things __simple and natural__. \n\n__No cryptic prefixes, suffixes and underscores__ that are specific to different languages.\n\n|\n\nThis style just utilizes different case types and English grammar to differentiate different \nentities and intentions.\n\nHere are the cases that are used in this coding style:\n- PascalCase: `ThisIsAnExampleOfPascalCase`\n- camelCase: `thisIsAnExampleOfCamelCase`\n- MACRO_CASE: `THIS_IS_AN_EXAMPLE_OF_MACRO_CASE`\n\n### 🗿 Architecture and Philosophy\n---\n\nThis section applies to most languages, not just c++\n\n#### Keep it simple, stupid\nThings are always changing, new deadlines, new features, new requirements.\n\nInstead of spending time over-engineering and designing something that you don't know how it will \nwork out (and you never will, unless you can predict the future), get it working first. After that\nyou can do whatever you want, refactor it, clean it, etc.\n\nNothing is future proof and don't waste your time trying to pretend you will design something \nfuture proof. Something \"good enough\" is often the right balance between how much time is spent on\ndesigning the architecture and implementation to allow changes if needed.\n\n#### Priority readability and iterability over pre-mature optimization\nThis of course is different per context/scenarios, but generally languages are fast enough under \nmost use-cases, and performance often only matters under certain part of a program (i.e. a hot loop).\n\nSacrificing readability and iterability (i.e. using an array/struct for better CPU caching over \n(linked) list strurcture that reads better) on non performance critical part isn't worth it.\n\nThat is not to say you should make it inefficient, small habits like adding `const` and using \nreference is generally good to do and doesn't hurt readability.\n\nA good rule of thumb is \"Make it easy to read first, then make it run faster\"\n\n#### No Inheritance, No OOP, No Interface, No \"Clean Code\", No \"SOLID\"\nThe mainstream really endorse OOP. Schools, corporates, books are all praising it because it is \n\"Battle Tested\" and is the industry de facto, not knowing how painfully confusing to navigate \nand difficult to add features to these codebase. Not to mention it is slower as well, see \n[\"Clean\" Code, Horrible Performance](https://www.youtube.com/watch?v=tD5NrevFtbU) by Casey Muratori.\n\nHere by OOP I mean **object inheritance and interfaces**, not functions that are binded to \na data structure, not RAII.\n\nOOP sounds great on paper, you re-use things with hierarchical design, isolation of concerns and \nallow easy testing. But in practice it often falls short in terms of readability and iterability.\n\nTrying to follow through a flow on what a function does? Too bad you will have to go to 20 \ndifferent files to understand which concrete functions **can** be called, not to mention there\ncan be **more than 1** concrete functions can be called if it is a multi-layer inheritance. \n\nUsing interfaces to make it easier for testing? Good luck diving through many layers and wrappers \nwhen you are trying to debug or read the code, only to find out the logic is a dynamic \ndelegate/function object that is spawned and configured somewhere else and you now have to find \nwhere that is. Also good luck adding new features since the moment you change the interface, \nyou are forced to update 20 other classes (and tests) that are dependent on that interface.\n\nOf course \"Clean Code\" and \"SOLID\" says none of these are an issue if you follow their rules.\nThis will be true if we live in a perfect world where there are no deadlines, no change of \nrequirements, no unique new features, no special use cases from the customer, etc. \n\nBut we don't live in a perfect world, this is just a lie so that people can sell books and host \ntalks and the only people can do this are big corporations which can afford to this and the rest\nof us are wasting time trying to perfect something that is always imperfect. \n\nI have been to [this](https://github.com/Neko-Box-Coder/ssGUI) \n[path](https://github.com/Neko-Box-Coder/CppOverride) (Using OOP) and **DEEPLY** regretted it. \n\nJust implement the damn thing. \n\n#### Composition, If and Switch Statements\n\nInstead of OOP and all those shit, just use composition, good ol' if statements and switch \nstatements when you need to generalize something. Not only it is easier to read since now each \nfunction in the generalization shows **EXACTLY** what concrete functions it will call, it is easier\nto debug as well since you can can access all the concrete data just by poking into the member \ndata structure.\n\n#### Explicit abstractions over implicit abstractions, no need to hide implementations\n\nTODO...\n\n#### Simple, explicit code leads to readability\n\n\n### ✏️ Identifiers / Names\n---\nIdentifiers or names should require minimum context to understand their purpose or what they store. \nTherefore, abbreviations should be avoided as it requires context to understand what it stands for. \n\nTry to be __simple and explicit__ (and sometimes long) rather than cryptic and short. \n\n- #### Anything (enum value, variables, etc...) constant or macro - MACRO_CASE\n    - **Explanation:** Macro case is used in many places that denote __constants__ and __macros__ \n    due to historic reasons. This can easily tell that something is __CONSTANT__ and \n    __you can't change it__.\n    - Example: `static const int NUM_OF_LEGS_FOR_HUMANOID = 2;`\n- #### Anything lives inside a function - camelCase\n    - **Explanation:** This can easily differentiate a __local variable__ in a function against \n    class or global variables and is especially helpful in a relatively long function.\n        ```c++\n            //Example\n            float NormalizedSum(int* vec, size_t count, int min, int max)\n            {\n                int sum = 0;\n                for(int i = 0; i \u003c count; i++)\n                    sum += vec[i]\n            \n                float normalizeRange = max - min;\n                return (float)(sum - min) / normalizeRange;\n            }    \n        ```\n- #### Anything that can be accessed outside a function - PascalCase\n    - **Explanation:** Clean, easy to read without any cryptic underscores or prefixes/suffixes, \n    and can clearly indicate it can be used/accessed by other functions.\n    - __Types Names or Class/Namespace Identifier - Explicit Noun__\n        - Example: `class ModulesManager`\n    - __Class/Global variables names - Explicit Noun Or State__\n        - Example: `bool Initialized;`\n        - \n        - Normally, class variable name should tell its purpose and therefore be different from \n        its type identifier.\n          However, if this is not possible, simply prepending a word like __`Current`__ will do the \n          job to tell it is not a type.\n        - Example: Type `ModulesManager` and class variable `CurrentModulesManager` \n    - __Function names - Explicit Verb, Question or Query__\n        - Example: Function `void CheckStatus()` or `bool IsStatusChecked()`.\n    - Example:\n        ```c++\n            //Example\n            #ifndef HUMANOID_ENEMY_HPP\n            #define HUMANOID_ENEMY_HPP\n            namespace MyGame\n            {\n                class HumanoidEnemy\n                {\n                    private:\n                        bool Initialized;\n                        ModulesManager CurrentModulesManager;\n                        bool StatusChecked;\n                        static const int NUM_OF_LEGS_FOR_HUMANOID = 2;\n                    public:\n                        HumanoidEnemy();\n                        ~HumanoidEnemy();\n                        void Initialize();\n                        void CreateModule(std::string moduleName);\n                        void RemoveModule(std::string moduleName);\n                        void CheckStatus();\n                        bool IsStatusChecked();\n                };\n            }\n            #endif\n        ```\n\n### 📐 Formatting\n---\n- #### Auto Formatter - No\n    - **Explanation:** This is because it requires quite some effort to setup and is often not \n    flexible enough. \n    - If a formatter is required, Microsoft style with slight modification suits the best.\n- #### Indentations - 4 spaces and indent for every section/block if possible\n    - **Explanation:**\n        - Allow differentiating __blocks/sections of code easily__\n        - Spaces allow __easier manual formatting__\n        - Guarantee to look the same __across machines and websites__.\n        - You can configure on most of the modern IDE or text editor to align and output 4 \n        spaces quite easily.\n- #### Bracket style - Newline and same indentation\n    - **Explanation:** Easier to read by providing spacing against the block content. Especially\n    when dealing multi-line if statement where the bracket in newline helps differentiate the if\n    statement lines and the actual content lines.\n    - Example:\n        ```\n            if( HasSomethingHappened() ||\n                HasSomethingElseHappened() ||\n                HasSomeOtherThingsHappened())\n            {\n                DoSomethingUrgent(a, b);\n                DoSomethingNext();\n            }\n            else\n            {\n                DoSomethingNotUrgent(a, b);\n                DoSomethingElseNext();\n            }\n\n            //Instead of\n\n            if( HasSomethingHappened() ||\n                HasSomethingElseHappened() ||\n                HasSomeOtherThingsHappened()) {\n                DoSomethingUrgent(a, b);\n                DoSomethingNext();\n            } else {\n                DoSomethingNotUrgent(a, b);\n                DoSomethingElseNext();\n            }\n        ```\n    - The first one looks perfectly spaced and logical, while the second one looks clustered and\n    difficult to differentiate if statements and the actual execution statements\n    - **Explanation:** Makes commenting and temporary change much easier to do\n    - Example:\n        ```c++\n            if(condition())\n            {\n                //Many statements here\n            }\n            \n            //Can be commented out to skip the condition easily like this\n            \n            //if(condition())\n            {\n                //Many statements here\n            }\n            \n            //Or to temporary disable a block but still have it being compiled\n            \n            //if(condition())\n            if(false)\n            {\n                //Many statements here\n            }\n- #### Nested Functions such as Lambda - Treat as new block\n    - **Explanation:** Nested functions are **functions** and should be treated and formatted \n    like so to be **consistent**.\n    -   Example: \n        ```c++\n            void SomeFunction()\n            {\n                auto someLambda = []()\n                {\n                    //...\n                }\n                \n                //Or move the [...](...) to its own line if it gets too long, but indented\n                auto someLongLambda = \n                [\u0026MyVar, \u0026MyVar2, \u0026MyVar3, ...](int myParam, int myParam2, int myParam3, ...)\n                {\n                    \n                }\n                \n                //Or like this (See Multilines section)\n                auto someLongLambda = \n                [\n                    \u0026MyVar, \n                    \u0026MyVar2, \n                    \u0026MyVar3, \n                    ...\n                ]\n                (\n                    int myParam, \n                    int myParam2, \n                    int myParam3, \n                    ...\n                )\n                {\n                    ...\n                }\n            }\n    \n        ```\n- #### Width/Column Limit - 100 characters\n    - **Explanation:**\n        - 100 characters hard limit allows the source file to be limited to half of the width of \n        any display, which...\n        - Allows __side by side__ header and source files\n        - If a line is too long, it should be __spread across multiple lines by parameters or \n        member action.__ (See Multilines section)\n- #### Multilines\n    - Try to align with nearest tab with parameters or statements. \n        - **Explanation:** Aligning with nearest tabs makes manual formatting a lot quicker, \n        it's a good compromise.\n    - For assignment, you can also split right half (i.e. after `=`) to next line indented if \n    doesn't fit single line. \n        - **Explanation:** Splitting assignment to 2 lines when needed is also readable and easy\n        to format.\n    - If the above 2 is not possible, format the parameters by blocks like a function block\n        - **Explanation:** This is a last resort and should be used sparingly. It looks slightly\n        weird but it is consistent with how lambdas and how function is declared. This is \n        particularly useful when used in an deeply nested indented block.\n    - Long Assignment\n        ```c++\n            MyClass myVariable = \n                someVariable.FirstFunction(mySuperDuperLongArgName, mySuperDuperLongArgName2);\n            \n            //Or\n            \n            MyClass myVariable = someVariable.FirstFunction(mySuperDuperLongArgName, \n                                                            mySuperDuperLongArgName2);\n        ```\n    - Function:\n        ```c++\n                                                //Align variables to the nearest tab width\n            void FunctionWithLotsOfParameters(  int a,\n                                                bool b,\n                                                std::string c,\n                                                std::vector\u0026 someVector,\n                                                //A few more parameters...\n                                                uint32_t finalParameter)\n            {\n                //...\n            }\n        ```\n    - Long if\n        ```c++\n                //Align to nearest tab width\n            if( (ConditionFunction(var1, var2, var3) \u0026\u0026 \n                conditionVariable \u0026\u0026 \n                conditionVariable2) ||\n                conditionVariable3)\n            {\n                DoSomething();\n            }\n        ```\n    - Long Lambda\n        ```c++\n            auto someLongLambda = \n            [\n                \u0026MyVar, \n                \u0026MyVar2, \n                \u0026MyVar3, \n                ...\n            ]\n            (\n                int myParam, \n                int myParam2, \n                int myParam3, \n                ...\n            )\n            {\n                ...\n            }\n        ```\n    - Constructor\n        ```c++\n            //Normal case\n                                                        //Align to nearest tab width\n            runcpp2::NodeRequirement::NodeRequirement(  const std::string\u0026 name, \n                                                        ryml::NodeType nodeType, \n                                                        bool required,\n                                                        bool nullable) :    Name(name), \n                                                                            NodeType(nodeType), \n                                                                            Required(required), \n                                                                            Nullable(nullable)\n            {\n                ...\n            }\n            \n            //Extreme case\n                                            //Align to nearest tab width\n            HumanoidEnemy::HumanoidEnemy(   int myParam1, \n                                            const std::unordered_map\u003cstd::string, int\u003e\u0026 myParam2, \n                                            std::unordered_map\u003c std::string, \n                                                                std::vector\u003cMyObject\u003e\u003e\u0026 myParam3,\n                                            const std::unordered_map\n                                            \u003c\n                                                std::string, \n                                                std::vector\u003cconst MyObject\u0026\u003e\n                                            \u003e\u0026 myParam4,\n                                            std::vector\u003cstd::pair\u003cint, bool\u003e\u003e myParam5) :\n                //Move to indented newline since there is no space after :\n                MyMember1(myParam1),\n                MyMember2(myParam2),\n                MyMember3(myParam3),\n                MyMember4(myParam4),\n                MyMember5(myParam5)\n            {\n                ...\n            }\n        ```\n    - Function Call With Many/Long Arguments\n        ```c++\n                                //Align to nearest tab width\n            SomeFunctionCall(   MyArgWithLongName1, \n                                MyArgWithLongName2, \n                                MyArgWithLongName3,\n                                MyArgWithLongName4);\n            \n            //Or in a very nested indented situation\n            \n            bool MyFunction(...)\n            {\n                for(...)\n                {\n                    if(...)\n                    {\n                        for(...)\n                        {\n                            MY_MACRO_FOR_HANDLING_ERROR\n                            (\n                                SomeFunctionCall\n                                (\n                                    MyArgWithLongName1, \n                                    MyArgWithLongName2, \n                                    MyArgWithLongName3,\n                                    MyArgWithLongName4\n                                )\n                            );\n                        }\n                    }\n                }\n                \n                ...\n            }\n        ```\n    - Function Chaining\n        -   Align with `.`/`-\u003e` operator\n            ```c++\n                            //Align to nearest tab width\n                someVariable.FirstFunction()\n                            .SecondFunction()\n                            .ThirdFunction();\n            ```\n        - Align with block if unable to align with `.`/`-\u003e` operator\n            ```c++\n                                    //Align to nearest tab width\n                FunctionInSameScope (var1, var2, var3, var4, var5, ...)\n                                    .SecondFunction()\n                                    .ThirdFunction(var1, var2, ...);\n            ```\n- #### Omitting Bracket - Only when the condition and action are short\n    - Saves a few lines, quicker and easier to read if an empty line is there to separate each block.\n      While it is possible to misindent multiple actions, it rarely happens to me \n      and compilers are smart enough to give warnings.\n        ```c++\n            if(!IsWaterBoiled())\n                BoilWater();\n\n            if(!HasChocolatePowder())\n                GetTeaBag();\n            else\n                GetChocolatePowder();\n\n            CreateBeverage();\n        ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fsimplecodingstyle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneko-box-coder%2Fsimplecodingstyle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fsimplecodingstyle/lists"}