Nested loops can slow down innovation

[nz_btn text="Innovation" link="http://casthighlight.wpengine.com/category/product/indicators-methodology/innovation/" icon="icon-office" color="orange" shape="rounded" hover_normal="opacity"][nz_btn text="Software Elegance" link="http://casthighlight.wpengine.com/category/product/indicators-methodology/software-elegance" icon="icon-dashboard" color="black" size="medium" shape="rounded"][nz_btn text="Code Complexity" link="http://casthighlight.wpengine.com/category/product/indicators-methodology/software-elegance/code-complexity/" icon="icon-code" color="black" shape="rounded" type="ghost" hover_ghost="screen"]

Nested loops can slow down innovation

This code insight detects loops within a loop (for, do, while, foreach, etc.). Depending on thresholds observed in the benchmark of thousands of applications and billions lines of code, Highlight accounts penalty points to the given scanned files.

Why you should care

For code readability and performance, nested loops are frequently considered as a bad practice. In many cases, there's a much faster and less wasteful way to accomplish the goal you're trying to achieve.

Business Impacts

Complex code can slow down innovation
[nz_btn text="Innovation" link="http://casthighlight.wpengine.com/category/product/indicators-methodology/innovation/" icon="icon-office" color="orange" shape="rounded" hover_normal="opacity"]

CAST recommendations

Consider refactoring your code by avoiding the use of nested loops.

References

https://softwareengineering.stackexchange.com/questions/199196/why-are-nested-loops-considered-bad-practice

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.
[nz_btn text="See features" link="http://casthighlight.wpengine.com/outputs-analytics/" icon="icon-stats" color="black" shape="rounded"][nz_btn text="How it works" link="http://casthighlight.wpengine.com/how-it-works/" icon="icon-cog" color="black" shape="rounded" type="ghost"]
For reference only. For the complete details please refer the original article
https://doc.casthighlight.com/alt_nestedloop-avoid-nested-loop-php/
Have more questions? Submit a request

Comments

Powered by Zendesk