CN108446115A - A kind of method and device of code reuse - Google Patents

A kind of method and device of code reuse Download PDF

Info

Publication number
CN108446115A
CN108446115A CN201810200727.2A CN201810200727A CN108446115A CN 108446115 A CN108446115 A CN 108446115A CN 201810200727 A CN201810200727 A CN 201810200727A CN 108446115 A CN108446115 A CN 108446115A
Authority
CN
China
Prior art keywords
code
code reuse
module
reuse
order
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810200727.2A
Other languages
Chinese (zh)
Inventor
陈志鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN201810200727.2A priority Critical patent/CN108446115A/en
Publication of CN108446115A publication Critical patent/CN108446115A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring

Abstract

The present invention provides a kind of method and device of code reuse, after receiving code reuse order, from acquisition code reuse module corresponding with the marking code in the code reuse order in the code reuse library pre-established, and loads the code reuse module.Due to passing through input code multiplexing commands, it can find and need the code being multiplexed and load the code after being converted to code according to specified rule, since there is no the operation of manual replicating code, therefore the problem of holiday code leads to compile error in a replication process is avoided to generate, not only realize the promotion easy to operate and writing efficiency of code reuse, and code reuse is focused on into code reuse library, the concentration for realizing data, avoids being distributed in each program and is not easy management and retrieval.It realizes that code spice is unified in code reuse library, realizes and changed at one, many places use, and reduce maintenance cost.

Description

A kind of method and device of code reuse
Technical field
The invention belongs to field of computer technology more particularly to a kind of method and devices of code reuse.
Background technology
In program development process, it is often necessary to be multiplexed pervious code, to save a large amount of time and cost, so as to Program development work is completed in the shortest time.
Usually realize that the method for code reuse is that programming personnel searches the code that can be re-used, and can be re-used finding Code after, the code that can be re-used is obtained from program by way of copy, is then pasted in the program currently developed. But there may be multirow and dispersions for the code due to that can be re-used, and holiday generation is easy to happen in copy procedure The problem of code, generates.
It realizes that the method for code reuse is not only complicated for operation but also is easy to happen holiday code in the prior art, causes Compile error.Simultaneously because the means not being managed collectively, cause the code spice disunity of multiplexing, maintenance cost is big, unfavorable In centralized management.
Invention content
In view of this, the purpose of the present invention is to provide a kind of method and devices of code reuse, to solve the prior art It is middle to realize complicated for operation when code reuse and be easy to happen compile error and be unfavorable for asking for the code that centralized management be re-used Topic.
Technical solution is as follows:
The present invention provides a kind of method of code reuse, including:
After receiving code reuse order, obtained and the code reuse order from the code reuse library pre-established In the corresponding code reuse module of marking code;
Load the code reuse module.
Preferably, described from the code mark got in the code reuse library pre-established in being asked with the code reuse After knowing corresponding code reuse module, further include:
When the code reuse order received includes parameter information, the generation is changed according to the parameter information Custom parameter in code Multiplexing module;
The load code reuse module includes:
Load the modified code reuse module.
Preferably, described to include according to the parameter information modification code reuse mould custom parameter in the block:
Obtain custom parameter to be modified in the code reuse module;
The custom parameter to be modified is obtained in the code reuse mould position in the block;
The parameter information is replaced into the custom parameter at the position.
Preferably, multiple code reuse modules are stored in the code reuse library;
The code reuse module by the name of code for the code segment that can be re-used, the code segment being re-used from Defined parameters area and the code segment composition being re-used.
Preferably, described from acquisition in the code reuse library pre-established and the marking code in the code reuse order After corresponding code reuse module, further include:
Record obtains the number of code reuse module using the code reuse order;
According to the number for using the code reuse order to obtain code reuse module, the code reuse module is carried out Sequence;
According to the sequencing of sequence, the code reuse module of predetermined threshold value number is obtained;
The code reuse module of the predetermined threshold value number got is stored to buffer area, to receive code next time After multiplexing commands, first from acquisition code reuse module corresponding with the marking code in the code reuse order in buffer area.
The present invention also provides a kind of devices of code reuse, including:
First acquisition unit, for after receiving code reuse order, being obtained from the code reuse library pre-established Code reuse module corresponding with the marking code in the code reuse order;
Loading unit, for loading the code reuse module.
Preferably, further include:
Unit is changed, for when the code reuse order received includes parameter information, according to the parameter Information changes the code reuse mould custom parameter in the block;
The loading unit includes:
Load the modified code reuse module.
Preferably, the modification unit includes:
First obtains subelement, for obtaining custom parameter to be modified in the code reuse module;
Second obtains subelement, for obtaining the custom parameter to be modified in the code reuse mould position in the block It sets;
Subelement is replaced, for the parameter information to be replaced to the custom parameter at the position.
Preferably, multiple code reuse modules are stored in the code reuse library;
The code reuse module by the name of code for the code segment that can be re-used, the code segment being re-used from Defined parameters area and the code segment composition being re-used.
Preferably, further include:
Recording unit, for recording the number for obtaining code reuse module using the code reuse order;
Sequencing unit, for according to the number for using the code reuse order to obtain code reuse module, to the generation Code Multiplexing module is ranked up;
Second acquisition unit obtains the code reuse mould of predetermined threshold value number for the sequencing according to sequence Block;
The code reuse module of storage unit, the predetermined threshold value number for will get is stored to buffer area, under It is first corresponding with the marking code in the code reuse order from being obtained in buffer area after once receiving code reuse order Code reuse module.
Compared with prior art, above-mentioned technical proposal provided by the invention has the following advantages that:
It is multiple from the code pre-established from above-mentioned technical proposal it is found that in the application after receiving code reuse order With obtaining corresponding with the marking code in code reuse order code reuse module in library, and load the code reuse Module.Due to passing through input code multiplexing commands, so that it may need the code that is multiplexed to find and load the code, to realize The multiplexing of code, therefore do not need to user and artificially search the code that can be re-used, finding the code defensive position that can be re-used It is dynamic to replicate the code, and the multiplexing for needing the position for being multiplexed code that could realize code is pasted, not only realize code reuse Promotion easy to operate and writing efficiency, and since there is no the operation of manual replicating code, therefore avoid multiple The problem of holiday code leads to compile error during system generates.Code reuse is focused on into code reuse library simultaneously, it is real The concentration of existing data, avoids being distributed in each program and is not easy management and retrieval.Realize that code spice is unified in code reuse library, It realizes and is changed at one, many places use, and reduce maintenance cost.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is the present invention Some embodiments for those of ordinary skill in the art without creative efforts, can also basis These attached drawings obtain other attached drawings.
Fig. 1 is a kind of flow chart of the method for code reuse provided in an embodiment of the present invention;
Fig. 2 is the flow chart of the method for another code reuse provided in an embodiment of the present invention;
Fig. 3 is the flow chart of the method for another code reuse provided in an embodiment of the present invention;
Fig. 4 is a kind of structural schematic diagram of the device of code reuse provided in an embodiment of the present invention;
Fig. 5 is the structural schematic diagram of the device of another code reuse provided in an embodiment of the present invention.
Specific implementation mode
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art The every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
Present embodiment discloses a kind of method of code reuse, the method for the code reuse is applied to host platform, ginseng See Fig. 1, which includes the following steps:
S101, after receiving code reuse order, obtained from the code reuse library pre-established multiple with the code With the corresponding code reuse module of marking code in order;
User is during writing code, when multiplexing being needed to realize the code of a certain function, input code multiplexing commands; Wherein, the marking code for the code for needing to be multiplexed is included at least in code reuse order.For example, the code reuse order of input is " COBOL ", " COBOL " is marking code herein.
Code reuse module is stored in the code reuse library pre-established, i.e., by the code that can be re-used according to scheduled In the unified centrally stored library to code reuse of rule, realizes the centralized management of data, avoid each code being re-used point The problem of cloth leads to not manageability in different programs generates.
Wherein, code reuse module includes name of code;
For example, code reuse module is:
The beginning of lattice@one code reuse module of symbolic indication is pushed up, back to back character string is name of code COBOL.
After receiving code reuse order input by user, generation for being multiplexed according to the needs that code reuse order includes The marking code of code, from the code reuse module stored in code reuse library, search one by one after@symbols character string immediately with The identical code reuse module of marking code in code reuse order.Search the code reuse order of name of code and input In the identical code reuse module of marking code.
S102, the load code reuse module.
After getting code reuse module in code reuse library, by code reuse module according to specified rule to generation Code is loaded into after being converted at the position of user's input code multiplexing commands, is replaced using code reuse module input by user Code reuse order.
From above-mentioned technical proposal it is found that in the present embodiment after receiving code reuse order, from the code pre-established It is multiplexed in library and obtains code reuse module corresponding with the marking code in the code reuse order, and it is multiple to load the code Use module.Due to passing through input code multiplexing commands, so that it may with find need the code that is multiplexed and according to specified rule it is right Code loads the code after being converted, to realize the multiplexing of code, therefore do not need to user and artificially search and can be re-used Code, replicate the code manually after finding the code that can be re-used, and paste need be multiplexed code position It can realize the multiplexing of code, not only the promotion easy to operate and writing efficiency of realization code reuse, but also since there is no The operation of manual replicating code, therefore avoid the problem of holiday code leads to compile error in a replication process and generate. Code reuse is focused on into code reuse library simultaneously, the concentration of data is realized, avoids being distributed in each program not manageability and inspection Rope.It realizes that code spice is unified in code reuse library, realizes and changed at one, many places use, and reduce maintenance cost.
Present embodiment discloses the methods of another code reuse, and referring to Fig. 2, which includes the following steps:
S201, after receiving code reuse order, obtained from the code reuse library pre-established multiple with the code With the corresponding code reuse module of marking code in order;
Wherein, multiple code reuse modules are stored in the code reuse library;
The code reuse module by the name of code for the code segment that can be re-used, the code segment being re-used from Defined parameters area and the code segment composition being re-used.
When establishing code reuse library, this code segment that can be re-used first is arranged in the code segment that can be re-used for one section Name of code, wherein the function setting name of code that the code segment that can be re-used according to this can be realized, so realize Classification to the code segment that difference can be re-used, convenient for finding the code segment that can be re-used.
And by the character string of the name of code of setting after@this spcial character;For example,@COBOL;In@and There are a spaces between the character string of name of code.
Then the custom parameter for including further according to this code segment that can be re-used, setting custom parameter area, wherein Custom parameter is the parameter for allowing user to be changed according to actual demand personalization.For example,
For this code segment that can be re-used, it includes #DATE#, #PROG# and # to allow the parameter that user changes AUTHOR#.Therefore, the custom parameter area of setting is:
COMMAND-BEGIN
#DATE# AFTER 0 DATE
#PROG# AFTER 0 PROG
#AUTHOR# AFTER 0 AUTHOR
COMMAND-END
Wherein, custom parameter area is started with COMMAND-BEGIN, and COMMAND-END terminates, for making by oneself among the two The order of adopted parameter modification.
For example, 1 UTNAME of UT*AFTER;
UT* represents the character string for finding all UT beginnings in multiplexing code, and AFTER represents to be positioned backward, positioning side BEFORE is may be arranged as in addition to AFTER, BEFORE represents to prelocalization, and 1 represents next first character String, 0 represents character string itself, therefore AFTER 1 herein represents one character string of positioning backward;UTNAME, which represents, to be determined Position to character string can be replaced by UTNAME parameters, this parameter can also be arranged to the splicing of two character strings, wherein using+ Number connection two character strings to be spliced together, such as UT+UTNAME are added then the character string navigated to can be replaced by UT beginnings The character string that UTNAME is spliced into, such as UTNAME parameters input by user are SYFG, then UT+UTNAME representatives is exactly UTSYFG, while keyword THIS may be used and carry out the character string that acute pyogenic infection of finger tip is positioned to, it is represented using THIS (b, n), b and starts word Position is accorded with, n represents length.If the UTNAME in mentioned order changes THIS (1,2)+UTNAME into, the character string navigated to is UTCNFG, UTNAME parameter are SYFG, then mentioned order can will be substituted for UTSYFG at this.
By taking 0 AUTHOR of #AUTHOR# AFTER in above-mentioned custom parameter area as an example, this order is referred to can quilt It is searched in the code segment of multiplexing and owns " AUTHOR " character string, after finding " AUTHOR " character string, position 0 character backward All " AUTHOR " character strings found are revised as storage input by user and arrived by string, i.e. " AUTHOR " character string itself This parameter of AUTHOR corresponds to the content of memory block.
It is the code segment itself that can be re-used after custom parameter area, such as:
According to the above method, it would be desirable to which the code segment of multiplexing is stored according to the form of the code reuse module of generation to code It is multiplexed in library.
After receiving code reuse order input by user, generation for being multiplexed according to the needs that code reuse order includes The marking code of code, from the code reuse module stored in code reuse library, search one by one after@symbols character string immediately with The identical code reuse module of marking code in code reuse order.Search the code reuse order of name of code and input In the identical code reuse module of marking code.
S202, when the code reuse order received includes parameter information, obtain the code reuse module In custom parameter to be modified;
In the present embodiment in code reuse order input by user, in addition to the code mark of the code including required multiplexing Know, can also include parameter information, wherein the parameter information is the content to the parameter modification in custom parameter area.
After receiving code reuse order, the marking code for including according to code reuse order gets code reuse Module, and can know code reuse mould custom parameter area in the block, the parameter for then including according to code reuse order Information obtains custom parameter to be modified in code reuse module.
For example, code reuse order input by user is:COBOL 20180108, COBOL are marking code, 20180108 For parameter information;The code reuse module that name of code is COBOL is got in code reuse library according to marking code, I.e. custom parameter area includes between identifying COMMAND-BEGIN and COMMAND-END in this code reuse module of COBOL Order, recognize three orders, be respectively:0 DATE of #DATE# AFTER, #PROG# AFTER 0 PROG and # AUTHOR#AFTER 0 PENG;
Only include a content 20180108 due to code reuse order input by user in the parameter information for including, but Custom parameter area includes three orders, determines only carried out to the parameter in the first command in custom parameter area at this time Modification.The code reuse mould custom parameter to be modified in the block of acquisition is between COMMAND-BEGIN and COMMAND-END First parameter #DATE#.
Code reuse order input by user is:COBOL 20180108 DJ0130, COBOL are marking code, 20180108 DJ0130 are parameter information;Since the parameter information that code reuse order input by user includes includes two Item content, custom parameter area include three orders, are determined at this time to the first command and second in custom parameter area Parameter in item order is modified, and the code reuse mould custom parameter to be modified in the block of acquisition is COMMAND- First parameter #DATE# between BEGIN and COMMAND-END and second parameter #PROG#.
Code reuse order input by user is:COBOL 20180108 DJ0130 PENG, COBOL are marking code, 20180108 DJ0130 PENG are parameter information.It is wrapped in the parameter information for including due to code reuse order input by user Include three contents, custom parameter area includes three orders, determine at this time in custom parameter area first command, the Parameter in two orders and Article 3 order is modified respectively, and the code reuse mould of acquisition is in the block to be modified self-defined First parameter #DATE#, second parameter #PROG# and third of the parameter between COMMAND-BEGIN and COMMAND-END A parameter #AUTHOR#.
For a code reuse module, the parameter information in code reuse order input by user is different, obtains To identical code Multiplexing module in custom parameter to be modified it is different.
And the custom parameter that can be changed that custom parameter area includes in different code reuse modules is different, input Code reuse order in parameter information it is identical, custom parameter to be modified in the different code Multiplexing module got It is different.
After receiving code reuse order, it can also be directly acquired according to parameter information to be modified in code reuse module Custom parameter.
For example, code reuse order input by user is:COBOL AUTHOR=CHEN, COBOL are marking code, AUTHOR=CHEN is parameter information, can directly be determined in code reuse module according to the parameter information in code reuse order Custom parameter to be modified be AUTHOR.
S203, the custom parameter to be modified is obtained in the code reuse mould position in the block;
After obtaining custom parameter to be modified in code reuse module, from the code reuse mould generation in the block being re-used Custom parameter is identified in code section.
For example, code reuse order input by user is:COBOL 20180108 is waited in the code reuse module got The custom parameter of modification is #DATE#.DATE character strings are identified from the code segment that can be re-used.
The mode of specific identification string be using grammatical analytics engine, after COMMAND-END to before next@i.e. Identify #DATE# this character string in the code segment that can be re-used, the code segment that when identification string can be re-used according to space pair Cutting is carried out, then each character string in pair code segment that can be re-used carries out character resolution one by one, according to each in the syntax The meaning of character is matched, and after being matched to the character string met, records the position for the DATE character strings being matched to, wherein position It sets including current line and works as forefront.
For example, code reuse order input by user is:COBOL AUTHOR=CHEN, the code reuse module got In custom parameter to be modified be AUTHOR.AUTHOR character strings are identified from the code segment that can be re-used, and record matching The position of the AUTHOR character strings arrived, wherein position include current line and work as forefront.
S204, the parameter information is replaced into the custom parameter at the position;
It is to the order of #DATE# parameters modification in custom parameter area:0 DATE of #DATE# AFTER, i.e., to DATE words Symbol string itself is modified, therefore after all DATE character strings in recognizing and recording the code segment that can be re-used, will 20180108 replace all DATE character strings.
Pair it is 0 AUTHOR of #AUTHOR# AFTER to the order of AUTHOR parameters modification in custom parameter area, i.e., AUTHOR character strings itself are modified, therefore all AUTHOR words in recognizing and recording the code segment that can be re-used After symbol string, CHEN is replaced into all AUTHOR character strings.
In other embodiments, it can also be realized to kinds of characters string by changing the order in custom parameter area Modification, it is all in identifying and recording the code segment that can be re-used for example, 1 AUTHOR of #AUTHOR# AFTER After AUTHOR character strings, the position recorded is positioned into a character string backward, and repair to the character string after repositioning Change.
S205, the modified code reuse module of load.
Modified code reuse module is recorded at the position of user's input code multiplexing commands, utilization is modified Code reuse module replaces code reuse order input by user.
It is understood that may include explanatory notes in the code reuse module of load, the readable of multiplexing code is improved Property, and user is avoided after loading one section of code, it is produced to improve the problem of readability needs to be manually entered explanatory notes It is raw.
From above-mentioned technical proposal it is found that in the present embodiment after receiving code reuse order, from the code pre-established It is multiplexed in library and obtains code reuse module corresponding with the marking code in the code reuse order, when the generation received When code multiplexing commands include parameter information, custom parameter to be modified in the code reuse module is obtained;Described in acquisition Custom parameter to be modified is in the code reuse mould position in the block;The parameter information is replaced to oneself at the position Defined parameters;And load the modified code reuse module.Due to passing through input code multiplexing commands, so that it may to find It needs the code being multiplexed and loads the code after being converted to code according to specified rule, to realize the multiplexing of code, Therefore not needing to user artificially searches the code that can be re-used, and replicates the generation manually after finding the code that can be re-used Code, and paste and need the position for being multiplexed code that could realize the multiplexing of code, not only realize code reuse it is easy to operate with And the promotion of efficiency is write, and since there is no the operation of manual replicating code, therefore avoid and omit in a replication process Partial code causes the problem of compile error to generate.And code reuse is focused on into code reuse library, it realizes the concentration of data, keeps away Exempt to be distributed in each program and is not easy management and retrieval.It realizes that code spice is unified in code reuse library, realizes and changed at one, it is more Place uses, and reduces maintenance cost.
Meanwhile the input paramete information in order, it can determine in code reuse module and wait in such a way that the syntax position The position of the custom parameter of modification, and it is automatically performed the modification of custom parameter, it goes to change one by one manually without user Code reuse mould code in the block improves the efficiency and accuracy of code reuse.
The method that the present embodiment also discloses another code reuse, referring to Fig. 3, which includes the following steps:
S301, after receiving code reuse order, obtained from the code reuse library pre-established multiple with the code With the corresponding code reuse module of marking code in order;
The realization method of step S301 is similar with the realization method of step S201 in a upper embodiment in the present embodiment, herein It repeats no more.
S302, record obtain the number of code reuse module using the code reuse order;
Such as code reuse order input by user is:COBOL then often uses this code reuse order of COBOL with reality Now this code reuse module of multiplexing COBOL is primary, just adds up to add on the access times of this code reuse module of COBOL One.S303, according to the number for using the code reuse order to obtain code reuse module, the code reuse module is carried out Sequence;
To all code reuse modules, carried out according to the descending sequence of the access times of each code reuse module Sequence.
For example, a total of 5 code reuse modules, are code reuse modules A, code reuse module B, code reuse respectively Module C, code reuse module D and code reuse module E, wherein the access times of code reuse modules A are 5 times, code reuse The access times of module B are 11 times, and the access times of code reuse module C are 1 time, and the access times of code reuse module D are 0 Secondary, the access times of code reuse module E are 0 time, then ranking results are:Code reuse module B, code reuse modules A, generation Code Multiplexing module C, code reuse module D, code reuse module E.Make according to each code reuse module in the present embodiment It is ranked up with the sequence of frequency from high to low.
S304, the sequencing according to sequence obtain the code reuse module of predetermined threshold value number;
Predetermined threshold value can be configured according to actual needs, for example, predetermined threshold value is 3, then be obtained from ranking results The code reuse module arrived is code reuse module B, code reuse modules A, code reuse module C.
S305, the code reuse module of the predetermined threshold value number got is stored to buffer area, to be received next time To after code reuse order, first from acquisition code reuse corresponding with the marking code in the code reuse order in buffer area Module;
Buffer area is set, and the code reuse module B got, code reuse modules A, code reuse module C are stored Into buffer area.
The database for being stored with the code reuse module that can be re-used is pre-established in the present embodiment, in addition to this, this Buffer area is additionally provided in embodiment, the buffer area is for storing the higher code reuse module of frequency of use so that receive To after code reuse order input by user, first searched from the higher code reuse module of frequency of use stored in buffer area With the presence or absence of the code reuse module being consistent with the marking code in code reuse order.Since the code stored in buffer area is multiple With the quantity of module code reuse few compared to the quantity of the code reuse module stored in database, and being stored in buffer area Module is the higher code reuse module of frequency of use, therefore according to the code reuse command lookup code reuse mould received When block, is first searched from buffer area, code reuse mould corresponding with code reuse order is not found only in buffer area It just searches from database when block, and then is directly searched from database compared to according to the code reuse order received The purpose that may be implemented quickly to find code reuse module, improves search efficiency.
S306, when the code reuse order received includes parameter information, obtain the code reuse module In custom parameter to be modified;
S307, the custom parameter to be modified is obtained in the code reuse mould position in the block;
S308, the parameter information is replaced into the custom parameter at the position;
S309, the modified code reuse module of load.
The realization side of the realization method of step S306-S309 and step S202-S205 in a upper embodiment in the present embodiment Formula is similar, and details are not described herein again.
From above-mentioned technical proposal it is found that in the present embodiment after receiving code reuse order, from the code pre-established It is multiplexed in library and obtains code reuse module corresponding with the marking code in the code reuse order, when the generation received When code multiplexing commands include parameter information, custom parameter to be modified in the code reuse module is obtained;Described in acquisition Custom parameter to be modified is in the code reuse mould position in the block;The parameter information is replaced to oneself at the position Defined parameters;And load the modified code reuse module.Due to passing through input code multiplexing commands, so that it may to find It needs the code being multiplexed and loads the code after being converted to code according to specified rule, to realize the multiplexing of code, Therefore not needing to user artificially searches the code that can be re-used, and replicates the generation manually after finding the code that can be re-used Code, and paste and need the position for being multiplexed code that could realize the multiplexing of code, not only realize code reuse it is easy to operate with And the promotion of efficiency is write, and since there is no the operation of manual replicating code, therefore avoid and omit in a replication process Partial code causes the problem of compile error to generate.And code reuse is focused on into code reuse library, it realizes the concentration of data, keeps away Exempt to be distributed in each program and is not easy management and retrieval.It realizes that code spice is unified in code reuse library, realizes and changed at one, it is more Place uses, and reduces maintenance cost.
Meanwhile the input paramete information in order, it can determine in code reuse module and wait in such a way that the syntax position The position of the custom parameter of modification, and it is automatically performed the modification of custom parameter, it goes to change one by one manually without user Code reuse mould code in the block improves the efficiency and accuracy of code reuse.
In addition, buffer area is provided in the present embodiment, and buffer area is for storing the higher code reuse mould of frequency of use Block is first searched corresponding code reuse module from buffer area after receiving code reuse order, is not only had in buffer area It is just searched from database when finding corresponding code reuse module, improves the search efficiency of code reuse module.
The method of corresponding above-mentioned code reuse, the present invention also provides a kind of device of code reuse, the code reuses The structural schematic diagram of device please refer to shown in Fig. 4, processing unit includes in the present embodiment:
First acquisition unit 401 and loading unit 402;
First acquisition unit 401, for after receiving code reuse order, being obtained from the code reuse library pre-established Take code reuse module corresponding with the marking code in the code reuse order;
Loading unit 402, for loading the code reuse module.
From above-mentioned technical proposal it is found that in the present embodiment after receiving code reuse order, from the code pre-established It is multiplexed in library and obtains code reuse module corresponding with the marking code in the code reuse order, and it is multiple to load the code Use module.Due to passing through input code multiplexing commands, so that it may need the code that is multiplexed to find and load the code, with reality The multiplexing of modern code, therefore do not need to user and artificially search the code that can be re-used, after finding the code that can be re-used The code is replicated manually, and pastes the multiplexing for needing the position for being multiplexed code that could realize code, not only realizes that code is multiple Promotion that is easy to operate and writing efficiency, and since there is no the operation of manual replicating code, therefore avoid The problem of holiday code leads to compile error in reproduction process generates.Code reuse is focused on into code reuse library simultaneously, The concentration for realizing data, avoids being distributed in each program and is not easy management and retrieval.Code spice system is realized in code reuse library One, it realizes and is changed at one, many places use, and reduce maintenance cost.
The present invention also provides the device of another code reuse, the structural schematic diagram of described device please refers to shown in Fig. 5, Device includes in the present embodiment:
First acquisition unit 401, loading unit 402, modification unit 501, recording unit 502, sequencing unit 503, second Acquiring unit 504 and storage unit 505;
First acquisition unit 401, for after receiving code reuse order, being obtained from the code reuse library pre-established Take code reuse module corresponding with the marking code in the code reuse order;
Unit 501 is changed, for when the code reuse order received includes parameter information, according to the ginseng Number information changes the code reuse mould custom parameter in the block;
Optionally, modification unit 501 includes:
First obtains subelement, for obtaining custom parameter to be modified in the code reuse module;
Second obtains subelement, for obtaining the custom parameter to be modified in the code reuse mould position in the block It sets;
Subelement is replaced, for the parameter information to be replaced to the custom parameter at the position.
Loading unit 402, for loading the modified code reuse module;
Recording unit 502, for recording the number for obtaining code reuse module using the code reuse order;
Sequencing unit 503, for according to the number for using the code reuse order to obtain code reuse module, to described Code reuse module is ranked up;
Second acquisition unit 504 obtains the code reuse of predetermined threshold value number for the sequencing according to sequence Module;
Storage unit 505, the code reuse module storage of the predetermined threshold value number for will get to buffer area, with It is first corresponding with the marking code in the code reuse order from being obtained in buffer area after receiving code reuse order next time Code reuse module.
From above-mentioned technical proposal it is found that in the present embodiment after receiving code reuse order, from the code pre-established It is multiplexed in library and obtains code reuse module corresponding with the marking code in the code reuse order, when the generation received When code multiplexing commands include parameter information, custom parameter to be modified in the code reuse module is obtained;Described in acquisition Custom parameter to be modified is in the code reuse mould position in the block;The parameter information is replaced to oneself at the position Defined parameters;And load the modified code reuse module.Due to passing through input code multiplexing commands, so that it may to find It needs the code being multiplexed and loads the code, to realize the multiplexing of code, therefore do not need to user and artificially search and can be answered Code replicates the code manually after finding the code that can be re-used, and pastes the position for needing to be multiplexed code It could realize the multiplexing of code, not only realize the promotion easy to operate and writing efficiency of code reuse, but also due to not depositing In the operation of manual replicating code, therefore avoids the problem of holiday code leads to compile error in a replication process and produce It is raw.And code reuse is focused on into code reuse library, it realizes the concentration of data, avoids being distributed in each program not manageability and inspection Rope.It realizes that code spice is unified in code reuse library, realizes and changed at one, many places use, and reduce maintenance cost.
Meanwhile the input paramete information in order, it can determine in code reuse module and wait in such a way that the syntax position The position of the custom parameter of modification, and it is automatically performed the modification of custom parameter, it goes to change one by one manually without user Code reuse mould code in the block improves the efficiency and accuracy of code reuse.
In addition, buffer area is provided in the present embodiment, and buffer area is for storing the higher code reuse mould of frequency of use Block is first searched corresponding code reuse module from buffer area after receiving code reuse order, is not only had in buffer area It is just searched from database when finding corresponding code reuse module, improves the search efficiency of code reuse module.
Each embodiment is described by the way of progressive in this specification, the highlights of each of the examples are with other The difference of embodiment, just to refer each other for identical similar portion between each embodiment.The device provided for embodiment For, since it is corresponding with the method that embodiment provides, so description is fairly simple, related place is said referring to method part It is bright.
It should be noted that herein, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or equipment including a series of elements includes not only those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or equipment institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including institute State in the process, method, article or equipment of element that there is also other identical elements.
The foregoing description of the disclosed embodiments enables those skilled in the art to realize or use the present invention.To this A variety of modifications of a little embodiments will be apparent for a person skilled in the art, and the general principles defined herein can Without departing from the spirit or scope of the present invention, to realize in other embodiments.Therefore, the present invention will not be limited It is formed on the embodiments shown herein, and is to fit to consistent with the principles and novel features disclosed in this article widest Range.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered It is considered as protection scope of the present invention.

Claims (10)

1. a kind of method of code reuse, which is characterized in that including:
After receiving code reuse order, from acquisition and the code reuse order in the code reuse library pre-established The corresponding code reuse module of marking code;
Load the code reuse module.
2. according to the method described in claim 1, it is characterized in that, it is described got from the code reuse library pre-established with After the corresponding code reuse module of marking code in the code reuse request, further include:
When the code reuse order received includes parameter information, it is multiple to change the code according to the parameter information With mould custom parameter in the block;
The load code reuse module includes:
Load the modified code reuse module.
3. according to the method described in claim 2, it is characterized in that, described change the code reuse according to the parameter information Mould custom parameter in the block includes:
Obtain custom parameter to be modified in the code reuse module;
The custom parameter to be modified is obtained in the code reuse mould position in the block;
The parameter information is replaced into the custom parameter at the position.
4. according to the method described in claim 1-3 any one, which is characterized in that be stored in the code reuse library multiple Code reuse module;
The code reuse module by the name of code for the code segment that can be re-used, the code segment being re-used it is self-defined Parameter region and the code segment composition being re-used.
5. according to the method described in claim 1-3 any one, which is characterized in that described from the code reuse library pre-established It is middle obtain corresponding with the marking code in code reuse order code reuse module after, further include:
Record obtains the number of code reuse module using the code reuse order;
According to the number for using the code reuse order to obtain code reuse module, the code reuse module is arranged Sequence;
According to the sequencing of sequence, the code reuse module of predetermined threshold value number is obtained;
The code reuse module of the predetermined threshold value number got is stored to buffer area, to receive code reuse next time After order, first from acquisition code reuse module corresponding with the marking code in the code reuse order in buffer area.
6. a kind of device of code reuse, which is characterized in that including:
First acquisition unit is obtained and institute from the code reuse library pre-established for after receiving code reuse order State the corresponding code reuse module of marking code in code reuse order;
Loading unit, for loading the code reuse module.
7. device according to claim 6, which is characterized in that further include:
Unit is changed, for when the code reuse order received includes parameter information, according to the parameter information Change the code reuse mould custom parameter in the block;
The loading unit includes:
Load the modified code reuse module.
8. device according to claim 7, which is characterized in that the modification unit includes:
First obtains subelement, for obtaining custom parameter to be modified in the code reuse module;
Second obtains subelement, for obtaining the custom parameter to be modified in the code reuse mould position in the block;
Subelement is replaced, for the parameter information to be replaced to the custom parameter at the position.
9. according to the device described in claim 6-8 any one, which is characterized in that be stored in the code reuse library multiple Code reuse module;
The code reuse module by the name of code for the code segment that can be re-used, the code segment being re-used it is self-defined Parameter region and the code segment composition being re-used.
10. according to the device described in claim 6-8 any one, which is characterized in that further include:
Recording unit, for recording the number for obtaining code reuse module using the code reuse order;
Sequencing unit, for according to the number for using the code reuse order to obtain code reuse module, answering the code It is ranked up with module;
Second acquisition unit obtains the code reuse module of predetermined threshold value number for the sequencing according to sequence;
The code reuse module of storage unit, the predetermined threshold value number for will get is stored to buffer area, with next time After receiving code reuse order, first from acquisition code corresponding with the marking code in the code reuse order in buffer area Multiplexing module.
CN201810200727.2A 2018-03-12 2018-03-12 A kind of method and device of code reuse Pending CN108446115A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810200727.2A CN108446115A (en) 2018-03-12 2018-03-12 A kind of method and device of code reuse

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810200727.2A CN108446115A (en) 2018-03-12 2018-03-12 A kind of method and device of code reuse

Publications (1)

Publication Number Publication Date
CN108446115A true CN108446115A (en) 2018-08-24

Family

ID=63194139

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810200727.2A Pending CN108446115A (en) 2018-03-12 2018-03-12 A kind of method and device of code reuse

Country Status (1)

Country Link
CN (1) CN108446115A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110489109A (en) * 2019-08-13 2019-11-22 上海乂学教育科技有限公司 The method and device of code reuse
CN112631653A (en) * 2021-03-09 2021-04-09 广州欧赛斯信息科技有限公司 Teaching evaluation index library code adaptation method and system
CN113505159A (en) * 2021-07-16 2021-10-15 马上消费金融股份有限公司 Data detection method, device and equipment
CN115562679A (en) * 2022-12-05 2023-01-03 广州市保伦电子有限公司 Method and server for automatically generating codes based on Java language

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461548A (en) * 2014-12-15 2015-03-25 北京国双科技有限公司 Code fragment adding method and device
CN106462399A (en) * 2014-06-30 2017-02-22 微软技术许可有限责任公司 Code recommendation
CN106681739A (en) * 2017-01-11 2017-05-17 杭州云象网络技术有限公司 Method for automatically generating intelligent contract
US20170147298A1 (en) * 2008-02-20 2017-05-25 Embarcadero Technologies, Inc. Development system with improved methodology for creation and reuse of software assets

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170147298A1 (en) * 2008-02-20 2017-05-25 Embarcadero Technologies, Inc. Development system with improved methodology for creation and reuse of software assets
CN106462399A (en) * 2014-06-30 2017-02-22 微软技术许可有限责任公司 Code recommendation
CN104461548A (en) * 2014-12-15 2015-03-25 北京国双科技有限公司 Code fragment adding method and device
CN106681739A (en) * 2017-01-11 2017-05-17 杭州云象网络技术有限公司 Method for automatically generating intelligent contract

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110489109A (en) * 2019-08-13 2019-11-22 上海乂学教育科技有限公司 The method and device of code reuse
CN112631653A (en) * 2021-03-09 2021-04-09 广州欧赛斯信息科技有限公司 Teaching evaluation index library code adaptation method and system
CN112631653B (en) * 2021-03-09 2021-06-15 广州欧赛斯信息科技有限公司 Index library code adaptation method and system
CN113505159A (en) * 2021-07-16 2021-10-15 马上消费金融股份有限公司 Data detection method, device and equipment
CN113505159B (en) * 2021-07-16 2023-04-25 马上消费金融股份有限公司 Data detection method, device and equipment
CN115562679A (en) * 2022-12-05 2023-01-03 广州市保伦电子有限公司 Method and server for automatically generating codes based on Java language

Similar Documents

Publication Publication Date Title
CN108446115A (en) A kind of method and device of code reuse
CN109086199B (en) Method, terminal and storage medium for automatically generating test script
US9207933B2 (en) Identifying authors of changes between multiple versions of a file
WO2006102512A2 (en) Change control management of xml documents
CN102279749A (en) Method and equipment for merging codes
CN107148616A (en) The efficient annotation system controlled for distributed version
CN102708203A (en) Database dynamic management method based on XML metadata
CN102110102A (en) Data processing method and device, and file identifying method and tool
CN102959538B (en) Index to document
CN110362596A (en) A kind of control method and device of text Extracting Information structural data processing
CN107783766A (en) The method and apparatus cleared up the file of application program
CN103309879A (en) Method and device for managing marks in WORD document
US8521762B2 (en) Automated business process modeling
CN109657043B (en) Method, device and equipment for automatically generating article and storage medium
CN112036843A (en) Flow element positioning method, device, equipment and medium based on RPA and AI
CN102171696B (en) The generation method and apparatus of customization data
CN106293862B (en) A kind of analysis method and device of expandable mark language XML data
CN106202423A (en) A kind of file ordering method and apparatus
CN113971044A (en) Component document generation method, device, equipment and readable storage medium
EP3992785A1 (en) Method and apparatus for acquiring command line multiway tree of data network device
CN107590076A (en) Obtain method, the method and device in generation business datum source of business datum
CN114048308A (en) Method and device for generating category retrieval report
CN113760907A (en) Data uniqueness identification method in database
CN107679027B (en) Method and device for converting Excel test case table into Word test case table
CN110489109A (en) The method and device of code reuse

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20180824