# US 2021/0081182 A1 · Identifying and recommending code snippets to be reused by software developer

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0081182 A1
- Document ID: US20210081182A1
- Status: Published application
- Kind: A1
- Application number: 16/573,911
- Filed: 2019-09-17
- Published: 2021-03-18
- Earliest claimed: 2019-09-17
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Padmanabha Venkatagiri Seshadri; Vijay Kumar Ananthapur Bache; Bidhu Ranjan Sahoo; Vijay Ekambaram
- Web page: https://patentgrep.com/patent/US20210081182A1

## CPC

- G06F 8/36: Software reuse
- G06F 8/71: Version control (security arrangements therefor G06F21/57); Configuration management
- G06F 8/73: Program documentation
- G06F 11/302: {where the computing system component is a software system}
- G06F 8/72: Code refactoring
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A computer-implemented method, system and computer program product for identifying and recommending code snippets to be reused by a software developer. Multiple sources (e.g., social media messages) are monitored for source code development difficulties. In response to detecting a source code development difficulty, the source code which is the source of the detected source code development difficulty is labeled with a struggle tag, which may indicate a category of the source code. Furthermore, source code snippets from various sources (e.g., source code snippets publicly available on the Internet) are mined, identified and labeled with tags, which may indicate a category of the source code snippet. Relevant source code snippets are identified to address the software developer's struggles based on matching one or more of these tags with the struggle tag, which are later ranked as to which are the best to address the software developer's struggles in writing source code.

## Claims

### Claim 1

A computer-implemented method for identifying and recommending code snippets to be reused by a software developer, the method comprising:
monitoring sources for source code development difficulties experienced by said software developer;
detecting a source code development difficulty from said monitored sources for source code development difficulties;
labeling source code which is a source of said detected source code development difficulty with a struggle tag indicating a category of source code;
storing said struggle tag in a repository;
mining and identifying source code snippets from software-related documents, source code repositories, and source code snippets publicly available on the Internet;
labeling said identified source code snippets with tags that indicate a category of source code;
storing said tags in said repository;
identifying relevant source code snippets to address software developer's struggles based on matching one or more tags of said stored tags with said struggle tag;
ranking said identified relevant source code snippets to be reused by said software developer in terms of assisting said software developer; and
notifying said software developer of said ranked relevant source code snippets by providing a list of said ranked relevant source code snippets.

### Claim 2 (depends on 1)

The method as recited in claim 1 further comprising:
labeling a source of said detected source code development difficulty with a second tag indicating a finding of a source code development difficulty to assist in identifying future source code development difficulties.

### Claim 3 (depends on 1)

The method as recited in claim 1 further comprising:
generating a struggle score indicating a degree said software developer struggled in writing source code; and
annotating said labeled source code with said struggle score.

### Claim 4 (depends on 3)

The method as recited in claim 3 further comprising;
ranking annotated source code snippets with struggle scores.

### Claim 5 (depends on 1)

The method as recited in claim 1, wherein said matching comprises an agreement of said category associated with said struggle tag within a threshold degree of semantic meaning of a category associated with said one or more tags of said identified relevant source code snippets.

### Claim 6 (depends on 1)

The method as recited in claim 1 further comprising:
refactoring relevant source code snippets identified from said list of said ranked relevant source code snippets desired to be used by said software developer.

### Claim 7 (depends on 1)

The method as recited in claim 1 further comprising:
identifying said source code associated with said detected source code development difficulty from said monitored sources via dependency analysis of source code and work item artifacts.

### Claim 8

A computer program product for identifying and recommending code snippets to be reused by a software developer, the computer program product comprising a computer readable storage medium having program code embodied therewith, the program code comprising the programming instructions for:
monitoring sources for source code development difficulties experienced by said software developer;
detecting a source code development difficulty from said monitored sources for source code development difficulties;
labeling source code which is a source of said detected source code development difficulty with a struggle tag indicating a category of source code;
storing said struggle tag in a repository;
mining and identifying source code snippets from software-related documents, source code repositories, and source code snippets publicly available on the Internet;
labeling said identified source code snippets with tags that indicate a category of source code;
storing said tags in said repository;
identifying relevant source code snippets to address software developer's struggles based on matching one or more tags of said stored tags with said struggle tag;
ranking said identified relevant source code snippets to be reused by said software developer in terms of assisting said software developer; and
notifying said software developer of said ranked relevant source code snippets by providing a list of said ranked relevant source code snippets.

### Claim 9 (depends on 8)

The computer program product as recited in claim 8, wherein the program code further comprises the programming instructions for:
labeling a source of said detected source code development difficulty with a second tag indicating a finding of a source code development difficulty to assist in identifying future source code development difficulties.

### Claim 10 (depends on 8)

The computer program product as recited in claim 8, wherein the program code further comprises the programming instructions for:
generating a struggle score indicating a degree said software developer struggled in writing source code; and
annotating said labeled source code with said struggle score.

### Claim 11 (depends on 10)

The computer program product as recited in claim 10, wherein the program code further comprises the programming instructions for:
ranking annotated source code snippets with struggle scores.

### Claim 12 (depends on 8)

The computer program product as recited in claim 8, wherein said matching comprises an agreement of said category associated with said struggle tag within a threshold degree of semantic meaning of a category associated with said one or more tags of said identified relevant source code snippets.

### Claim 13 (depends on 8)

The computer program product as recited in claim 8, wherein the program code further comprises the programming instructions for:
refactoring relevant source code snippets identified from said list of said ranked relevant source code snippets desired to be used by said software developer.

### Claim 14 (depends on 8)

The computer program product as recited in claim 8, wherein the program code further comprises the programming instructions for:
identifying said source code associated with said detected source code development difficulty from said monitored sources via dependency analysis of source code and work item artifacts.

### Claim 15

A system, comprising:
a memory for storing a computer program for identifying and recommending code snippets to be reused by a software developer; and
a processor connected to said memory, wherein said processor is configured to execute the program instructions of the computer program comprising:
monitoring sources for source code development difficulties experienced by said software developer;
detecting a source code development difficulty from said monitored sources for source code development difficulties;
labeling source code which is a source of said detected source code development difficulty with a struggle tag indicating a category of source code;
storing said struggle tag in a repository;
mining and identifying source code snippets from software-related documents, source code repositories, and source code snippets publicly available on the Internet;
labeling said identified source code snippets with tags that indicate a category of source code;
storing said tags in said repository;
identifying relevant source code snippets to address software developer's struggles based on matching one or more tags of said stored tags with said struggle tag;
ranking said identified relevant source code snippets to be reused by said software developer in terms of assisting said software developer; and
notifying said software developer of said ranked relevant source code snippets by providing a list of said ranked relevant source code snippets.

### Claim 16 (depends on 15)

The system as recited in claim 15, wherein the program instructions of the computer program further comprise:
labeling a source of said detected source code development difficulty with a second tag indicating a finding of a source code development difficulty to assist in identifying future source code development difficulties.

### Claim 17 (depends on 15)

The system as recited in claim 15, wherein the program instructions of the computer program further comprise:
generating a struggle score indicating a degree said software developer struggled in writing source code; and
annotating said labeled source code with said struggle score.

### Claim 18 (depends on 17)

The system as recited in claim 17, wherein the program instructions of the computer program further comprise:
ranking annotated source code snippets with struggle scores.

### Claim 19 (depends on 15)

The system as recited in claim 15, wherein said matching comprises an agreement of said category associated with said struggle tag within a threshold degree of semantic meaning of a category associated with said one or more tags of said identified relevant source code snippets.

### Claim 20 (depends on 15)

The system as recited in claim 15, wherein the program instructions of the computer program further comprise:
refactoring relevant source code snippets identified from said list of said ranked relevant source code snippets desired to be used by said software developer.
