Detection of antipatterns through statistical analysis
First Claim
Patent Images
1. A computer implemented method of generating code free from antipatterns, comprising:
- receiving a code containing at least one of a plurality of code segments, each one of said at least one code segment includes at least one pattern;
automatically analyzing each one of said at least one code segment to identify a plurality of predefined features of said at least one pattern, each of said plurality of predefined features describing one of a plurality of pattern properties;
creating at least one array comprising a plurality of features vectors,each one of said at least one array is associated with one of said at least one code segment,each one of said plurality of features vectors is associated with one of said at least one pattern included in a respective one of said at least one code segment and comprises said plurality of predefined features identified in said respective one of said at least one pattern; and
generating a new code from said code, by;
matching each one of said plurality of features vectors of each of said at least one pattern included in said each of said at least one code segment, with a plurality of template features vectors each representing one of a plurality of antipatterns, said plurality of template features vectors is stored in an antipatterns dataset,determining a presence or an absence of each of said plurality of antipatterns within said each at least one code segment according to said matching,identifying at least one approved pattern, which is not an antipattern, to replace at least one of said plurality of antipatterns detected in said code segment, said at least one approved pattern exhibits a similar functional behavior as said at least one antipattern, andautomatically replacing said at least one detected antipattern by said at least one identified approved pattern;
wherein each of said plurality of pattern properties is a member in a group consisting of;
number of fields involved in said pattern, type of fields involved in said pattern, number of methods said pattern spans, number of Abstract Syntax Tree (AST) nodes involved in said pattern, type of AST nodes involved in said pattern, frameworks involved in said pattern, designated scope of said pattern, reachability from an enclosing scope of said pattern, global variables use, variable initialization states and escaped variables.
1 Assignment
0 Petitions
Accused Products
Abstract
A computer implemented method of detecting code antipatterns, comprising:
- 1) Receiving a code containing one or more of a plurality of code segments, each one of the one or more code segments includes one or more of a plurality of patterns.
- 2) Automatically analyzing each one of the one or more code segment to create an array of a plurality of features vectors, each one of the plurality of features vectors maps a plurality of predefined features found in one or more patterns.
- 3) Matching each one of the plurality of features vectors with a plurality of template features vectors each representing one of a plurality of antipatterns, the plurality of template features vectors is stored in an antipatterns dataset.
- 4) Determining a presence or an absence of each of the plurality of antipatterns within each of the one or more code segments according to the matching.
-
Citations
22 Claims
-
1. A computer implemented method of generating code free from antipatterns, comprising:
-
receiving a code containing at least one of a plurality of code segments, each one of said at least one code segment includes at least one pattern; automatically analyzing each one of said at least one code segment to identify a plurality of predefined features of said at least one pattern, each of said plurality of predefined features describing one of a plurality of pattern properties; creating at least one array comprising a plurality of features vectors, each one of said at least one array is associated with one of said at least one code segment, each one of said plurality of features vectors is associated with one of said at least one pattern included in a respective one of said at least one code segment and comprises said plurality of predefined features identified in said respective one of said at least one pattern; and generating a new code from said code, by; matching each one of said plurality of features vectors of each of said at least one pattern included in said each of said at least one code segment, with a plurality of template features vectors each representing one of a plurality of antipatterns, said plurality of template features vectors is stored in an antipatterns dataset, determining a presence or an absence of each of said plurality of antipatterns within said each at least one code segment according to said matching, identifying at least one approved pattern, which is not an antipattern, to replace at least one of said plurality of antipatterns detected in said code segment, said at least one approved pattern exhibits a similar functional behavior as said at least one antipattern, and automatically replacing said at least one detected antipattern by said at least one identified approved pattern; wherein each of said plurality of pattern properties is a member in a group consisting of;
number of fields involved in said pattern, type of fields involved in said pattern, number of methods said pattern spans, number of Abstract Syntax Tree (AST) nodes involved in said pattern, type of AST nodes involved in said pattern, frameworks involved in said pattern, designated scope of said pattern, reachability from an enclosing scope of said pattern, global variables use, variable initialization states and escaped variables. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9)
-
-
10. A system for generating code free from antipatterns, comprising:
-
an interface for communicating with a user; a program store storing a code; and a processor coupled to the first interface and the program store for implementing the stored code, the code comprising; code instructions for receiving a code having a plurality of code segments, each one of said plurality of code segments includes at least one pattern, said code is received according to a user input received via said interface; code instructions for automatically analyzing each one of said plurality of code segments to identify a plurality of predefined features of said at least one pattern, each of said plurality of predefined features describing one of a plurality of pattern properties; code instructions for creating at least one array consisting of a plurality of features vectors, each one of said at least one array is associated with one of said plurality of code segments, each one of said plurality of features vectors is associated with one of said at least one pattern included in a respective one of said plurality of code segments and comprises said plurality of predefined features identified in said respective one of said at least one pattern; and code instructions for generating a new code from said code, by; comparing each one of said plurality of features vectors of each of said at least one pattern included in said each of said at least one code segment, with a plurality of template features vectors each representing one of a plurality of antipatterns, said plurality of template features vectors is stored in an antipatterns dataset, determining a presence or an absence of at least one of said plurality of antipatterns within said each code segments according to said compare, identifying at least one approved pattern, which is not an antipattern, to replace at least one of said plurality of antipatterns detected in said code segment, said at least one approved pattern exhibits a similar functional behavior as said at least one antipattern, and automatically replacing said at least one detected antipattern by said at least one identified approved pattern; wherein each of said plurality of pattern properties is a member in a group consisting of;
number of fields involved in said pattern, type of fields involved in said pattern, number of methods said pattern spans, number of Abstract Syntax Tree (AST) nodes involved in said pattern, type of AST nodes involved in said pattern, frameworks involved in said pattern, designated scope of said pattern, reachability from an enclosing scope of said pattern, global variables use, variable initialization states and escaped variables. - View Dependent Claims (11, 12, 13, 14, 15)
-
-
16. A computer program product for degenerating code free from antipatterns, comprising:
-
a non-transitory computer readable storage medium; first program instructions to receive a code that includes at least one of a plurality of code segments, each one of said at least one code segments includes at least one pattern; second program instructions to analyze each one of said plurality of code segments to identify a plurality of predefined features of said at least one pattern; third program instructions to create at least one array consisting of a plurality of features vectors, each one of said at least one array is associated with one of said plurality of code segments, each one of said plurality of features vectors is associated with one of said at least one pattern included in a respective one of said plurality of code segments and comprises said plurality of predefined features identified in said respective one of said at least one pattern; and fourth program instructions to generate a new code from said code, by; matching each one of said plurality of features vectors of each of said at least one pattern included in said each of said plurality of code segments, with a plurality of template features vectors each representing one of a plurality of antipatterns, said plurality of template features vectors is stored in an antipatterns dataset, determining a presence or an absence of each of said plurality of antipatterns within said each at least one code segments according to said match, calculating at least one approved pattern, which is not an antipattern, to replace at least one of said plurality of antipatterns detected in said code segment, said at least one approved pattern exhibits a similar functional behavior as said at least one antipattern, and automatically replace said at least one detected antipattern by said at least one calculated approved pattern; wherein said first, second, third and fourth program instructions are stored on said non-transitory computer readable storage medium; wherein each of said plurality of pattern properties is a member in a group consisting of;
number of fields involved in said pattern, type of fields involved in said pattern, number of methods said pattern spans, number of Abstract Syntax Tree (AST) nodes involved in said pattern, type of AST nodes involved in said pattern, frameworks involved in said pattern, designated scope of said pattern, reachability from an enclosing scope of said pattern, global variables use, variable initialization states and escaped variables. - View Dependent Claims (17, 18, 19, 20, 21, 22)
-
Specification