×

Detection of antipatterns through statistical analysis

  • US 10,055,329 B2
  • Filed: 09/30/2015
  • Issued: 08/21/2018
  • Est. Priority Date: 09/30/2015
  • Status: Active Grant
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.

View all claims
  • 1 Assignment
Timeline View
Assignment View
    ×
    ×