CN110333851A - Code decoupling method and relevant device - Google Patents

Code decoupling method and relevant device Download PDF

Info

Publication number
CN110333851A
CN110333851A CN201910505108.9A CN201910505108A CN110333851A CN 110333851 A CN110333851 A CN 110333851A CN 201910505108 A CN201910505108 A CN 201910505108A CN 110333851 A CN110333851 A CN 110333851A
Authority
CN
China
Prior art keywords
code
subobject
call
codes
calling
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
CN201910505108.9A
Other languages
Chinese (zh)
Other versions
CN110333851B (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910505108.9A priority Critical patent/CN110333851B/en
Publication of CN110333851A publication Critical patent/CN110333851A/en
Application granted granted Critical
Publication of CN110333851B publication Critical patent/CN110333851B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

This application involves the disaggregated models more particularly to a kind of code decoupling method and relevant device in intelligent decision, are applied to electronic equipment, this method comprises: obtaining the source code of target application;Analysis source code uses object to obtain the multiple of target application;Source code is decoupled as public calling code and object reference code using object based on multiple, public calling code includes multiple first codes, each first code allows to use object reference by multiple at least two using in object, object reference code includes that multiple subobjects call code, it includes multiple second codes that each subobject, which calls code, multiple second codes that subobject calls code i to include only allow quilt object reference code i associated using object reference, and it is one of them in the multiple subobject calling code that subobject, which calls code i,.Source code can be simplified using the embodiment of the present application and promote the maintainability of source code.

Description

Code decoupling method and relevant device
Technical field
This application involves electronic technology field more particularly to a kind of code decoupling methods and relevant device.
Background technique
The same application can often have that multiple (such as the application of express delivery class can have manager, the person that posts part, pull part using objects Person, receiver etc.), multiple overlappings that can have partial function using object.And writing for current code is extremely lack of standardization, for It is to be developed respectively to each using object there are the code writing mode of multiple applications using object, leads to multiple uses The common common code that object can call repeats to write, and causes the lengthy and jumbled too fat to move of source code, maintainable low.
Summary of the invention
The embodiment of the present application provides a kind of code decoupling method and relevant device, for simplifying source code and promoting source code Maintainability.
In a first aspect, the embodiment of the present application provides a kind of code decoupling method, which comprises
Obtain the source code of target application;
The source code is parsed, uses object to obtain the multiple of the target application;
The source code is decoupled as public calling code and object reference code using object based on the multiple, it is described Public calling code includes multiple first codes, and each first code permission is made by the multiple at least two using in object With object reference, the object reference code includes that multiple subobjects call code, and it includes multiple that each subobject, which calls code, Second code, subobject call code i multiple second codes for including only to allow to be called by the subobject code i is associated to be made With object reference, it is one of them in the multiple subobject calling code that the subobject, which calls code i,.
Second aspect, the embodiment of the present application provide a kind of code decoupling device, are applied to electronic equipment, described device packet It includes:
Acquiring unit, for obtaining the source code of target application;
Resolution unit uses object for parsing the source code to obtain the multiple of the target application;
Decoupling unit, for being decoupled the source code for public calling code and object using object based on the multiple Code is called, the public calling code includes multiple first codes, and each first code allows to use object by the multiple In at least two use object reference, the object reference code includes that multiple subobjects call code, each subobject tune It include multiple second codes with code, multiple second codes that subobject calls code i to include only allow by the subobject tune Object reference is used with code i is associated, it is that the multiple subobject calls in code wherein that the subobject, which calls code i, One.
The third aspect, the embodiment of the present application provide a kind of electronic equipment, including processor, memory, communication interface, and One or more programs, said one or multiple programs are stored in above-mentioned memory, and are configured by above-mentioned processor It executes, above procedure is included the steps that for executing the instruction in method described in the embodiment of the present application first aspect.
Fourth aspect, the embodiment of the present application provide a kind of computer readable storage medium, wherein above-mentioned computer-readable Storage medium is for storing computer program, wherein above-mentioned computer program is executed by processor, to realize that the application such as is implemented Step some or all of described in method described in example first aspect.
5th aspect, the embodiment of the present application provide a kind of computer program product, wherein above-mentioned computer program product Non-transient computer readable storage medium including storing computer program, above-mentioned computer program are operable to make to calculate Step some or all of described in method of the machine execution as described in the embodiment of the present application first aspect.The computer program produces Product can be a software installation packet.
As can be seen that in the embodiment of the present application, electronic equipment obtains the source code of target application, the source generation is parsed Code uses object to obtain the multiple of the target application;Multiple use objects are then based on to decouple source code for public tune With code and object reference code.Compared to the source code before decoupling, only comprising public calling generation in the source code that decouples Code and object reference code eliminate in the source code before decoupling and repeat the public calling code write, so that after decoupling Source code it is more succinct, it is readable strong.During later maintenance, it is only necessary to the public calling code safeguarded of needs or Object reference code is readjusted, and is not needed to carry out big change to the general frame of source code, is reduced maintenance process In difficulty, to improve the maintainability of source code.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of application for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is a kind of flow diagram of code decoupling method provided by the embodiments of the present application;
Fig. 2 is the flow diagram of another code decoupling method provided by the embodiments of the present application;
Fig. 3 is the structural schematic diagram of a kind of electronic equipment provided by the embodiments of the present application;
Fig. 4 is a kind of code decoupling device provided by the embodiments of the present application.
Specific embodiment
In order to make those skilled in the art more fully understand application scheme, below in conjunction in the embodiment of the present application Attached drawing, the technical scheme in the embodiment of the application is clearly and completely described, it is clear that described embodiment is only The embodiment of the application a part, instead of all the embodiments.Based on the embodiment in the application, ordinary skill people Member's every other embodiment obtained without making creative work, all should belong to the model of the application protection It encloses.
It is described in detail separately below.
The description and claims of this application and term " first ", " second ", " third " and " in the attached drawing Four " etc. are not use to describe a particular order for distinguishing different objects.In addition, term " includes " and " having " and it Any deformation, it is intended that cover and non-exclusive include.Such as it contains the process, method of a series of steps or units, be System, product or equipment are not limited to listed step or unit, but optionally further comprising the step of not listing or list Member, or optionally further comprising other step or units intrinsic for these process, methods, product or equipment.
Referenced herein " embodiment " is it is meant that a particular feature, structure, or characteristic described can wrap in conjunction with the embodiments It is contained at least one embodiment of the application.Each position in the description occur the phrase might not each mean it is identical Embodiment, nor the independent or alternative embodiment with other embodiments mutual exclusion.Those skilled in the art explicitly and Implicitly understand, embodiment described herein can be combined with other embodiments.
The electronic equipment that the application refers to may include the various handheld devices with wireless communication function, mobile unit, Wearable device calculates equipment, service equipment or other processing equipments and various forms for being connected to radio modem User equipment (User Equipment, UE), mobile station (Mobile Station, MS), terminal device (terminal Device) etc..
Referring to Figure 1, Fig. 1 is a kind of code decoupling method provided by the embodiments of the present application, is applied to electronic equipment, described Method includes:
Step 101: obtaining the source code of target application.
Further, before the source code for obtaining target application, the method also includes: code decoupling instruction is received, The code decoupling instruction carries the mark of the source code of the target application.
Wherein, code decoupling instruction, which refers to, reduces the instruction that is mutually related between code.In soft project, between code There is dependence to certainly exist coupling, theoretic absolute zero coupling is not accomplished, but can pass through some existing sides Method minimizes the degree of coupling, therefore code decoupling does not imply that the coupling released between code completely, but reduces between code Coupling.
Wherein, the source code refers to the uncompiled target application according to certain programming language specification writing Text file is the readable computer language instruction of series of human.In modern procedures language, source code be can be with books Or the form of tape occurs, but the most commonly used format is text file, the purpose of this typical format is to compile out Computer program.
Step 102: parsing the source code, use object to obtain the multiple of the target application.
Specifically, the parsing source code, to obtain multiple specific sides using object of the target application Formula are as follows: the source code is parsed, to obtain the code text of the source code;It whether determines in the code text comprising using Object keywords;If using object keywords comprising described in the code text, based on described true using object keywords The multiple of the fixed target application use object.
It illustrates, it is assumed that target application attracts customers for PA, and the source code of electronic equipment parsing obtains code text, if described It include " salesman of PA ", " recommender " " salesman of third part ", " admin in code text Of PA ", then can determine that the PA attracts customers multiple uses object are as follows: PA business personnel, recommendation person, third party business personnel, PA management Member, wherein salesman of PA is the expression character of PA business personnel in code text, and recommender is to push away in code text The expression character for the person of recommending, salesman of third part are the expression character of third party business personnel in code text, admin Of PA is the expression character of administrator in code text.
Step 103: being decoupled the source code for public calling code and object reference using object based on the multiple Code, the public calling code includes multiple first codes, and each first code allows by the multiple using in object At least two use object reference, and the object reference code includes that multiple subobjects call code, and each subobject calls generation Code includes multiple second codes, and multiple second codes that subobject calls code i to include only allow to call generation by the subobject Code i is associated to use object reference, the subobject call code i be the multiple subobject call in code wherein one It is a.
Specifically, described to be decoupled the source code for public calling code and object tune using object based on the multiple With code, the public calling code includes multiple first codes, and each first code allows by the multiple using in object At least two use object reference, the object reference code includes that multiple subobjects call code, comprising: by the source generation Code is divided by function as multiple component codes;Determine that each component code allows called use object;If component code j The quantity using object for allowing to call is greater than or equal to 2, it is determined that the component code j is in the public calling code One first code;If the quantity using object that the component code allows to call is 1, it is determined that the component code j is Its second code called using the corresponding subobject of object in code for allowing to call.
It illustrates, it is assumed that target application attracts customers for PA, and what the PA attracted customers includes following four using object: PA business Member, recommendation person, third party business personnel, PA administrator, each identical function being had using object be, for example, send message function, Message function is received, the function that PA business personnel individually has is release tasks function, and the function that recommendation person individually has is to recommend Task function, the function that third party business personnel individually has are the function that receives an assignment, and the function that PA administrator individually has is pipe Manage task function, then realize above-mentioned function have corresponding code, send message function codes, receive message function codes, Release tasks function code recommends task functional code, the function code that receives an assignment, management role function code, and transmission is disappeared Cease function code, receive message function codes as public calling code, by release tasks function code, recommend task code, Function code, management role function code receive an assignment as object reference code.
As can be seen that in the embodiment of the present application, electronic equipment obtains the source code of target application, the source generation is parsed Code uses object to obtain the multiple of the target application;Multiple use objects are then based on to decouple source code for public tune With code and object reference code.Compared to the source code before decoupling, only comprising public calling generation in the source code that decouples Code and object reference code eliminate in the source code before decoupling and repeat the public calling code write, so that after decoupling Source code it is more succinct, it is readable strong.During later maintenance, it is only necessary to the public calling code safeguarded of needs or Object reference code is readjusted, and is not needed to carry out big change to the general frame of source code, is reduced maintenance process In difficulty, to improve the maintainability of source code.
In the implementation of the application, the source code is decoupled as public calling using object based on the multiple After code and object reference code, the method also includes:
All second codes are mutually matched, to obtain matching result, the matching result includes M first With successfully recording, each first successful match record includes using the mark of identical at least two second code of object, each First successful match records a corresponding sub- object reference code, and the M is positive integer;
Based on each first successful match record deletion, its corresponding subobject calls multiple first objects in code the The case where two codes, each subobject after deletion calls code to match there is no any two second code, each first The mark at least two second code for including in successful match record includes its corresponding the multiple first object the The mark of two codes.
For example, object reference code includes that subobject calls code 1, subobject that code 2, subobject is called to call generation Code 3;It includes second code A11, second code B11, second code C11, second code A12 that subobject, which calls code 1,;Subobject Calling code 2 includes second code C21, second code D21, second code E21;It includes second code that subobject, which calls code 3, B31, second code F31, second code G31.Matching result, matching knot are obtained after all second codes are mutually matched Include first successful match record: A11 and A12 in fruit, then delete subobject call second code A11 in code 1 or Second code A12.
In the implementation of the application, the matching result further includes that N number of second successful match records, and each second It include using the mark of at least two different second codes of object with successfully record, the N is positive integer, and the method is also wrapped It includes:
One of mark in the mark at least two second code for including in each second successful match record Know corresponding second code to be moved in the public calling code, and the institute that will include in each second successful match record It states in the mark of at least two second codes except one of them described corresponding second code of mark is deleted.
For example, object reference code includes that subobject calls code 1, subobject that code 2, subobject is called to call generation Code 3;It includes second code A11, second code B11, second code C11, second code A12 that subobject, which calls code 1,;Subobject Calling code 2 includes second code C21, second code D21, second code E21;It includes second code that subobject, which calls code 3, B31, second code F31, second code G31.Matching result, matching knot are obtained after all second codes are mutually matched Include the second successful match record in fruit: B11 and B31 then deletes second code B11 or second code B31, then will remain Remaining second code B11 or second code B31 is moved in public calling code.
Further, in the mark at least two second code that will include in each second successful match record The corresponding second code of one of mark be moved in the public calling code after, the method also includes:
In the mark at least two second code that will include in each second successful match record except it is described wherein The corresponding second code of one mark is associated with using object to one of them described corresponding second code of mark.
It include one in matching result for example, obtaining matching result after all second codes are mutually matched A second successful match record: B11 and B31 then deletes second code B11 or second code B31, then by the remaining second generation Code B11 or second code B31 is moved in public calling code.If the second code deleted is B11, by second code B11 Be associated with to second code B31 using object so that the use that second code B31 both can be original by second code B31 Object reference, can also be by the use object reference of second code B11 originally.
In the implementation of the application, the source code is decoupled as public calling using object based on the multiple After code and object reference code, the method also includes:
Code call instruction is received, the code call instruction carries the type of code of request call;
If the type of code of the request call is public calling type of code, the first response instruction is sent, described the One response instruction carries at least one public calling code present in the electronic equipment;
If the type of code of the request call is object reference type of code, it is determined that the code call instruction request The first object of code is called to use object;The second response instruction is sent, the second response instruction carries the first object Code is called using the corresponding subobject of object.
Specifically, the first object of the determination code call instruction request call code uses the one specific of object Implementation are as follows: determine the transmitting terminal electronic equipment of the code call instruction;Transmitting terminal based on the code call instruction Electronic equipment determines that the first object of the code call instruction request call code uses object.
Illustrate, it is assumed that target application attracts customers for PA, the PA attract customers using object include it is following at least one: PA Business personnel, recommendation person, third party business personnel, PA administrator, if the electronics that electronics end sending device is PA business personnel end is set It is standby, it is determined that first object is PA business personnel using object, and first object is recommendation person, third party business personnel, PA using object The method of determination of administrator is the same as PA business personnel.It should be noted that the method for determination of transmitting terminal electronic equipment can be existed by identification The account information of target application determines on the transmitting terminal electronic equipment.
In the implementation of the application, the source code is decoupled as public calling using object based on the multiple After code and object reference code, the method also includes:
When receiving the increase code command for carrying third code, determine the third code uses object;
If the quantity using object of the third code is greater than or equal to 2, the third code is moved to described In public calling code;
If the quantity using object of the third code is 1 and the multiple of the target application use object including described The third code is then moved to the corresponding subobject tune of use object of the third code by the use object of third code With in code;
If the quantity using object of the third code does not include institute for multiple use objects of 1 and the target application That states third code uses object, then creates a sub- object reference code and be moved to the third code described newly-built Subobject call code in.
It should be noted that it is the case where code development increases using object in the process that above-described embodiment is corresponding.If It in development process, needs to increase a function, then it needs to be determined that realizing the code of the function, is then determined to call the code Use object, if using number of objects be greater than or equal to 2 if can directly determine the code be public calling code;If using pair As there was only 1, then need whether further previous multiple use objects include that this can be direct if including using object The code is sorted out to its corresponding subobject and is called in code, if not including, need a newly-built sub- object reference code with And the code moving to newly-built subobject is called in code.
In the implementation of the application, the source code is decoupled as public calling using object based on the multiple After code and object reference code, the method also includes:
Dissociation instruction is received, the dissociation instruction is used to release the second target and uses object and forth generation code Association, second target are that the multiple one using in object uses object using object, and the forth generation code is institute A first code in multiple first codes that public calling code includes is stated, the forth generation code includes institute using object It states the second target and uses object using object and third target;
The forth generation code is moved to the third target to call in code using the subobject of object.
It should be noted that it is the case where code development is reduced using object in the process that above-described embodiment is corresponding, if the Four codes are greater than 2 using object, then release one of using after being associated with of object and forth generation code, which remains Remaining associated use object is still greater than or is equal to 2, so the forth generation code remains a public calling code, is not required to make as above Processing.
In the implementation of the application, the source code is decoupled as public calling using object based on the multiple After code and object reference code, the method also includes:
The public calling code and the object reference code are compiled, the public calling code after compiling and described The permission of object reference code is run by the target application.
It is consistent with the embodiment shown in FIG. 1, referring to Fig. 2, Fig. 2 is another generation provided by the embodiments of the present application Code decoupling method, is applied to electronic equipment, which comprises
Step 201: obtaining the source code of target application.
Step 202: parsing the source code, use object to obtain the multiple of the target application.
Step 203: being decoupled the source code for public calling code and object reference using object based on the multiple Code, the public calling code includes multiple first codes, and each first code allows by the multiple using in object At least two use object reference, and the object reference code includes that multiple subobjects call code, and each subobject calls generation Code includes multiple second codes, and multiple second codes that subobject calls code i to include only allow to call generation by the subobject Code i is associated to use object reference, the subobject call code i be the multiple subobject call in code wherein one It is a.
Step 204: all second codes being mutually matched, to obtain matching result, the matching result includes M A first successful match record, each first successful match record include the mark using identical at least two second code of object Know, each first successful match records a corresponding sub- object reference code, and the M is positive integer.
Step 205: based on each first successful match record deletion, its corresponding subobject calls multiple the in code The case where one target second code, each subobject after deletion calls code to match there is no any two second code, The mark at least two second code for including in each first successful match record include its corresponding the multiple the The mark of one target second code.
Step 206: the matching result further includes N number of second successful match record, each second successful match record packet The mark using at least two different second codes of object is included, the N is positive integer, will be in each second successful match record Including at least two second code mark in the corresponding second code of one of mark be moved to it is described public It calls in code.
Step 207: will be removed in the mark at least two second code for including in each second successful match record One of them described corresponding second code of mark is deleted.
Step 208: receiving code call instruction, the code call instruction carries the type of code of request call.
Step 209: if the type of code of the request call is public calling type of code, sending the first response and refer to It enables, the first response instruction carries at least one public calling code present in the electronic equipment.
Step 210: if the type of code of the request call is object reference type of code, it is determined that the code calls Instruction request calls the first object of code using object and sends the second response instruction, and the second response instruction carries institute It states first object and calls code using the corresponding subobject of object.
Step 211: when receiving the increase code command for carrying third code, determining the use pair of the third code As.
Step 212: if the quantity using object of the third code is greater than or equal to 2, the third code being moved It moves into the public calling code.
Step 213: if the quantity using object of the third code is 1 and the multiple of the target application use object Object is used including the third code, then the third code is moved to the corresponding using object of the third code Subobject calls in code.
Step 214: if the quantity using object of the third code is 1 and the multiple of the target application use object Do not include the third code using object, then creates a sub- object reference code and be moved to the third code The newly-built subobject calls in code.
Step 215: receiving dissociation instruction, the dissociation instruction uses object and for releasing the second target The association of four codes, second target using object be the multiple one using in object use object, the described 4th Code is a first code in multiple first codes that the public calling code includes, the use pair of the forth generation code Object is used using object and third target as including second target.
Step 216: the forth generation code being moved to the third target and is called in code using the subobject of object.
Step 217: compiling the public calling code and the object reference code, the public calling generation after compiling Code and object reference code permission are run by the target application.
It should be noted that step 208-210 can be before step 211, it can also be after step 211;Step 211-214 can be before step 208, can also be after step 216;Step 214 and step 215 can before 208, Can be after 208, the specific implementation process of the present embodiment can be found in specific implementation process described in above method embodiment, This is no longer described.
It is consistent with above-mentioned Fig. 1 and embodiment shown in Fig. 2, referring to Fig. 3, Fig. 3 is provided by the embodiments of the present application one The structural schematic diagram of kind electronic equipment, including processor, memory, communication interface and one or more programs, wherein above-mentioned One or more programs are stored in above-mentioned memory, and are configured to be executed by above-mentioned processor, and above procedure includes using In the instruction for executing following steps:
Obtain the source code of target application;
The source code is parsed, uses object to obtain the multiple of the target application;
The source code is decoupled as public calling code and object reference code using object based on the multiple, it is described Public calling code includes multiple first codes, and each first code permission is made by the multiple at least two using in object With object reference, the object reference code includes that multiple subobjects call code, and it includes multiple that each subobject, which calls code, Second code, subobject call code i multiple second codes for including only to allow to be called by the subobject code i is associated to be made With object reference, it is one of them in the multiple subobject calling code that the subobject, which calls code i,.
As can be seen that in the embodiment of the present application, electronic equipment obtains the source code of target application, the source generation is parsed Code uses object to obtain the multiple of the target application;Multiple use objects are then based on to decouple source code for public tune With code and object reference code.Compared to the source code before decoupling, only comprising public calling generation in the source code that decouples Code and object reference code eliminate in the source code before decoupling and repeat the public calling code write, so that after decoupling Source code it is more succinct, it is readable strong.During later maintenance, it is only necessary to the public calling code safeguarded of needs or Object reference code is readjusted, and is not needed to carry out big change to the general frame of source code, is reduced maintenance process In difficulty, to improve the maintainability of source code.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple With code and object reference code, the public calling code includes multiple first codes, and each first code allows described Multiple at least two using in object use object reference, and the object reference code includes that multiple subobjects call code side Face, above procedure include the instruction specifically for executing following steps:
The source code is divided by function as multiple component codes;
Determine that each component code allows called use object;
If the quantity using object that component code j allows to call is greater than or equal to 2, it is determined that the component code j is A first code in the public calling code;
If the quantity using object that the component code allows to call is 1, it is determined that the component code j is permitted by it That calls perhaps calls a second code in code using the corresponding subobject of object.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, above procedure includes the instruction for being also used to execute following steps:
All second codes are mutually matched, to obtain matching result, the matching result includes M first With successfully recording, each first successful match record includes using the mark of identical at least two second code of object, each First successful match records a corresponding sub- object reference code, and the M is positive integer;
Based on each first successful match record deletion, its corresponding subobject calls multiple first objects in code the The case where two codes, each subobject after deletion calls code to match there is no any two second code, each first The mark at least two second code for including in successful match record includes its corresponding the multiple first object the The mark of two codes.
In the implementation of the application, the matching result further includes that N number of second successful match records, and each second Successful match record includes using the mark of at least two different second codes of object, and the N is positive integer, above procedure packet Include the instruction for being also used to execute following steps:
By one of them in the mark at least two second code for including in each second successful match record It identifies corresponding second code to be moved in the public calling code, and will include in each second successful match record Except one of them described corresponding second code of mark is deleted in the mark of at least two second code.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, above procedure includes the instruction for being also used to execute following steps:
Code call instruction is received, the code call instruction carries the type of code of request call;
If the type of code of the request call is public calling type of code, the first response instruction is sent, described the One response instruction carries at least one public calling code present in the electronic equipment;
If the type of code of the request call is object reference type of code, it is determined that the code call instruction request The first object of code is called to use object;The second response instruction is sent, the second response instruction carries the first object Code is called using the corresponding subobject of object.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, above procedure includes the instruction for being also used to execute following steps:
When receiving the increase code command for carrying third code, determine the third code uses object;
If the quantity using object of the third code is greater than or equal to 2, the third code is moved to described In public calling code;
If the quantity using object of the third code is 1 and the multiple of the target application use object including described The third code is then moved to the corresponding subobject tune of use object of the third code by the use object of third code With in code;
If the quantity using object of the third code does not include institute for multiple use objects of 1 and the target application That states third code uses object, then creates a sub- object reference code and be moved to the third code described newly-built Subobject call code in.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, above procedure includes the instruction for being also used to execute following steps:
Dissociation instruction is received, the dissociation instruction is used to release the second target and uses object and forth generation code Association, second target are that the multiple one using in object uses object using object, and the forth generation code is institute A first code in multiple first codes that public calling code includes is stated, the forth generation code includes institute using object It states the second target and uses object using object and third target;
The forth generation code is moved to the third target to call in code using the subobject of object.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, above procedure includes the instruction for being also used to execute following steps:
The public calling code and the object reference code are compiled, the public calling code after compiling and described The permission of object reference code is run by the target application.
It should be noted that the specific implementation process of the present embodiment can be found in specific implementation described in above method embodiment Process no longer describes herein.
Above-described embodiment is mainly described the scheme of the embodiment of the present application from the angle of method side implementation procedure.It can With understanding, in order to realize the above functions, it comprises execute the corresponding hardware configuration of each function and/or soft for electronic equipment Part module.Those skilled in the art should be readily appreciated that, described in conjunction with the examples disclosed in the embodiments of the present disclosure Unit and algorithm steps, the application can be realized with the combining form of hardware or hardware and computer software.Some function is studied carefully Unexpectedly it is executed in a manner of hardware or computer software driving hardware, the specific application and design constraint depending on technical solution Condition.Professional technician can specifically realize described function to each using distinct methods, but this It realizes it is not considered that exceeding scope of the present application.
The embodiment of the present application can carry out the division of functional unit according to the method example to electronic equipment, for example, can With each functional unit of each function division of correspondence, two or more functions can also be integrated in a processing unit In.The integrated unit both can take the form of hardware realization, can also realize in the form of software functional units.It needs It is noted that be schematical, only a kind of logical function partition to the division of unit in the embodiment of the present application, it is practical real It is current that there may be another division manner.
It is below the application Installation practice, the application Installation practice is realized for executing the application embodiment of the method Method.Referring to Fig. 4, a kind of code decoupling device provided by the embodiments of the present application, is applied to electronic equipment, described device packet It includes:
Acquiring unit 401, for obtaining the source code of target application;
Resolution unit 402 uses object for parsing the source code to obtain the multiple of the target application;
Decoupling unit 403, for based on it is the multiple using object by the source code decouple for public calling code with Object reference code, the public calling code includes multiple first codes, and each first code allows by the multiple use At least two in object use object reference, and the object reference code includes that multiple subobjects call code, every height pair It include multiple second codes as calling code, it is right by the son that multiple second codes that subobject calls code i to include only allow As calling code i is associated to use object reference, it is that the multiple subobject calls in code that the subobject, which calls code i, One of them.
As can be seen that in the embodiment of the present application, electronic equipment obtains the source code of target application, the source generation is parsed Code uses object to obtain the multiple of the target application;Multiple use objects are then based on to decouple source code for public tune With code and object reference code.Compared to the source code before decoupling, only comprising public calling generation in the source code that decouples Code and object reference code eliminate in the source code before decoupling and repeat the public calling code write, so that after decoupling Source code it is more succinct, it is readable strong.During later maintenance, it is only necessary to the public calling code safeguarded of needs or Object reference code is readjusted, and is not needed to carry out big change to the general frame of source code, is reduced maintenance process In difficulty, to improve the maintainability of source code.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple With code and object reference code, the public calling code includes multiple first codes, and each first code allows described Multiple at least two using in object use object reference, and the object reference code includes that multiple subobjects call code side Face, the decoupling unit 403, is specifically used for:
The source code is divided by function as multiple component codes;
Determine that each component code allows called use object;
If the quantity using object that component code j allows to call is greater than or equal to 2, it is determined that the component code j is A first code in the public calling code;
If the quantity using object that the component code allows to call is 1, it is determined that the component code j is permitted by it That calls perhaps calls a second code in code using the corresponding subobject of object.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, described device further includes matching unit 404 and deletion unit 405, in which:
The matching unit 404, it is described to obtain matching result for all second codes to be mutually matched Matching result includes M the first successful match records, and each first successful match record includes using object identical at least two The mark of a second code, each first successful match record a corresponding sub- object reference code, and the M is positive integer;
The deletion unit 405 calls generation for its corresponding subobject based on each first successful match record deletion Multiple first object second codes in code, each subobject after deletion call code that any two second code phase is not present The mark of the case where matching, at least two second code for including in each first successful match record include that its is corresponding The mark of the multiple first object second code.
In the implementation of the application, the matching result further includes that N number of second successful match records, and each second Successful match record includes using the mark of at least two different second codes of object, and the N is positive integer, and described device is also Including mobile unit 406, the mark of at least two second code for that will include in each second successful match record In the corresponding second code of one of mark be moved in the public calling code;
The deletion unit 405 is also used to will include in each second successful match record described at least two second Except one of them described corresponding second code of mark is deleted in the mark of code.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, described device further includes communication unit 407 and determination unit 408, in which:
The communication unit 407, for receiving code call instruction, the code call instruction carries the generation of request call Code type;If the type of code of the request call is public calling type of code, sends the first response and instruct, described first Response instruction carries at least one public calling code present in the electronic equipment;
The determination unit 408 is used for, if the type of code of the request call is object reference type of code, it is determined that The first object of the code call instruction request call code uses object;
The communication unit 407, is also used to send the second response instruction, and the second response instruction carries first mesh Mark calls code using the corresponding subobject of object.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, the determination unit 408 is also used to receiving the increase code for carrying third code When instruction, determine that the second of the third code uses object;
The mobile unit 406 will if the quantity using object for being also used to the third code is greater than or equal to 2 The third code is moved in the public calling code;If the quantity using object of the third code is 1 and described The multiple of target application using object include that the third code uses object, then the third code are moved to described the Three codes are called in code using the corresponding subobject of object;
Described device further includes creating unit 409, if the quantity using object for the third code is 1 and described The multiple of target application do not include that the third code uses object using object, then create a sub- object reference code; The mobile unit 406 is also used to for the third code being moved to the newly-built subobject and calls in code.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, the communication unit 407 is also used to receive dissociation instruction, the disassociation Instruction is made for releasing the second target being associated with using object and forth generation code, second target using object to be the multiple Object is used with one in object, the forth generation code is one in multiple first codes that the public calling code includes A first code, the forth generation code includes that second target uses object and third target to use object using object;
The mobile unit 406 is also used to for the forth generation code being moved to the described second subobject tune for using object With in code.
In the implementation of the application, the source code is decoupled as public tune using object based on the multiple After code and object reference code, described device further includes compilation unit 410, for compile the public calling code and The object reference code, the public calling code and the object reference code after compiling allow by the target application Operation.
It should be noted that acquiring unit 401, resolution unit 402, decoupling unit 403, matching unit 404, deletion unit 405, mobile unit 406, determination unit 408, creating unit 409 and compilation unit 410 can be realized by processor, communication unit 407 can be realized by communication interface.
The embodiment of the present application also provides a kind of computer storage medium, wherein the computer storage medium is stored for depositing Store up computer program, the computer program be executed by processor as in above method embodiment record either method part or Overall Steps.
The embodiment of the present application also provides a kind of computer program product, and above-mentioned computer program product includes storing calculating The non-transient computer readable storage medium of machine program, above-mentioned computer program are operable to that computer is made to execute such as above-mentioned side Some or all of either record method step in method embodiment.The computer program product can be a software installation Packet.
It should be noted that for the various method embodiments described above, for simple description, therefore, it is stated as a series of Combination of actions, but those skilled in the art should understand that, the application is not limited by the described action sequence because According to the application, some steps may be performed in other sequences or simultaneously.Secondly, those skilled in the art should also know It knows, the embodiments described in the specification are all preferred embodiments, related actions and modules not necessarily the application It is necessary.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, there is no the portion being described in detail in some embodiment Point, reference can be made to the related descriptions of other embodiments.
In several embodiments provided herein, it should be understood that disclosed device, it can be by another way It realizes.For example, the apparatus embodiments described above are merely exemplary, such as the division of said units, it is only a kind of Logical function partition, there may be another division manner in actual implementation, such as multiple units or components can combine or can To be integrated into another system, or some features can be ignored or not executed.Another point, shown or discussed is mutual Coupling, direct-coupling or communication connection can be through some interfaces, the indirect coupling or communication connection of device or unit, It can be electrical or other forms.
Above-mentioned unit as illustrated by the separation member may or may not be physically separated, aobvious as unit The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme 's.
It, can also be in addition, each functional unit in each embodiment of the application can integrate in one processing unit It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of software functional units.
If above-mentioned integrated unit is realized in the form of SFU software functional unit and sells or use as independent product When, it can store in a computer-readable access to memory.Based on this understanding, the technical solution of the application substantially or Person says that all or part of the part that contributes to existing technology or the technical solution can body in the form of software products Reveal and, which is stored in a memory, including some instructions are used so that a computer equipment (can be personal computer, server or network equipment etc.) executes all or part of each embodiment above method of the application Step.And memory above-mentioned includes: USB flash disk, read-only memory (ROM, Read-Only Memory), random access memory The various media that can store program code such as (RAM, Random Access Memory), mobile hard disk, magnetic or disk.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of above-described embodiment is can It is completed with instructing relevant hardware by program, which can store in a computer-readable memory, memory May include: flash disk, read-only memory (English: Read-Only Memory, referred to as: ROM), random access device (English: Random Access Memory, referred to as: RAM), disk or CD etc..
The embodiment of the present application is described in detail above, specific case used herein to the principle of the application and Embodiment is expounded, the description of the example is only used to help understand the method for the present application and its core ideas; At the same time, for those skilled in the art can in specific embodiments and applications according to the thought of the application There is change place, in conclusion the contents of this specification should not be construed as limiting the present application.

Claims (10)

1. a kind of code decoupling method, which is characterized in that be applied to electronic equipment, which comprises
Obtain the source code of target application;
The source code is parsed, uses object to obtain the multiple of the target application;
The source code is decoupled as public calling code and object reference code using object based on the multiple, it is described public Calling code includes multiple first codes, and each first code allows by the multiple at least two uses pair using in object As calling, the object reference code includes that multiple subobjects call code, and it includes multiple second that each subobject, which calls code, Code, multiple second codes that subobject calls code i to include only allow to be called the associated use pair of code i by the subobject As calling, it is one of them in the multiple subobject calling code that the subobject, which calls code i,.
2. the method according to claim 1, wherein described use object by the source code based on the multiple Decoupling is public calling code and object reference code, and the public calling code includes multiple first codes, each first generation Code allows to use object reference by the multiple at least two using in object, and the object reference code includes that multiple sons are right As calling code, comprising:
The source code is divided by function as multiple component codes;
Determine that each component code allows called use object;
If the quantity using object that component code j allows to call is greater than or equal to 2, it is determined that the component code j is described A first code in public calling code;
If the quantity using object that the component code allows to call is 1, it is determined that the component code j is allowed to adjust by it A second code in code is called using the corresponding subobject of object.
3. method according to claim 1 or 2, which is characterized in that described to use object by the source based on the multiple After code decoupling is public calling code and object reference code, the method also includes:
All second codes are mutually matched, to obtain matching result, the matching result include M first matching at Function record, each first successful match record include using the mark of identical at least two second code of object each first Successful match records a corresponding sub- object reference code, and the M is positive integer;
Based on each first successful match record deletion, its corresponding subobject calls multiple first object second generations in code The case where code, each subobject after deletion calls code to match there is no any two second code, each first matching The mark at least two second code for including in success record includes its corresponding the multiple first object second generation The mark of code.
4. according to the method described in claim 3, it is characterized in that, the matching result further includes N number of second successful match note Record, each second successful match record includes using the mark of at least two different second codes of object, and the N is positive whole Number, the method also includes:
By one of mark in the mark at least two second code for including in each second successful match record Corresponding second code is moved in the public calling code, and will each second successful match record in include described in Except one of them described corresponding second code of mark is deleted in the mark of at least two second codes.
5. method according to claim 1-4, which is characterized in that described to use object by institute based on the multiple After source code decoupling is stated as public calling code and object reference code, the method also includes:
Code call instruction is received, the code call instruction carries the type of code of request call;
If the type of code of the request call is public calling type of code, the first response instruction, first sound are sent It should instruct and carry at least one public calling code present in the electronic equipment;
If the type of code of the request call is object reference type of code, it is determined that the code call instruction request call The first object of code uses object;The second response instruction is sent, the second response instruction carries the first object and uses The corresponding subobject of object calls code.
6. method according to claim 1-5, which is characterized in that described to use object by institute based on the multiple After source code decoupling is stated as public calling code and object reference code, the method also includes:
When receiving the increase code command for carrying third code, determine the third code uses object;
If the quantity using object of the third code is greater than or equal to 2, the third code is moved to described public It calls in code;
If the quantity using object of the third code is 1 and multiple use objects of the target application include the third The corresponding subobject of use object that the third code is moved to the third code is then called generation by the use object of code In code;
If the quantity using object of the third code is 1 and the multiple of the target application using objects do not include described the Three codes use object, then create a sub- object reference code and the third code is moved to the newly-built son In object reference code.
7. method according to claim 1-6, which is characterized in that described to use object by institute based on the multiple After source code decoupling is stated as public calling code and object reference code, the method also includes:
Dissociation instruction is received, the dissociation instruction is used to release the pass that the second target uses object and forth generation code Connection, second target are that the multiple one using in object uses object using object, and the forth generation code is described A first code in multiple first codes that public calling code includes, the forth generation code includes described using object Second target uses object using object and third target;
The forth generation code is moved to the third target to call in code using the subobject of object.
8. a kind of code decoupling device, which is characterized in that be applied to electronic equipment, described device includes:
Acquiring unit, for obtaining the source code of target application;
Resolution unit uses object for parsing the source code to obtain the multiple of the target application;
Decoupling unit, for being decoupled the source code for public calling code and object reference using object based on the multiple Code, the public calling code includes multiple first codes, and each first code allows by the multiple using in object At least two use object reference, and the object reference code includes that multiple subobjects call code, and each subobject calls generation Code includes multiple second codes, and multiple second codes that subobject calls code i to include only allow to call generation by the subobject Code i is associated to use object reference, the subobject call code i be the multiple subobject call in code wherein one It is a.
9. a kind of electronic equipment, which is characterized in that including processor, memory, communication interface, and one or more programs, One or more of programs are stored in the memory, and are configured to be executed by the processor, described program packet Include the instruction for executing the step in the method according to claim 1 to 7.
10. a kind of computer readable storage medium, which is characterized in that the computer readable storage medium is for storing computer Program, the computer program are executed by processor, to realize the method according to claim 1 to 7.
CN201910505108.9A 2019-06-12 2019-06-12 Code decoupling method and related equipment Active CN110333851B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910505108.9A CN110333851B (en) 2019-06-12 2019-06-12 Code decoupling method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910505108.9A CN110333851B (en) 2019-06-12 2019-06-12 Code decoupling method and related equipment

Publications (2)

Publication Number Publication Date
CN110333851A true CN110333851A (en) 2019-10-15
CN110333851B CN110333851B (en) 2023-06-16

Family

ID=68141098

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910505108.9A Active CN110333851B (en) 2019-06-12 2019-06-12 Code decoupling method and related equipment

Country Status (1)

Country Link
CN (1) CN110333851B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131025A (en) * 2020-09-28 2020-12-25 平安养老保险股份有限公司 Component transmission method and device, computer equipment and storage medium
CN113220336A (en) * 2020-01-21 2021-08-06 腾讯科技(深圳)有限公司 Code processing method, device, medium and electronic equipment
CN117033287A (en) * 2023-10-08 2023-11-10 易方信息科技股份有限公司 Multi-bus communication method, system, equipment and storage medium based on SDK (software development kit) package

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6658425B1 (en) * 1998-03-16 2003-12-02 International Business Machines Corporation Generic data centric object structure and implementation
CN105892997A (en) * 2016-03-31 2016-08-24 北京奇虎科技有限公司 Code control method and device
CN108021360A (en) * 2016-11-04 2018-05-11 华为技术有限公司 Rules process method, code process method and relevant device
CN108491209A (en) * 2018-02-23 2018-09-04 厦门集微科技有限公司 The extracting method and device of common code in a kind of html pages
US20190171426A1 (en) * 2016-07-21 2019-06-06 Sony Interactive Entertainment Inc. Program compiler and linker, and method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6658425B1 (en) * 1998-03-16 2003-12-02 International Business Machines Corporation Generic data centric object structure and implementation
CN105892997A (en) * 2016-03-31 2016-08-24 北京奇虎科技有限公司 Code control method and device
US20190171426A1 (en) * 2016-07-21 2019-06-06 Sony Interactive Entertainment Inc. Program compiler and linker, and method
CN108021360A (en) * 2016-11-04 2018-05-11 华为技术有限公司 Rules process method, code process method and relevant device
CN108491209A (en) * 2018-02-23 2018-09-04 厦门集微科技有限公司 The extracting method and device of common code in a kind of html pages

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
黄洲 等: "基于静态代码分析的自动化对象行为协议提取工具", 计算机科学, no. 08, pages 175 - 179 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113220336A (en) * 2020-01-21 2021-08-06 腾讯科技(深圳)有限公司 Code processing method, device, medium and electronic equipment
CN112131025A (en) * 2020-09-28 2020-12-25 平安养老保险股份有限公司 Component transmission method and device, computer equipment and storage medium
CN117033287A (en) * 2023-10-08 2023-11-10 易方信息科技股份有限公司 Multi-bus communication method, system, equipment and storage medium based on SDK (software development kit) package
CN117033287B (en) * 2023-10-08 2024-02-13 易方信息科技股份有限公司 Multi-bus communication method, system, equipment and storage medium based on SDK (software development kit) package

Also Published As

Publication number Publication date
CN110333851B (en) 2023-06-16

Similar Documents

Publication Publication Date Title
CN110333851A (en) Code decoupling method and relevant device
CN110119292B (en) System operation parameter query method, matching method, device and node equipment
US20060168581A1 (en) Software deployment system
CN110519711A (en) A kind of information push method, device, storage medium and server
CN108376544B (en) Information processing method, device, equipment and computer readable storage medium
CN109818848A (en) Methods of exhibiting and device, storage medium, the electronic device of session
CN105224421B (en) Data backup method and device and electronic equipment
CN110650503B (en) Network access method, device, system and computer readable storage medium
CN112363845A (en) Data synchronization method of system integration middling station and integration middling station system
CN109582873A (en) Method and apparatus for pushed information
CN111221630A (en) Business process processing method, device, equipment, readable storage medium and system
CN109683992B (en) Method and apparatus for managing objects
CN109561134A (en) Electronic device, distributed type assemblies service distribution method and storage medium
CN110275701A (en) Data processing method, device, medium and calculating equipment
CN113672205B (en) Workflow framework based on business event driving
CN110399131A (en) Improve method, apparatus, the computer equipment of application program stability
CN109271543A (en) Display methods, device, terminal and the computer readable storage medium of thumbnail
CN105763511B (en) A kind of method for processing business and communication system
US9936015B2 (en) Method for building up a content management system
CN106874004A (en) The method and client and server of lowest version software compatibility highest version file
CN111026355A (en) Information interaction method and device, computer equipment and computer readable storage medium
CN110297639A (en) Method and apparatus for detecting code
CN109509467A (en) Code generating method and device
CN109361730A (en) Card information acquisition methods, system and Cloud Server based on face
CN112311931B (en) Method and device for processing contact information at terminal and electronic equipment

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
GR01 Patent grant
GR01 Patent grant