Browse Prior Art Database

A method of extracted copied code segments to improve code reuse

IP.com Disclosure Number: IPCOM000229958D
Publication Date: 2013-Aug-09
Document File: 3 page(s) / 83K

Publishing Venue

The IP.com Prior Art Database

Abstract

A method is disclosed that marks and extracts code which gets pasted into documents and other piece s of software. Extract code can be stored abstractly and then be pasted in multiple places whilst storing one copy allowing for reusable code that can be adapted to the location it is inserted into.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 51% of the total text.

Page 01 of 3

A method of extracted copied code segments to improve code reuse

There are many occasions when writing code, where code needs to be reused in

several locations and more importantly where this repeated code needs to change for all instances. An example of this is when writing tests and you need to repeat some setup code or change how a GUI test reactions after clicking on a button. A few ways to solve this problem are highlighted below:
Manually editing the code

    The user can simply edit all instances of all applicable codes. This is most labour intensive and the user may miss some places where this is used. Search/Replace

    The user can use IDE functionality to search for occurrences of the code that needs to be changed then automatically replace it. This may not find all instances of the code, depending on the scope of the search and may not be very effective

when performing changing over multiple lines, or if the search criteria picks up entries that shouldn't be edited.

Code Reuse

    This is the best solution for the problem where the code is only actually used in one place but this may not always be applicable due to the structure of the code, for example, class visibility or the code is in two different projects.

    A smarter solution is required that is able to all users to reuse code in a project but still control its structure regardless of how complicated the project becomes. The method disclosed works by marking when code gets pasted into documents and storing the original version in a separate code store. Code changes are tracked and when code changes in one location it will be updated in all locations.

The method deal with the following aspects:


Marking copied code segments as linkable


Determining paste logic for inserting code segments


Extracting variable names from code segments


Accounting for code compilation issues in code segments


Determining whether a code change should be added to a linked code segment.

This will allow the user to use identical code segments throughout their code

without worrying that some segments may get out of date, ensuring they stay consistent and when one piece of code gets updated, the user will not have to change it anywhere else. This is useful in many areas but can include GUI testing,

where test code is split over multiple projects yet they may wish to reuse the same

sleep logic. In these sort of scenarios a refactor may be an option, but in order to ensure a stable test code stream, such a rewrite would not be unfeasible. Another good benefit is that code changes are tracked via files, not the projects that they are used in so that code used in two different projects can also benefit from changes many in one code segment.

    Every time the user copies code, the system will mark the copied code as potentially linkable. Every time the user pastes the code, the system will increment the paste co...