Coding Guidelines
“Good code is written so that is readable, understandable, covered by automated tests, not over complicated and does well what is intended to do.”
https://engineering.intenthq.com/2015/03/what-is-good-code-a-scientific-definition/SmartDB/PinkDB
SmartDB is an Oracle-centric methodology for applications that use the Oracle Database. Many of the concepts can be generalised across all database technologies. PinkDB is a similar cross database methodology.
http://stevenfeuersteinonplsql.blogspot.com/2018/05/the-smartdb-resource-center.htmlhttps://www.salvis.com/blog/2018/07/18/the-pink-database-paradigm-pinkdb/
Stored Procedures vs Application Codehttps://rob.conery.io/2015/02/21/its-time-to-get-over-that-stored-procedure-aversion-you-have/
Design is everything. #SMARTDB philosophy these days (when everyone is forcing you to use cloud) is more important than ever before.
If your application is chatty and is using a lot of packets to solve the same problem – you are not cloud-ready.
Comments
Comments explain the code’s purpose
Comments explain the code
Comments highlight the potential gotchas
Comments provide landmarks for future work
https://blogs.oracle.com/javamagazine/post/java-comments-reduce-technical-debt
Functions
"FUNCTIONS SHOULD DO ONE THING. THEY SHOULD DO IT WELL. THEY SHOULD DO IT ONLY."
Robert C. Martin"Functions should either do something or answer something, but not both."
Robert C. MartinUser Input
“Test input for plausibility and validity"
Brian Kernighan and P.J. Plauger"Never trust user input"
Ian DarwinTest-Driven Development (TDD)
KISS
Keep It Simple, Stupid"The purpose of software engineering is to reduce complexity, not to create it."
Pamela ZaveDRY
Don't Repeat YourselfThe goal of DRY is to reduce repetition of code. If you need to call it more than once, make it a Function. If you need to call it more than once and in multiple programs, consider a "microservice" rather than repeating the code in each program.
YAGNI
You Aren't Gonna Need ItDon't bloat your code with code you don't need yet. Don't put in a function that nothing calls yet. Add that function if/when that functionality becomes a concrete requirement.
SOLID
Single Responsibility Principle (SRP)
"SRP says to keep together things that change for the same reason, and seperate things that change for different reasons. Divergent change occurs when you group together things that change for different reasons. Shotgun surgery happens when you keep apart those things that change for the same reaon."
Robert C. Martinhttps://sites.google.com/site/unclebobconsultingllc/getting-a-solid-startOpen-Closed Principle
Liskov Subsitution Principle
Interface Segregation Principle
Dependency Inversion Principle
SoC
Separation of Concerns- See also "Functions" above.
- See also "Single Responsibility Principle (SRP)" above.
"One of the good examples of SoC is the MVC pattern where data (“model”), the logic (“controller”), and what the end-user sees (“view”) divided into three different sections and each part is handled independently. Saving of data to a database has nothing to do with rendering the data on the web." (3)
LoD
Law of DemeterEach unit should have only limited knowledge about other units: only units “closely” related to the current unit.
Each unit should only talk to its friends; don’t talk to strangers.
Only talk to your immediate friends.
"The fundamental notion is that a given object should assume as little as possible about the structure or properties of anything else (including its subcomponents), in accordance with the principle of "information hiding". It may be viewed as a corollary to the principle of least privilege, which dictates that a module possess only the information and resources necessary for its legitimate purpose." (4)
POLA
Principle Of Least Astonishment"a component of a system should behave in a way that most users will expect it to behave, and therefore not astonish or surprise users. The following is a corollary of the principle: If a necessary feature has a high astonishment factor, it may be necessary to redesign the feature." (5)
Facade Pattern
"a facade is an object that serves as a front-facing interface masking more complex underlying or structural code." (6)
Algorithms
Sorting
Recursion
Searching
Graph Algorithms
Tree Algorithms
Dynamic Programming
Big-O Analysis
Time and space efficiencyZero Data Apps
The Twelve Factor App
https://12factor.net/Refactoring
"Refactoring consists of improving the internal structure of an existing program’s source code, while preserving its external behavior." (1)
"Refactoring does “not” mean: rewriting code, fixing bugs, improving observable aspects of software such as its interface" (1)
Factoring is "organizing code into useful fragments" (2)
Optimization
Premature optimization is the root of all evil in programming.
Donald KnuthBibliography & References
Refactoringhttps://stackoverflow.com/questions/20624340/what-is-refactoring(1) https://www.agilealliance.org/glossary/refactoring/(2) http://thinking-forth.sourceforge.net/
Using Databaseshttps://hackaday.com/2021/06/08/linux-fu-databases-are-next-level-file-systems/
SmartDB/PinkDBhttp://stevenfeuersteinonplsql.blogspot.com/2018/05/the-smartdb-resource-center.htmlhttps://www.salvis.com/blog/2018/07/18/the-pink-database-paradigm-pinkdb/https://rob.conery.io/2015/02/21/its-time-to-get-over-that-stored-procedure-aversion-you-have/https://blog.ora-600.pl/2020/01/09/the-curious-case-of-enq-tx-row-lock-contention/
The 12 Factor Apphttps://12factor.net/
Zero Data Appshttps://0data.app/
Lazy Development (The functional style of programming)https://blogs.oracle.com/javamagazine/post/java-lazy-functional-development
Commentshttps://blogs.oracle.com/javamagazine/post/java-comments-reduce-technical-debt
Test-Driven Development (TDD)https://blogs.oracle.com/javamagazine/post/refactoring-java-part-1-driving-agile-development-with-test-driven-developmenthttps://www.infoq.com/articles/test-driven-design-java/https://www.oracle.com/technical-resources/articles/adf/essentials-part5.html (JUnit)https://blogs.oracle.com/vbcs/post/simplified-test-driven-development-with-oracle-visual-builderhttps://hackernoon.com/introduction-to-test-driven-development-tdd-61a13bc92d92
Law of Demeter (LoD)(4) https://en.wikipedia.org/wiki/Law_of_Demeter
POLA(5) https://en.wikipedia.org/wiki/Principle_of_least_astonishment
Facade pattern(6) https://en.wikipedia.org/wiki/Facade_pattern
SOLIDhttps://www.geeksforgeeks.org/solid-principle-in-programming-understand-with-real-life-examples/
Single-Responsibility Principlehttps://blogs.oracle.com/java/post/core-design-principleshttps://en.wikipedia.org/wiki/Single-responsibility_principlehttps://sites.google.com/site/unclebobconsultingllc/getting-a-solid-start
Cautionary taleshttps://specbranch.com/posts/knight-capital/
Estimatinghttps://betterprogramming.pub/coding-fast-and-slow-developers-and-the-psychology-of-overconfidence-433388e7aec0