General Principles
The following is a list of language-agnostic development rules and principles that should be followed when working within any Rizing development project.
Rules related to specific languages can be found in their respective section (see catalog).
π Philosophyβ
Rizing's code base is built with the philosophy that less code is better code. We aim to write simple and concise software that is easily readable, consistent, and re-usable.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
Not every principle herein has to be strictly followed, and even fewer will be universally agreed upon. These are guidelines and nothing more, but they are ones codified over many years of collective experience by the authors of Clean Code.
π General Principlesβ
Below are a set of general principles that should be followed when working within any Rizing development effort.
- Be consistent
- Self documenting code
- Automate anything that can be automated
- If you see an issue (even if it's not yours) fix it or make a ticket to address it later
- Always follow Clean Code principles
The following is a set of general principles inspired by quotes directly from Clean Code.
LeBlanc's Lawβ
"Later equals never"
If the code can be cleaned up now, do it now - because later never happens.
Keep Code Cleanβ
"The only way to make the deadline β the only way to go fast β is to keep the code as clean as possible at all times."
Using the excuse that you can't write clean code because you don't have the time is not a valid argument.
Be Intentionalβ
"Clean code always looks like it was written by someone who cares"
Writing clean code doesn't just happen. You have to intentionally be explicit and thoughtful.
Be Proactiveβ
"Leave the campground cleaner than the way you found it."
You are not ONLY responsible for code you wrote, but for the system as a whole. If you see something wrong, fix it.
Writing Skillsβ
"Make the code read like a top-down set of paragraphs."
"Master programmers think of systems as stories to be told rather than programs to be written."
Clean code should not have to be analyzed, but rather read like a book. Readers should not have to do mental math or calculations, rather they should be able to read variable and function names and understand what is happening.
Self Documentingβ
Comments should explain why
not what
. What
your code is doing, should be self-evident.
"Every time you write a comment, you should grimace and feel the failure of your ability of expression."
"Donβt comment bad codeβrewrite it."
Code should be self documenting, meaning it can be clearly read like a book or set of instructions. If it cannot, then there is a failure in the code to express the intent.
One Word per Conceptβ
"Use the same concept across the codebase."
FetchValue() vs GetValue() vs RetrieveValue()
If you are using fetchValue() to return a value of something, use the same concept; instead of using fetchValue() in all the code, using getValue(), retrieveValue() will confuse the reader.
dataFetcher() vs dataGetter() vs dataFetcher()
If all three methods do the same thing, don't mix and match across the code base. Instead, stick to one.
FeatureManager vs FeatureController
Stick to either Manager or Controller. Again, consistency across the codebase for the same thing.
Don't Repeat Yourself (DRY)β
"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system."
At its simplest level, this basically means that you should aim to reduce the amount of duplicated code that exists.
Clarity is Kingβ
"One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king. Professionals use their powers for good and write code that others can understand."
π SOLID Principlesβ
Rizing development guidelines and principles are based on Clean Code and subsequently SOLID principles.
SOLID is the mnemonic acronym introduced by Michael Feathers for the first five principles named by Robert Martin, which meant five basic principles of object-oriented programming and design.
- S: Single Responsibility Principle (SRP)
- O: Open/Closed Principle (OCP)
- L: Liskov Substitution Principle (LSP)
- I: Interface Segregation Principle (ISP)
- D: Dependency Inversion Principle (DIP)
It is highly recomended that you read the book Clean Code and fully understand the concepts and ideas herein. You can review the Clean Code summary documentation and visualizations here.
π‘ Code Reviewsβ
All code that makes it into any production system must go through a code review process (triggered by a Pull Request). Once bugs are introduced into a codebase it is exponentially harder to find and get rid of them. The code review offers a last opportunity to stop bugs from being introduced into the codebase. It is a core requirement of all team members to participate in, and contribute to, the code review process.
Code Review Checklistβ
- Is the PR linked to an issue?
- Does the functionality work per the specifications?
- Does the code meet the coding standards guidelines?
- Do all linting and automated tests pass?
- Does new functionality have adequate test coverage?
- Does new functionality have adequate documentation coverage?
π§ Tooling & Automationβ
"Anything that can be automated, should be."
The success of Rizing development operations depend on the ability to scale development efforts and benefit from standard and predictable behavior and code. As a result, tooling should be implemented to automated anything that can be automated, whenver possible. Automations help keep things consistent and reduce repetative tasks. An example of such tools include; automatically running code formatters on save, git hooks, and pipeline build processes.
π Modifying Rulesβ
All coding standards documentation and rules are kept and maintained via Git, any recommended changes or enhancements to any standards should be made through a Pull Request.