![]() |
C.3 Coding Insights |
Coding Insights empowers developers to write higher-quality code by providing real-time guidance during compilation. This feature reinforces best practices and encourages efficient coding habits, making development smoother and more productive.
SheerPower’s option insights
enables the compiler to collect
detailed metrics during compilation, generating a comprehensive
Coding Insights Report. By analyzing code complexity and
structure, this tool helps developers create code that is easier to
develop, test, and maintain—enhancing both efficiency and reliability.
To enable insights, simply add this to the top of your program:
SheerPower tracks various metrics during compilation and automatically generates a detailed insights report at the end of the process.
The insights report provides the following key details:
The report assigns a Complexity Level score to each routine:
(Show/Hide Understanding Complexity Level)
Complexity Level (CL) is a way to measure how complicated
a routine (or function) is. It counts the number of decision points
in the code—such as if
and else
statements.
The more decisions your code makes, the more complex it becomes. A higher complexity score usually means the code is harder to read, test, and maintain.
Every routine starts with a complexity of 0. Then:
if
and else
, etc. adds to the score.Example:
This routine has CL = 2 (+1 for the if
statement).
If a routine’s Complexity Level is high (21+ or more), the code is getting difficult to read, test, and maintain.
local routines
Move parts of the logic into separate local routines. Each routine should focus on one task only.
Instead of many nested if
statements, use
early exits (guard
statements). This makes the code
flatter and easier to follow.
case
Instead of Multiple if
StatementsBefore:
After (Simplified with case
):
The CL is now lower! The code is easier to follow.
If logic isn’t needed, remove it! If an if
statement always leads to return
, rewrite it
more cleanly.
if
,
else
, etc.).select case
, and keeping logic simple.The report assigns a Lines of Code (Adjusted) status to each routine:
The report assigns a Literals Usage status to each routine:
To make the most of option insights
, consider the
following best practices:
SheerPower's option insights
provides
a valuable way to assess and optimize code complexity.
By reviewing the generated report and applying best
practices, developers can maintain clean, efficient,
and scalable SheerPower applications.
Hide Description
|
|
Enter or modify the code below, and then click on RUN |
Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use. |