Smells like code duplication – spotting violations of the DRY principle

Table of Contents

Reading time: 5 min

Audience: ServiceNow platform owners, software engineers

Is your ServiceNow instance DRY…?

Adherence to the Don’t Repeat Yourself (DRY) principle is one of the key requirements for building a robust software system. This principle was formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer. They define it in the following way:

“Every piece of knowledge must have a single, unambiguous, authoritative representation within a system”.

While the context for which “The Pragmatic Programmer” was written is that of traditional software development of multi-tiered applications, it certainly also applies to low-code development platforms such as ServiceNow®. Indeed, the argument could be made that since ServiceNow® and other low code development platforms require less code to be written to implement any given functionality, introducing code duplication in these platforms should be considered a more severe violation of best practices than in “traditional” software development environments.

… or WET?

However one may feel about this conceptually, the fact remains that no one likes fixing the same bug twice, or even worse, releasing a fix for a bug into production only to have it show up again because a piece of duplicated code had not been identified and corrected. In fact, the opposite of a DRY system is often referred to as a WET one, with this acronym taking on the somewhat humorous meanings of:

“write everything twice”

“we enjoy typing”


“waste everyone’s time”

So whatever your role in a ServiceNow® SaaS platform may be that of a manager, an architect, or a developer, it is certainly in your best interest to keep your instance as DRY as possible.

Unfortunately, until now there were not many tools you could use to ensure that this was the case, other than manual code reviews, which are not an effective tool to detect code duplication anyway, unless the duplicated code is in the same Configuration Element.

Detecting code duplication with Quality Clouds for ServiceNow

With Quality Clouds for ServiceNow you now have a tool which can effectively assist you in identifying duplicated code. Specific code duplication indicators are in the development pipeline for this quarter, but you can already use the information generated by a Quality Clouds scan to identify duplicated code and duplicated code elements in your instance. From our experience working with various customers who are already taking advantage of this feature, the Service Catalog is an area where code duplication is seen often , as Catalog Client Scripts especially are repeatedly copied and pasted to be associated with slightly different Catalog Items. This is certainly an area where it pays to be especially vigilant before the amount of code duplication builds up.

There are two main ways to detect possible code duplication with Quality Clouds for ServiceNow. They both involve analyzing the list of detected issues, as follows:

Look for duplicated Configuration Elements – These are likely to hold duplicate code:


  1. Once on your Quality Clouds for ServiceNow platform, navigate to the Team overview dashboard.
  2. Scroll down to the detailed issues table and export it to Excel.
  3. Use Excel’s conditional formatting feature to highlight Configuration Elements with the same name.
  4. Any rows with the same Configuration Element type are likely Configuration Elements that have been copied and pasted whole, keeping even their names.


Bingo! You’ve just sniffed out a code duplication. Follow the links to the exact code lines from our exported sheet to confirm and rewrite as required.

Look for repeating patterns of issues across different Configuration Elements – these are likely to be duplicated code blocks:


  1. Once on your Quality Clouds for ServiceNow platform, navigate to the Application overview dashboard.
  2. Scroll down to the detailed issues table and export it to Excel.
  3. Look for the same issue types being repeated on the same lines of code across Configuration Elements with different Sys Ids. These almost certainly identify blocks of code that have been copied and pasted across different Configuration Elements.


Well, there you have it. So now, do you know if your instance is DRY or WET?

Set up a demo of Quality Clouds for ServiceNow with us if you want to learn more.

Interested in what we do?
Find out how Quality Clouds can enhance your SaaS platforms' governance, compliance, and quality in real-time.
Quality Clouds
Quality Clouds was created to address a significant gap in the tech industry: the challenge developers face with Salesforce and ServiceNow deployments. Identifying the risks of working on unknown systems, our founders sought to empower developers with essential insights for quality and governance in SaaS projects.

Want to learn more? Let's talk: