IP Library › Granted Patent US 11,662,998
Granted Patent B2
US 11,662,998 · App. 17/350,362 · Granted May 30, 2023

Detecting duplicated code patterns in visual programming language code instances

Inventors: Miguel Ângelo Da Terra Neves (Lisbon, PT); António Manuel de Carvalho dos Santos Alegria (Lisbon, PT); João Pedro Nunes Nadkarni (Faro, PT); Pedro Tomás Mendes Resende (Lisbon, PT); Miguel Monteiro Ventura (Cascais, PT)
G06F8/75G06F8/34G06F8/423G06F8/433G06F8/72G06F16/319G06F40/284
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,662,998
App. No.
17/350,362
Granted
May 30, 2023
Kind
B2
Abstract

In various embodiments, a process for detecting duplicated code patterns in visual programming language code instances includes analyzing a repository of graph based visual programming language code instances and detecting a similar code portion pattern duplicated among a group of graph based visual programming language code instances included in the repository of graph based visual programming language code instances including by using an index and tokenizing a flow corresponding to at least one graph based visual programming language code instance in the group of graph based visual programming language code instance. The process includes visually indicating elements belonging to the detected similar code portion pattern within a visual representation of at least one of the group of graph based visual programming language code instances.

Claims (58)

1. A method, comprising:

analyzing a repository of graph based visual programming language code instances;

detecting a similar code portion pattern duplicated among a group of graph based visual programming language code instances included in the repository of graph based visual programming language code instances including by:

using an index and tokenizing a flow corresponding to at least one graph based visual programming language code instance in the group of graph based visual programming language code instances;

determining that at least one candidate flow pair exists;

in response to determining that the at least one candidate flow pair exists, obtaining an identified candidate flow pair;

extracting a duplicated code pattern for the identified candidate flow pair; and

replacing the identified candidate flow pair with the extracted duplicated code pattern; and

within a visual representation of at least one of the group of graph based visual programming language code instances, visually indicating elements belonging to the detected similar code portion pattern.

2. The method of claim 1 , wherein replacing the identified candidate flow pair with the extracted duplicated code pattern is based at least in part on a refactor weight associated with the extracted duplicated code pattern meeting a threshold.

3. The method of claim 1 , wherein determining that the at least one candidate flow pair exists includes evaluating a set of candidate flow pairs in which a previous identified candidate flow pair is replaced with the extracted duplicated code pattern.

4. The method of claim 1 , wherein detecting the similar code portion pattern duplicated among the group of graph based visual programming language code instances includes:

in response to determining that the at least one candidate flow pair does not exist, outputting duplicated code patterns.

5. The method of claim 1 , wherein extracting the duplicated code pattern for the identified candidate flow pair includes:

mapping at least one node of a first flow in the identified candidate flow pair into at least one node of a second flow in the identified candidate flow pair; and

extracting a single maximal duplicated code pattern based at least in part on the mapping.

6. The method of claim 5 , wherein the mapping is based at least in part on at least one of: inclusion variables, mapping variables, or control-flow variables.

7. The method of claim 1 , wherein detecting the similar code portion pattern duplicated among the group of graph based visual programming language code instances includes de-duplicating flows within a set of flows prior to determining that the at least one candidate flow pair exists.

8. The method of claim 7 , wherein de-duplicating the flows within the set of flows includes identifying isomorphic patterns including by at least one of:

using a group hash; or

sorting combined label concatenation including by:

computing a key for a flow, wherein the key includes a sorted concatenation of combined labels of edges in the flow;

determining that there exists an isomorphic flow within a set of flows among those with a same key; and

extracting an isomorphic pattern in response to determining that there exists a flow within the set of flows among those with a same key.

9. The method of claim 1 , further comprising, after obtaining the identified candidate flow pair, applying at least one pre-processing rule to reduce a size of the group of graph based visual programming language code instances.

10. The method of claim 1 , wherein the index includes an inverted index and further comprising:

tokenizing at least one flow including by combining edge labels, wherein the combined edge labels include a concatenation of a node label of a first node, an edge label of an edge, and a node label of a second node combining the first node and the second node; and

building the inverted index for a set of flows using the tokenized at least one flow.

11. The method of claim 10 , wherein only pairs of graphs in the repository of graph based visual programming language code instances that occur in a same index list associated with the inverted index are used during initialization of a queue and adding a new pattern to the inverted index prior to updating the queue.

12. The method of claim 1 , further comprising:

obtaining a tree hierarchy of similar code portion patterns including the detected similar code portion pattern.

13. The method of claim 12 , further comprising:

determining refactoring steps based at least in part on the tree hierarchy of the similar code portion patterns.

14. The method of claim 1 , wherein visually indicating elements belonging to the detected similar code portion pattern includes displaying the detected similar code portion pattern within an architecture dashboard.

15. The method of claim 1 , wherein visually indicating elements belonging to the detected similar code portion pattern includes displaying the detected similar code portion pattern within a ranked list of patterns.

16. The method of claim 15 , wherein the ranked list of patterns is ordered by recommended refactoring order.

17. The method of claim 1 , further comprising outputting guidance for refactoring code based at least in part on the detected similar code portion pattern.

18. A system, comprising:

a processor configured to:

analyze a repository of graph based visual programming language code instances;

detect a similar code portion pattern duplicated among a group of graph based visual programming language code instances included in the repository of graph based visual programming language code instances including by being configured to:

use an index and tokenizing a flow corresponding to at least one graph based visual programming language code instance in the group of graph based visual programming language code instances;

determine that at least one candidate flow pair exists;

in response to determining that the at least one candidate flow pair exists, obtain an identified candidate flow pair;

extract a duplicated code pattern for the identified candidate flow pair; and

replace the identified candidate flow pair with the extracted duplicated code pattern; and

within a visual representation of at least one of the group of graph based visual programming language code instances, visually indicate elements belonging to the detected similar code portion pattern; and

a memory coupled to the processor and configured to provide the processor with instructions.

19. The system of claim 18 , wherein the replacement of the identified candidate flow pair with the extracted duplicated code pattern is based at least in part on a refactor weight associated with the extracted duplicated code pattern meeting a threshold.

20. A computer program product embodied in a non-transitory computer readable medium and comprising computer instructions for:

analyzing a repository of graph based visual programming language code instances;

detecting a similar code portion pattern duplicated among a group of graph based visual programming language code instances included in the repository of graph based visual programming language code instances including by:

using an index and tokenizing a flow corresponding to at least one graph based visual programming language code instance in the group of graph based visual programming language code instances;

determining that at least one candidate flow pair exists;

in response to determining that the at least one candidate flow pair exists, obtaining an identified candidate flow pair;

extracting a duplicated code pattern for the identified candidate flow pair; and

replacing the identified candidate flow pair with the extracted duplicated code pattern; and

within a visual representation of at least one of the group of graph based visual programming language code instances, visually indicating elements belonging to the detected similar code portion pattern.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 30, 2021
From: NEVES, MIGUEL ÂNGELO DA TERRA; ALEGRIA, ANTÓNIO MANUEL DE CARVALHO DOS SANTOS; NADKARNI, JOÃO PEDRO NUNES; RESENDE, PEDRO TOMÁS MENDES; VENTURA, MIGUEL MONTEIRO
To: OUTSYSTEMS - SOFTWARE EM REDE, S.A.
Reel/Frame 057330/0664 →
Continuity (4)
Provisional Application 63117899 · Nov 24, 2020
Provisional Application 63117895 · Nov 24, 2020
Provisional Application 63110330 · Nov 5, 2020
Related Publication 20220137959A1 · May 5, 2022
Cited By (1)
US 12,585,576