CN103699377A - Reconstruction combination method for program codes - Google Patents

Reconstruction combination method for program codes Download PDF

Info

Publication number
CN103699377A
CN103699377A CN201310639852.0A CN201310639852A CN103699377A CN 103699377 A CN103699377 A CN 103699377A CN 201310639852 A CN201310639852 A CN 201310639852A CN 103699377 A CN103699377 A CN 103699377A
Authority
CN
China
Prior art keywords
combination
reconstructed
reconstructed operation
reconstruct
program code
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.)
Granted
Application number
CN201310639852.0A
Other languages
Chinese (zh)
Other versions
CN103699377B (en
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.)
State Grid Corp of China SGCC
Information and Telecommunication Branch of State Grid Jiangxi Electric Power Co Ltd
Original Assignee
State Grid Corp of China SGCC
Information and Telecommunication Branch of State Grid Jiangxi Electric Power Co 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 State Grid Corp of China SGCC, Information and Telecommunication Branch of State Grid Jiangxi Electric Power Co Ltd filed Critical State Grid Corp of China SGCC
Priority to CN201310639852.0A priority Critical patent/CN103699377B/en
Publication of CN103699377A publication Critical patent/CN103699377A/en
Application granted granted Critical
Publication of CN103699377B publication Critical patent/CN103699377B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

The invention provides a reconstruction combination method for program codes. The method comprises a reconstruction combination initialization step a, a prepositive and postpositive key program code element extraction step b, a dependency relationship marking step c, an exchange relationship marking and reordering step d, an optimization capability marking step e, an optimization operation step f and an optimized program code exporting step g, wherein dependency relationships comprise a complete dependency relationship, a completely partial dependency relationship, a partially complete dependency relationship and a partially partial dependency relationship; exchange relationships comprises an unconditional exchange relationship and a conditional exchange relationship. The method has the characteristics of high reconstruction efficiency, processing flexibility, complete optimization and the like.

Description

A kind of method that program code is reconstructed to operative combination
Technical field
The present invention relates to code refactoring technology, especially a kind of method that program code is reconstructed to operative combination.
Background technology
Reconstruct refers to and is not changing under the prerequisite of " can the examining behavior of software ", by adjustment programme inner structure, design, allow code be easier to understand, more easily to revise, being reconstructed into Extreme Programming, fast programming etc. provides guarantee and has supported, but also rests on the exploratory stage about the research of reconstruct instrument.Reconstructed operation instrument has eclipse(for the Integrated Development Tool of java applet) reconstruct etc., but this class instrument seriously depends on code operation person's command operating, and operational efficiency is low.
Code refactoring process is not often independently carried out, and when reconstruct is often accompanied by a plurality of step, carries out, and reasonably organizing the combination execution sequence between a plurality of reconstructed operations is the key that reconstruct is carried out.The present invention studies a kind of method that program code is reconstructed to operative combination, for intelligent reconstructed operation, lays a good foundation, and has reconstruct efficiency high.
Summary of the invention
The invention provides a kind of method that program code is reconstructed to operative combination, comprise the following steps:
Step a: reconstructed operation combination initialization step; Be written into reconstructed operation combination to be optimized, read user-defined initial reconstitution operative combination configuration, described initial reconstitution operative combination meets all precondition inspection requirements, and all precondition legitimacies are verified, guarantees that initial reconstitution combination can true(-)running;
Step b: extract preposition, rearmounted key procedure code element step; According to described user-defined initial reconstitution operative combination, extract preposition key procedure code element and the rearmounted key procedure code element of each reconstructed operation in combination; Described preposition key procedure code element represents the program code elements state before reconstructed operation effect, and described rearmounted key procedure code element represents the program code elements state after reconstructed operation effect;
Step c: mark dependence step; By the concrete reconstructed operation in the combination of traversal reconstructed operation, analyze the preposition and rearmounted key procedure code element of initial reconstitution combination simultaneously, if the latter's precondition in a pair of reconstructed operation meets, depend on the result that the former reconstruct is carried out, by sign, carry out the dependence between each reconstructed operation of mark;
Steps d: the commutative relation of mark and the step that reorders; After if the former with the latter in a pair of reconstructed operation sequentially exchanges, the result that reconstructed operation combination is carried out is constant, thinks and has tradable relation between these two reconstructed operations, by sign, carrys out the commutative relation between each reconstructed operation of mark; And according to the commutative relation between each reconstructed operation, reconstruct operative combination is carried out to swap operation, obtain new reconstructed operation combination after reconstruct being combined into rearrangement order operation;
Step e: mark can optimization ability step; Described new reconstructed operation combination is carried out to step c operation, adjust the dependence between described new reconstructed operation combination, by the dependence between described new reconstructed operation combination and each reconstructed operation, what by reconstruct Combinatorial Optimization rule, draw described new reconstructed operation combination can optimization ability, and carries out mark with identifying;
Step f: Optimum Operation step; Reconstruct Combinatorial Optimization rule application is carried out to Optimum Operation in described new reconstructed operation combination; If Optimum Operation process is interrupted or blocking-up, return original state and avoid endless loop operation;
Step g: derive the program code step after optimizing; Program code after derivation operates described new reconstructed operation Combinatorial Optimization.
Wherein said dependence comprises complete dependence, complete partial dependency relation, part dependence, part partial dependency relation completely.
Wherein said commutative relation comprises unconditional commutative relation, condition commutative relation.
Wherein said reconstruct Combinatorial Optimization rule comprises combination reduced rule and merger reformulation rule.
Technique effect of the present invention is:
1, reconstruct efficiency is high, and processing procedure is flexible, and reconstruct combined altitudes is simplified, and reconstructed operation complexity reduces greatly;
2, support a large amount of reconstructed operations to carry out simultaneously, be applicable to reconstructed operation in batches, reconstruction property obviously promotes;
3, set reconstruct Combinatorial Optimization rule, optimized and implement from left to right, process is clear, and system resource takies less, the fast response time of makeing mistakes;
4, implementation procedure is simple, and feasibility is strong, and easy to operate, easy left-hand seat, for robotization, intelligent reconstruct are had laid a good foundation.
Accompanying drawing explanation
Fig. 1 is code refactoring operation step map of the present invention.
Fig. 2 is general frame process flow diagram of the present invention.
Embodiment
As shown in Figure 1, code refactoring operation step map of the present invention, a kind of method that program code is reconstructed to operative combination provided by the invention, comprises step:
Step a: reconstructed operation combination initialization step; Be written into reconstructed operation combination to be optimized, read user-defined initial reconstitution operative combination configuration, described initial reconstitution operative combination meets all precondition inspection requirements, and all precondition legitimacies are verified, guarantees that initial reconstitution combination can true(-)running;
Step b: extract preposition, rearmounted key procedure code element step; According to described user-defined initial reconstitution operative combination, extract preposition key procedure code element and the rearmounted key procedure code element of each reconstructed operation in combination; Described preposition key procedure code element represents the program code elements state before reconstructed operation effect, and described rearmounted key procedure code element represents the program code elements state after reconstructed operation effect;
Step c: mark dependence step; By the concrete reconstructed operation in the combination of traversal reconstructed operation, analyze the preposition and rearmounted key procedure code element of initial reconstitution combination simultaneously, if the latter's precondition in a pair of reconstructed operation meets, depend on the result that the former reconstruct is carried out, by sign, carry out the dependence between each reconstructed operation of mark;
Steps d: the commutative relation of mark and the step that reorders; After if the former with the latter in a pair of reconstructed operation sequentially exchanges, the result that reconstructed operation combination is carried out is constant, thinks and has tradable relation between these two reconstructed operations, by sign, carrys out the commutative relation between each reconstructed operation of mark; And according to the commutative relation between each reconstructed operation, reconstruct operative combination is carried out to swap operation, obtain new reconstructed operation combination after reconstruct being combined into rearrangement order operation;
Step e: mark can optimization ability step; Described new reconstructed operation combination is carried out to step c operation, adjust the dependence between described new reconstructed operation combination, by the dependence between described new reconstructed operation combination and each reconstructed operation, what by reconstruct Combinatorial Optimization rule, draw described new reconstructed operation combination can optimization ability, and carries out mark with identifying;
Step f: Optimum Operation step; Reconstruct Combinatorial Optimization rule application is carried out to Optimum Operation in described new reconstructed operation combination; If Optimum Operation process is interrupted or blocking-up, return original state and avoid endless loop operation;
Step g: derive the program code step after optimizing; Program code after derivation operates described new reconstructed operation Combinatorial Optimization.
General frame process flow diagram of the present invention as shown in Figure 2, the present invention combines and reads user-defined combination initial configuration by being written into reconstructed operation to be optimized, to initial reconstitution, a series of analyzing and processing operation is carried out in combination, by relation between traversal search operation, find that the potential of operation room can optimization, reset reconstructed operation position and to optimizable reconstructed operation to applying successively from left to right the corresponding principle of optimality, and then simplify reconstruct complicacy and shorten reconstructed operation step, the reconstructed operation being finally optimized combination.
1, reconstructed operation relation derivation:
First, according to User Defined initial pool, infer preposition key procedure code element and the rearmounted key procedure code element of each reconstructed operation.Preposition key procedure code element can represent the reconfiguration program code element state for the treatment of before reconstructed operation effect, rearmounted key procedure code element can represent the reconfiguration program code element state for the treatment of after reconstructed operation effect, and the essence of reconstructed operation unit is that preposition key procedure code element is converted to rearmounted key procedure code element.For example: reconstructed operation " rename method MethodName1 is method MethodName2 ", preposition key procedure code element is: MethodName1, rearmounted key procedure code element is: MethodName2.
Secondly, traversal is explored the also dependence between mark reconstructed operation.In a pair of reconstructed operation, if the latter's precondition satisfied depends on the result that the former reconstruct is carried out, claim the relation of Existence dependency between these two reconstructed operations.The dependence of two reconstruct operation rooms has four kinds: completely-rely on completely (the latter's precondition just place one's entire reliance upon the former reconstruct execution result), completely-partial dependency (the latter's precondition place one's entire reliance upon the former reconstruct execution result a part), partly-rely on that (the latter's precondition not only relies on the result that the former reconstruct is carried out completely, also rely on the result that other reconstruct is carried out) and part-partial dependency (the latter's precondition relies on a part for the former reconstruct execution result, also relies on the result that other reconstruct is carried out).
Then, by the commutative relation between the dependence analytical derivation reconstructed operation of initial reconstitution operative combination.In a pair of reconstructed operation, if after the exchange of the order of the former with the latter, the result that reconstructed operation combination is carried out is constant, claims to have tradable relation between these two reconstructed operations.The commutative relation of two reconstruct operation rooms has two kinds: unconditional exchange (the direct exchange sequence of the former with the latter, need not carry out any other processes) and condition exchange (after the former with the latter exchange, need correspondingly revise and cause affected key procedure code element in the former because the latter is preposition).
2, reconstruct Combinatorial Optimization rule application:
First, according to the commutative relation between reconstructed operation, the tradable reconstructed operation pair of mark.For the commutative relation mark in reconstructed operation combination, respectively to corresponding reconstructed operation to unconditionally exchanging or condition exchange.Reconstructed operation exchange process is called again the rearrangement to initial reconstitution combination, and rearrangement is a pith of reconstruct combined depth optimizing process, for the application of reconstruct Combinatorial Optimization rule is laid a good foundation.
Secondly, the reconstruct combination after resetting is analyzed, explored the also potential optimized of mark reconstruct combination.Suitably adjust the dependence between the reconstructed operation after resetting, by new reconstructed operation combination and the dependence between each reconstructed operation, by adaptive reconstruct Combinatorial Optimization rule analyze explore reconstructed operation combination can optimization ability, and use specific identifier mark.
Then, regular to application reconstructed operation Combinatorial Optimization to optimizable reconstructed operation.Can optimization ability for analyze exploring before the reconstructed operation that obtains, the new reconstructed operation combination by corresponding reconstruct Combinatorial Optimization rule application after reordering.Reconstructed operation Combinatorial Optimization rule has two kinds: combination reduced rule (can directly merge former and later two reconstructed operations, only carry out a precondition inspection and a reconstruct conversion operations) and merger reformulation rule (merge former and later two reconstructed operations, carry out a precondition inspection and twice reconstruct conversion operations).

Claims (4)

1. program code is reconstructed to a method for operative combination, it is characterized in that, comprise the following steps:
Step a: reconstructed operation combination initialization step; Be written into reconstructed operation combination to be optimized, read user-defined initial reconstitution operative combination configuration, described initial reconstitution operative combination meets all precondition inspection requirements, and all precondition legitimacies are verified, guarantees that initial reconstitution combination can true(-)running;
Step b: extract preposition, rearmounted key procedure code element step; According to described user-defined initial reconstitution operative combination, extract preposition key procedure code element and the rearmounted key procedure code element of each reconstructed operation in combination; Described preposition key procedure code element represents the program code elements state before reconstructed operation effect, and described rearmounted key procedure code element represents the program code elements state after reconstructed operation effect;
Step c: mark dependence step; By the concrete reconstructed operation in the combination of traversal reconstructed operation, analyze the preposition and rearmounted key procedure code element of initial reconstitution combination simultaneously, if the latter's precondition in a pair of reconstructed operation meets, depend on the result that the former reconstruct is carried out, by sign, carry out the dependence between each reconstructed operation of mark;
Steps d: the commutative relation of mark and the step that reorders; After if the former with the latter in a pair of reconstructed operation sequentially exchanges, the result that reconstructed operation combination is carried out is constant, thinks and has tradable relation between these two reconstructed operations, by sign, carrys out the commutative relation between each reconstructed operation of mark; And according to the commutative relation between each reconstructed operation, reconstruct operative combination is carried out to swap operation, obtain new reconstructed operation combination after reconstruct being combined into rearrangement order operation;
Step e: mark can optimization ability step; Described new reconstructed operation combination is carried out to step c operation, adjust the dependence between described new reconstructed operation combination, by the dependence between described new reconstructed operation combination and each reconstructed operation, what by reconstruct Combinatorial Optimization rule, draw described new reconstructed operation combination can optimization ability, and carries out mark with identifying;
Step f: Optimum Operation step; Reconstruct Combinatorial Optimization rule application is carried out to Optimum Operation in described new reconstructed operation combination; If Optimum Operation process is interrupted or blocking-up, return original state and avoid endless loop operation;
Step g: derive the program code step after optimizing; Program code after derivation operates described new reconstructed operation Combinatorial Optimization.
2. a kind of method that program code is reconstructed to operative combination according to claim 1, is characterized in that: described dependence comprises complete dependence, complete partial dependency relation, part dependence, part partial dependency relation completely.
3. a kind of method that program code is reconstructed to operative combination according to claim 1, is characterized in that: described commutative relation comprises unconditional commutative relation, condition commutative relation.
4. a kind of method that program code is reconstructed to operative combination according to claim 1, is characterized in that: described reconstruct Combinatorial Optimization rule comprises combination reduced rule and merger reformulation rule.
CN201310639852.0A 2013-12-04 2013-12-04 Reconstruction combination method for program codes Active CN103699377B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310639852.0A CN103699377B (en) 2013-12-04 2013-12-04 Reconstruction combination method for program codes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310639852.0A CN103699377B (en) 2013-12-04 2013-12-04 Reconstruction combination method for program codes

Publications (2)

Publication Number Publication Date
CN103699377A true CN103699377A (en) 2014-04-02
CN103699377B CN103699377B (en) 2017-02-01

Family

ID=50360916

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310639852.0A Active CN103699377B (en) 2013-12-04 2013-12-04 Reconstruction combination method for program codes

Country Status (1)

Country Link
CN (1) CN103699377B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106843820A (en) * 2015-12-04 2017-06-13 阿里巴巴集团控股有限公司 Code process method and apparatus
CN109324800A (en) * 2018-10-25 2019-02-12 金蝶软件(中国)有限公司 It is a kind of avoid endless loop calculate optimization method and optimization device
CN113495752A (en) * 2020-04-03 2021-10-12 中国科学院沈阳自动化研究所 Method and system for quickly reconstructing codes after process change

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPWO2008072334A1 (en) * 2006-12-14 2010-03-25 富士通株式会社 Compiling method and compiler
CN101706753B (en) * 2009-12-11 2013-04-10 武汉虹信通信技术有限责任公司 Unit testing framework and method based on Perl

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106843820A (en) * 2015-12-04 2017-06-13 阿里巴巴集团控股有限公司 Code process method and apparatus
CN106843820B (en) * 2015-12-04 2020-08-04 阿里巴巴集团控股有限公司 Code processing method and device
CN109324800A (en) * 2018-10-25 2019-02-12 金蝶软件(中国)有限公司 It is a kind of avoid endless loop calculate optimization method and optimization device
CN113495752A (en) * 2020-04-03 2021-10-12 中国科学院沈阳自动化研究所 Method and system for quickly reconstructing codes after process change
CN113495752B (en) * 2020-04-03 2024-04-30 中国科学院沈阳自动化研究所 Method and system for quickly reconstructing codes based on process change

Also Published As

Publication number Publication date
CN103699377B (en) 2017-02-01

Similar Documents

Publication Publication Date Title
Lindbom et al. Perl-speaks-NONMEM (PsN)—a Perl module for NONMEM related programming
CN102591777B (en) A kind of unit test code generation method and device
CN106649100A (en) Automatic test method and system
CN105528418B (en) A kind of design documentation generation method and device
CN112199086A (en) Automatic programming control system, method, device, electronic device and storage medium
CN110888720A (en) Task processing method and device, computer equipment and storage medium
KR101588592B1 (en) Hybrid application development system based on object relational mapping and the method thereof
CN105339889A (en) Techniques for language translation localization for computer applications
CN106557351B (en) The data processing method and device of built-in application program
CN114424257A (en) Automatic rendering and extraction of form data using machine learning
CN105653245A (en) Code automatic generation system, device and method
CN109144506A (en) A kind of configurable UI interface creating method
US20160132307A1 (en) Leveraging Legacy Applications for Use with Modern Applications
CN104731588A (en) Page layout file generation method and device
US10496423B2 (en) Method for opening up data and functions of terminal application based on reconstruction technology
CN110990048A (en) Method and system for monitoring resource loss of Unity project
Benouda et al. Automatic code generation within MDA approach for cross-platform mobiles apps
CN103699377A (en) Reconstruction combination method for program codes
CN111158800B (en) Method and device for constructing task DAG based on mapping relation
CN110109684B (en) Block chain link point management proxy service installation method, electronic device and storage medium
CN103455337A (en) Method for using dynamic library under Android development environment
CN104199675A (en) System capable of quick system development based on database parameter utilization
US20150378693A1 (en) Compiling nested relational algebras with multiple intermediate representations
CN103902274A (en) Platform for developing smart television UI (user interface)
Dickinson et al. Simitk: Visual programming of the itk image-processing library within simulink

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant