I made organizing Stored Procedures into Chapters and Steps a principle.
These separation points are marked by comments and variables used in performance and result logging.
A step is one specific technical or conceptual task that cannot be divided into further pieces without
leaving the abstraction of Stored Procedures or the task at hand. It could create an intermediate table, deletion of records, a calculation, or a logging step.
A chapter is a group of steps contributing to achieving one intermediate of the final result.
I assign steps a number and let them increase in increments greater than one.
The first digit of the step is the Chapter number to make it immediately apparent where the step stems from.
Why do I engage in what you might think is nothing but embellishment?
If only some of the following arguments seem convincing, you should seriously consider chapters and steps in the Stored Procedure code from now on:
1. Reflection of worthiness:
2. Means of self-discipline
This can be of great use in bustling workplaces where you cannot reserve long hours of cloistered coding.
3. Facilitation of documentation
Leave out the purely technical steps, and you have good points of departure for user manuals.
4. Unit of testing and debugging
5. Predefined elements of performance measurement
Make a difference by demonstrating to others how one element of standardization can look like.
Note that with mere tags in steps and chapters, individuality and freedom of thought are preserved!
7. Facilitation of communication
8. Evolutionary Advantage
If that organism is made up of well-defined units that can be turned on or off, modified, or reused elsewhere, this is an advantage over fuzzy structures that lack any internal organization.
9. Data Flow control
for semantic tests after the SP has passed the earlier tests. This is especially valuable if the outcome looks correct but went
through the SP in unexpected twists and sidewalks.
10. Leaving a good legacy
be able to depart from where I finished much easier if they find code that is already organized and named. Organized code is a business card
you leave at the virtual desk.