Electronic device and method for managing code

The method addresses the challenge of identifying and managing dead code by monitoring execution frequency and performing targeted deletions, enhancing code management efficiency and resource optimization.

WO2024248200A1PCT designated stage expired Publication Date: 2024-12-05COUPANG CORP
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/KR2023/007763
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-06-01
Filing Date
2023-06-07
Publication Date
2024-12-05

AI Technical Summary

Technical Problem

Existing code management technologies fail to identify and remove dead code effectively, even when linked references exist, leading to inefficiencies in capacity and time due to accumulated unused or rarely executed code.

Method used

A method that checks the execution frequency of nodes in source code by inserting test code and monitoring log records, determining a level based on execution frequency, and managing code sets accordingly, including deleting dead code if it meets certain conditions, while also performing code coverage tests and visualizing data through an integrated development environment.

Benefits of technology

Effectively identifies and manages dead code based on execution frequency, optimizing system resources by removing unused code and ensuring accurate classification of essential and non-essential code blocks, thereby improving efficiency and reducing storage needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure KR2023007763_05122024_PF_FP_ABST
    Figure KR2023007763_05122024_PF_FP_ABST
Patent Text Reader

Abstract

A method by which an electric device manages a code, according to one embodiment of the present disclosure, may comprise the steps of: checking information about a plurality of nodes in a source code; checking at least one entry node from among the plurality of nodes; checking execution frequency of the at least one entry node; and checking, on the basis of the execution frequency of the at least one entry node, a code set to be managed in the source code.
Need to check novelty before this filing date? Find Prior Art

Description

Electronic devices and methods for managing codes

[0001] The present disclosure relates to a technique for managing code, and more particularly, to a technique for identifying and removing dead code based on the execution frequency of the code.

[0002] If unused or rarely executed code is not removed from source code, this accumulation can lead to inefficiencies in terms of both capacity and time. Conventional techniques identify and remove unused code without associated references. However, some code, despite having associated references, is either never executed or rarely executed (i.e., dead code), and this problem persists in that such code is not removed through the aforementioned techniques.

[0003] According to one embodiment of the present disclosure, a technical problem is to identify dead codes based on the execution frequency of the codes and to manage the dead codes.

[0004] A method for managing code in an electronic device according to one embodiment of the present disclosure may include: checking information on a plurality of nodes in source code; checking at least one entry node among the plurality of nodes; checking an execution frequency of the at least one entry node; and checking a code set to be managed among the source code based on the execution frequency of the at least one entry node.

[0005] The step of checking the execution frequency of the at least one entry node according to one embodiment may include the step of inserting a test code for measuring the execution frequency into the at least one entry node; the step of checking a log record of the test code for a set period of time; and the step of checking the execution frequency of the at least one entry node according to the log record of the test code.

[0006] A method for managing code according to one embodiment may further include a step of determining a level of at least one entry node based on an execution frequency of the at least one entry node, and the step of identifying the set of codes to be managed may be a step of identifying the set of codes to be managed among the source codes based on the level of the at least one entry node.

[0007] According to one embodiment, the step of checking the execution frequency of the at least one entry node is performed repeatedly multiple times, and the interval for checking the execution frequency of the at least one entry node can be determined based on the level of the at least one entry node.

[0008] A method for managing code according to one embodiment may further include the steps of: identifying a set of codes to be managed as dead codes; and, if the dead code corresponds to a set deletion condition, deleting the dead code.

[0009] A method for managing code according to one embodiment may further include the steps of: obtaining a call to the deleted dead code; and recovering the deleted dead code.

[0010] A method for managing code according to one embodiment further includes a step of performing a code coverage test on the source code, wherein a threshold for passing the code coverage test of the at least one entry node can be determined based on a level of the at least one entry node.

[0011] The step of identifying the set of codes to be managed according to one embodiment may include: identifying a first entry node having an execution frequency less than a set threshold; identifying at least one first sub-node associated with the first entry node; and identifying codes corresponding to the first entry node and the at least one first sub-node as the set of codes to be managed.

[0012] The step of identifying the set of codes to be managed according to one embodiment may further include the step of identifying at least one second sub-node associated with a second entry node whose execution frequency is greater than or equal to the threshold value among the at least one first sub-node; and the step of excluding the code corresponding to the at least one second sub-node from the set of codes to be managed.

[0013] A method for managing code according to one embodiment further includes a step of generating data of a graph structure for the source code, and the step of checking information about the plurality of nodes may be a step of checking information about the plurality of nodes included in the data of the graph structure.

[0014] A method for managing code according to one embodiment may further include the steps of determining properties of the plurality of nodes based on the execution frequency of the at least one entry node; and the step of displaying data of the graph structure in which the properties of the plurality of nodes are reflected through an integrated development environment.

[0015] According to one embodiment, the properties of the plurality of nodes may include at least one of the sizes or colors of the plurality of nodes.

[0016] A method for managing code according to one embodiment may further include a step of obtaining an execution request of the source code, and the step of checking information about the plurality of nodes may be a step of checking information about the plurality of nodes based on a structure of a program called according to the execution request.

[0017] The step of verifying information about the plurality of nodes according to one embodiment may include a step of verifying a class, field, or function included in the source code based on the structure of a program called according to the execution request; and a step of verifying the verified class, field, or function with the plurality of nodes.

[0018] According to one embodiment, at least one entry node may include a top-level class, a field dependent on an external server, or a function dependent on an external server.

[0019] A method for managing code according to one embodiment may further include the steps of adding a code block to the source code; and, if an execution frequency for the code block is not measured until a predetermined period of time has elapsed from the time the code block is added, identifying the code block as dead code.

[0020] An electronic device according to one embodiment of the present disclosure includes a communication circuit communicatively connected to a terminal; one or more processors; and one or more memories storing one or more instructions, wherein the one or more processors are configured to, by executing the one or more instructions, check information on a plurality of nodes in a source code, check at least one entry node among the plurality of nodes, check an execution frequency of the at least one entry node, and check a code set to be managed among the source codes based on the execution frequency of the at least one entry node.

[0021] According to one embodiment of the present disclosure, dead code can be identified and managed based on the execution frequency of the code.

[0022] FIG. 1 is a block diagram of an electronic device according to one embodiment of the present disclosure.

[0023] FIG. 2 is a diagram for explaining the operation between an electronic device and a terminal according to one embodiment of the present disclosure.

[0024] FIG. 3 is a processing flowchart of an electronic device according to one embodiment of the present disclosure.

[0025] Figures 4a and 4b are graphs of source code according to one embodiment of the present disclosure.

[0026] FIG. 5 is a graph of source code according to one embodiment of the present disclosure.

[0027] FIG. 6 is a processing flowchart of an electronic device according to one embodiment of the present disclosure.

[0028] FIG. 7 is a diagram visualizing source code according to one embodiment of the present disclosure.

[0029] The terms used in the embodiments have been selected from widely used and common terms, taking into account the functions of the present disclosure. However, these terms may vary depending on the intentions of those skilled in the art, precedents, the emergence of new technologies, etc. Furthermore, in certain cases, terms may be arbitrarily selected by the applicant, in which case their meanings will be described in detail in the relevant description. Therefore, the terms used in this disclosure should not be defined simply as names of terms, but rather based on the meanings of the terms and the overall content of the present disclosure.

[0030] When a part of the specification is said to "include" a component, this does not exclude other components, but rather implies the inclusion of other components, unless otherwise specifically stated. Furthermore, terms such as "part" and "module" used in the specification mean a unit that processes at least one function or operation, which may be implemented in hardware, software, or a combination of hardware and software.

[0031] The expression "at least one of a, b, and c" described throughout the specification may encompass 'a alone', 'b alone', 'c alone', 'a and b', 'a and c', 'b and c', or 'all of a, b, and c'.

[0032] The "terminal" mentioned below may be implemented as a computer or portable terminal that can connect to a server or other terminal via a network. Here, the computer includes, for example, a notebook, desktop, laptop, etc. equipped with a web browser, and the portable terminal may include, for example, a wireless communication device that guarantees portability and mobility, and may include all types of handheld-based wireless communication devices such as communication-based terminals such as IMT (International Mobile Telecommunication), CDMA (Code Division Multiple Access), W-CDMA (W-Code Division Multiple Access), LTE (Long Term Evolution), smartphones, tablet PCs, etc.

[0033] Below, embodiments of the present disclosure are described in detail with reference to the attached drawings so that those skilled in the art can easily implement the present disclosure. However, the present disclosure may be implemented in various different forms and is not limited to the embodiments described herein.

[0034] Hereinafter, embodiments of the present invention will be described in detail with reference to the attached drawings.

[0035] In describing the embodiments, descriptions of technical details that are well-known in the technical field to which the present invention pertains and are not directly related to the present invention will be omitted. This is to avoid obscuring the gist of the present invention by omitting unnecessary explanations and to convey it more clearly.

[0036] For the same reason, some components in the attached drawings are exaggerated, omitted, or schematically depicted. Furthermore, the dimensions of each component do not entirely reflect its actual size. Identical or corresponding components in each drawing are assigned the same reference numbers.

[0037] The advantages and features of the present invention, and the methods for achieving them, will become clearer with reference to the embodiments described in detail below together with the accompanying drawings. However, the present invention is not limited to the embodiments disclosed below and may be implemented in various different forms. These embodiments are provided only to ensure that the disclosure of the present invention is complete and to fully inform those skilled in the art of the scope of the invention, and the present invention is defined only by the scope of the claims. Like reference numerals designate like elements throughout the specification.

[0038] At this time, it will be understood that each block of the processing flow diagrams and combinations of the flow diagrams can be performed by computer program instructions. These computer program instructions can be installed in a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing equipment, so that the instructions executed by the processor of the computer or other programmable data processing equipment create a means for performing the functions described in the flow diagram block(s). These computer program instructions can also be stored in a computer-available or computer-readable memory that can direct a computer or other programmable data processing equipment to implement the functions in a specific manner, so that the instructions stored in the computer-available or computer-readable memory can also produce a manufactured item that includes an instruction means for performing the functions described in the flow diagram block(s). Since the computer program instructions may be installed on a computer or other programmable data processing device, a series of operational steps may be performed on the computer or other programmable data processing device to create a computer-executable process, and the instructions that cause the computer or other programmable data processing device to perform the steps for performing the functions described in the flowchart block(s) may also provide steps for performing the functions described in the flowchart block(s).

[0039] Additionally, each block may represent a module, segment, or portion of code that contains one or more executable instructions for performing a specific logical function(s). It should also be noted that in some alternative implementation examples, the functions described in the blocks may occur out of order. For example, two blocks depicted in succession may actually be executed substantially concurrently, or the blocks may sometimes be executed in reverse order, depending on their respective functions.

[0040] FIG. 1 is a block diagram of an electronic device (100) according to one embodiment of the present disclosure. The electronic device (100) may be a server that operates services related to e-commerce. The electronic device (100) may be a server that manages various programs (software) for operating the services. The electronic device (100) may be connected to a terminal in communication with the terminal to transmit and receive various information. The electronic device (100) may be a device that acquires various information related to the program, acquires it from the terminal, and provides it to the terminal or another device.

[0041] Referring to FIG. 1, an electronic device (100) according to one embodiment may include a processor (110), a memory (120), and a communication circuit (130). At least one of the components included in the electronic device (100) may be omitted, or another component may be added to the electronic device (100). Additionally or alternatively, some of the components may be implemented in an integrated manner, or may be implemented as a single or multiple entities. At least some of the components within the electronic device (100) may be connected to each other via a bus, a general purpose input / output (GPIO), a serial peripheral interface (SPI), or a mobile industry processor interface (MIPI), and may exchange data and / or signals.

[0042] According to one embodiment, the processor (110) of the electronic device (100) is a component that can perform calculations or data processing related to control and / or communication of each component of the electronic device (100), and can be operatively connected to the components of the electronic device (100). The processor (110) can load commands or data received from other components of the electronic device (100) into the memory (120), process the commands or data stored in the memory (120), and store result data. The memory (120) of the electronic device (100) according to one embodiment can store various data used by at least one component (e.g., the processor (110)). The memory (120) can store instructions for the operation of the processor (110) described above. The program can be stored as software in the memory (120) and can include, for example, an operating system, middleware, or an application.

[0043] According to one embodiment, the communication circuit (130) of the electronic device (100) can establish a wired or wireless communication channel with an external device (e.g., a terminal) and transmit and receive various data with the external device. The communication circuit (130) of the electronic device (100) can include at least one port for connecting to the external device via a wired cable in order to communicate with the external device via a wire. The communication circuit (130) of the electronic device (100) can be configured to be connected to a cellular network (e.g., 3G, LTE, 5G, Wibro, or Wimax) by including a cellular communication module. According to one embodiment, the communication circuit (130) of the electronic device (100) can include a short-range communication module to transmit and receive data with the external device using short-range communication (e.g., Wi-Fi, Bluetooth, Bluetooth Low Energy (BLE), UWB), but is not limited thereto.

[0044] FIG. 2 is a drawing for explaining the operation of an electronic device (100) and a terminal (200) according to one embodiment of the present disclosure.

[0045] An electronic device (100) according to one embodiment can communicate with a terminal (200) and transmit and receive various information. The terminal (200) can include a controller (210), a communication circuit (220), and a database (230). At least one of the components included in the terminal (200) may be omitted, or another component may be added to the terminal (200). At least some of the components within the terminal (200) can be connected to each other via a bus, GPIO, SPI, MIPI, or the like, to transmit and receive data and / or signals.

[0046] According to one embodiment, a controller (210) of a terminal (200) is a configuration capable of performing operations or data processing related to control and / or communication of each component of the terminal (200), and may be operatively connected to the components of the terminal (200). The controller (210) according to one embodiment may include a usage frequency collector (211) and a batch job builder (213).

[0047] According to one embodiment, the communication circuit (220) of the terminal (200) can establish a wired or wireless communication channel with an external device (e.g., the electronic device (100)) and transmit and receive various data with the external device. The communication circuit (220) of the terminal (200) may include at least one port for connecting to the external device via a wired cable in order to communicate with the external device via a wire. The communication circuit (220) of the terminal (200) may be configured to be connected to a cellular network (e.g., 3G, LTE, 5G, Wibro, or Wimax) by including a cellular communication module. The communication circuit (220) of the terminal (200) may also include a short-range communication module to transmit and receive data with the external device using short-range communication (e.g., Wi-Fi, Bluetooth, Bluetooth Low Energy (BLE), UWB), but is not limited thereto.

[0048] A terminal (200) according to one embodiment may store source code (205) for running a program. The source code (205) may be received from an electronic device (100) which is a server and stored in the terminal (200). The electronic device (100) may generate data in a graph structure for the source code (205) used in the program. The graph structure may be a structure representing relationships between objects constituting the data. The graph structure may include a plurality of nodes and a plurality of edges connecting the nodes. The graph disclosed in this document may refer to a directed graph. Although the present disclosure focuses on data in a graph structure, data in a tree structure may also be used.

[0049] Multiple nodes included in the data of the graph structure may represent classes, fields, or functions included in the source code (205). A class may refer to a framework for defining an object. An object may refer to data used in a program. A class may include fields indicating the state of an object and methods indicating the behavior of the object. Fields may refer to variables included in the class. A function may be a set of codes (or a block of codes) that performs a task with a specific purpose. In other words, each node may be composed of a set of codes for performing a specific function.

[0050] An electronic device (100) according to one embodiment can generate data in a graph structure for source code using a source code visualization tool. The source code visualization tool can, for example, perform syntax analysis using a parser as a preprocessing step to extract useful program information included in the source code, and generate an intermediate representation by performing the syntax analysis. The source code visualization tool can generate data in a graph structure by reading syntax information using an abstract syntax tree. In addition to the examples described above, the electronic device (100) can visualize source code using various source code visualization tools. A user can easily understand and analyze the source code using the visualized source code. That is, the electronic device (100) can identify classes, fields, or functions included in the source code using the source code visualization tool, and generate data in a graph structure with each identified class, field, or function as a node.

[0051] An electronic device (100) according to one embodiment can check information about a plurality of nodes in source code. Specifically, the electronic device (100) can check information about a plurality of nodes based on the structure of a server-side program called in response to a request for execution of the source code, and can check information about a plurality of nodes based on data of a graph structure for the source code. According to one embodiment, the electronic device (100) can obtain a request for execution of the source code, and check information about a plurality of nodes based on the structure of the program called in response to the execution request. For example, the electronic device (100) can check a class, field, or function included in the source code based on the structure of the program called in response to the execution request, and check the checked class, field, or function as a plurality of nodes. According to one embodiment, the electronic device (100) can also check a plurality of nodes included in data of a graph structure.

[0052] An electronic device (100) according to one embodiment may identify (determine) at least one entry node among a plurality of nodes. An entry node may refer to a dependent starting point between ends in an end-to-end manner. An entry node may also be called an entry point, an entry point, or an entry code. Whether or not a node corresponds to an entry node may be determined by a user or may be determined according to specific rules (e.g., class name, class hierarchy, or whether or not it depends on a server). A node primarily called by an external server may be determined to be an entry node. For example, the electronic device (100) may determine at least one node corresponding to a top-level class, a field dependent on an external server, or a function dependent on an external server, among a plurality of nodes included in data of a graph structure, as an entry node.

[0053] In order to check the execution frequency of at least one entry node, the electronic device (100) according to one embodiment may insert a test code for measuring the execution frequency into at least one entry node. For example, the processor (110) may insert the test code for measuring the execution frequency into a class corresponding to at least one entry node at the time of compilation. The electronic device (100) may transmit the source code in which the test code is inserted into at least one entry node to the terminal (200). The terminal (200) may compile the source code in which the test code is inserted into at least one entry node. According to another embodiment, the electronic device (100) may also insert the test code into at least one entry node of the source code stored in the terminal (200).

[0054] According to one embodiment, the usage frequency collection unit (211) may be configured to collect information on whether test code inserted into at least one entry node has been executed (used). The usage frequency collection unit (211) may be a software module. The usage frequency collection unit (211) may monitor how much the test code inserted into at least one entry node has been executed, thereby checking the execution frequency of at least one entry node. The usage frequency collection unit (211) may store the collected information in a database (230). A specific method for measuring the execution frequency of an entry node will be described later.

[0055] According to one embodiment, the database (230) of the terminal (200) can store various information (or data) under the control of the controller (210). The database (230) can store various information related to the program. In the present embodiment, the database (230) is described as being included in the terminal (200), but is not limited thereto, and the database (230) can be implemented outside the terminal (200) to exchange various data with the terminal (200). The database (230) can store information regarding the execution frequency of at least one entry node. According to one embodiment, the database (230) may not store information regarding the execution frequency for frequently executed entry nodes. According to one embodiment, in order to measure the time-series change in the execution frequency of each of at least one entry node, information regarding the execution frequency of all entry nodes can be measured.

[0056] According to one embodiment, the batch job generation unit (213) can transmit information regarding the execution frequency of at least one entry node stored in the database (230) to a server (i.e., the electronic device (100)) via the communication circuit (220). When the terminal (200) is in an idle state, the batch job generation unit (213) can transmit information regarding the execution frequency of at least one entry node to the server (the electronic device (100)).

[0057] According to one embodiment, the electronic device (100) may be a server that manages the execution frequency of at least one entry node included in the source code. The electronic device (100) may determine and manage information regarding a target for inserting test code, the frequency for inserting the test code, and the execution frequency of at least one node. The electronic device (100) may determine a target for inserting test code and the frequency for inserting the test code based on information regarding the execution frequency of at least one entry node collected from the terminal (200). For example, for an entry node with a high execution frequency, it may be determined that the code is essential and not to insert the test code in the future, or it may be determined that the test code is inserted only once a year. For example, for an entry node with a low execution frequency, it may be determined that the code is a management target and that the test code is inserted once a week.

[0058] FIG. 3 is a processing flowchart of an electronic device (100) according to one embodiment of the present disclosure.

[0059] Referring to the processing flowchart 300, the processor (110) of the electronic device (100) according to one embodiment can, in step 310, check information about a plurality of nodes in the source code. According to one embodiment, the electronic device (100) can obtain an execution request of the source code and check information about a plurality of nodes based on the structure of the program called according to the execution request. For example, the electronic device (100) can obtain an execution request of the source code from the terminal (200) and identify information about a plurality of nodes based on the structure of the program called.

[0060] According to one embodiment, the electronic device (100) can generate data in a graph structure for source code and identify multiple nodes included in the data in the graph structure. The electronic device (100) can visualize the source code so that a user can easily understand it at a glance. For example, the electronic device (100) can generate data in a graph structure for the source code by analyzing the source code using a source code visualization tool. The data in the graph structure for the source code will be described in detail with reference to FIG. 4A.

[0061] Referring to FIG. 4A, data (400) of a graph structure for source code may be composed of a plurality of nodes and a plurality of edges connecting the plurality of nodes. The electronic device (100) may confirm (identify) a class, field, or function included in the source code and generate data (400) of a graph structure with each of the confirmed classes, fields, or functions as a node. That is, a plurality of nodes included in the data (400) of the graph structure for source code may correspond to a class, field, or function included in the source code. The data (400) of the graph structure for source code may include a plurality of nodes and a plurality of edges connecting the nodes. The edges may represent a reference relationship (or dependency relationship) between nodes. For example, a first node (401) and a second node (403) are connected by an edge, and the second node (403) may be a sub-node or child node that references the first node (401). The electronic device (100) can analyze source code using the above-described method, generate data (400) of a graph structure for the source code, and use this to check information about multiple nodes in the source code. The data (400) of the graph structure for the source code described above can be displayed to the user through an integrated development environment (IDE).

[0062] Returning to FIG. 3, the processor (110) according to one embodiment may, at step 320, determine at least one entry node among a plurality of nodes included in the source code. An entry node may refer to a dependent starting point between the ends in an end-to-end manner. Whether a node corresponds to an entry node may be determined by the user or based on specific rules (e.g., class name, class hierarchy, dependency on a server). A node primarily called by an external server may be determined to be an entry node.

[0063] Referring to FIG. 4B, the electronic device (100) can confirm (identify) at least one entry node among a plurality of nodes included in data (400) of a graph structure for source code. The electronic device (100) can confirm (identify) at least one entry node (410) among the plurality of nodes, a child node (420) connected to at least one entry node (410), and an unused node (430). The electronic device (100) can, for example, determine at least one node corresponding to a top-level class, a field dependent on an external server, or a function dependent on an external server among the plurality of nodes included in the data of the graph structure as the entry node (410). The child node (420) may be a dependent node having at least one entry node (410) as a parent node. An unused node may be a node that is not connected to at least one entry node (410) and may be a node that is not used when executing the source code. The processor (110) can delete unused nodes (430).

[0064] Returning to FIG. 3, the processor (110) according to one embodiment may, in step 330, check the execution frequency of at least one entry node. The electronic device (100) may insert a test code for measuring the execution frequency into at least one entry node. The electronic device (100) may check the log records of the test code for a set period of time (e.g., one month). The electronic device (100) may check the execution frequency of at least one entry node based on the log records of the test code. The step of checking the execution frequency of at least one entry node may be performed repeatedly multiple times. For example, the electronic device (100) may check the execution frequency of at least one entry node at one-month intervals. The interval for checking the execution frequency of at least one entry node may be determined based on the execution frequency of at least one entry node. For example, for an entry node with a high execution frequency, the execution frequency may be checked at one-year intervals by inserting the test code once a year. For example, for entry nodes with low execution frequencies, test code can be inserted once a week to check execution frequency at weekly intervals. As described above, each entry node can adjust the interval (or cycle) for checking execution frequency based on its past execution frequency.

[0065] An electronic device (100) according to one embodiment may determine a level of at least one entry node based on the execution frequency of at least one entry node. For example, the electronic device (100) may assign a level from 1 to 10 to at least one entry node. The electronic device (100) may assign a higher level as the execution frequency of at least one entry node increases. The electronic device (100) may determine an interval for checking the execution frequency of at least one entry node based on the level of at least one entry node.

[0066] Referring to FIG. 5, the processor (110) may determine the level of each of at least one entry node (510). For example, the processor (110) may determine the level of entry node A (511) and entry node B (513) with a very high execution frequency as 10. For example, the processor (110) may determine the level of entry node C (515) and entry node D (517) with a low execution frequency as 2, and may determine the level of entry node E (519) with a very low execution frequency as 1.

[0067] The processor (110) of the electronic device (100) can determine the properties of a plurality of nodes based on the execution frequency of at least one entry node (510). The electronic device (100) can display data (500) in a graph structure that reflects the properties of the plurality of nodes through an integrated development environment (IDE). The properties of the plurality of nodes can include, for example, at least one of the sizes or colors of the plurality of nodes. For example, the electronic device (100) can display nodes with a relatively high execution frequency in red, nodes with a medium execution frequency in yellow, and nodes with a low execution frequency in blue. For example, the electronic device (100) can display nodes with a high execution frequency as large, nodes with a medium execution frequency in medium, and nodes with a low execution frequency in small. For example, the electronic device (100) can display nodes with a high execution frequency in bold using diagonal hatching, nodes with a medium execution frequency in medium using horizontal lines, and nodes with a low execution frequency in light using dot patterns. In addition, the electronic device (100) can display nodes as distinct from each other according to the execution frequency (or level) of the nodes.

[0068] Returning to FIG. 3, the processor (110) according to one embodiment may, in step 340, identify a code set to be managed among source codes based on the execution frequency of at least one entry node. The processor (110) may identify a first entry node whose execution frequency is less than a set threshold value, and may identify at least one first sub-node associated with the first entry node. In the above case, the processor (110) may identify the code corresponding to the first entry node and the at least one first sub-node as the code set to be managed. In one embodiment, the processor (110) may identify a first entry node whose level is less than a set threshold value, and may identify at least one first sub-node associated with the first entry node. In the above case, the processor (110) may identify the code corresponding to the first entry node and the at least one first sub-node as the code set to be managed.

[0069] Referring to FIG. 5, the processor (110) can identify a first entry node whose level is lower than a set threshold level, and can identify at least one first sub-node associated with the first entry node. For example, if the level of the entry node D (517) is determined to be 2, the processor (110) can identify the entry node D (517) whose level is lower than the set threshold level (e.g., level 3). The processor (110) can identify at least one sub-node (521) associated with the entry node D (517). The processor (110) can identify the code corresponding to the entry node D (517) and the at least one sub-node (521) as a code set to be managed.

[0070] If there is at least one second sub-node associated with a second entry node whose execution frequency is greater than or equal to a threshold value among at least one first sub-node, the processor (110) may exclude the code corresponding to at least one second sub-node from the code set to be managed. For example, if the level of the entry node C (515) is determined to be 2, the processor (110) may check that the entry node C (515) is below the set threshold level (e.g., level 3). The processor (110) may check at least one sub-node (523, 525) associated with the entry node C (515). Among these, the sub-node (525) is associated with not only the entry node C (515) but also the entry node B (513). Therefore, the code corresponding to the sub-node (525) may be excluded from the code set to be managed. Meanwhile, since at least one subnode (523) is associated only with entry node C (515) among the multiple entry nodes, the codes corresponding to entry node C (515) and at least one subnode (523) can be excluded from the code set to be managed. Meanwhile, entry node A (511) at level 10 can be excluded from the code set to be managed. Entry node E (519) at level 1 can be confirmed as a code set to be managed.

[0071] In one embodiment, the processor (110) may identify a set of codes to be managed as dead codes. If the dead codes correspond to the set deletion conditions, the processor (110) may automatically delete the dead codes. In one embodiment, if the dead codes correspond to the set deletion conditions, the processor (110) may provide a notification to the terminal (200) indicating that it is desirable to delete the dead codes.

[0072] According to one embodiment, the electronic device (100) can recover deleted dead codes if a call to the deleted dead code is obtained after the dead codes have been deleted. That is, according to the method described above, nodes with low execution frequencies can be classified as dead codes and automatically deleted, but sometimes essential nodes may be mistakenly deleted. Therefore, if a call to the deleted dead codes occurs, the deleted dead codes can be recovered.

[0073] Fig. 6 is a processing flowchart of an electronic device (100) according to one embodiment of the present disclosure. Any details overlapping with those described in Fig. 3 will be omitted.

[0074] Referring to the processing flowchart 600, the processor (110) of the electronic device (100) according to one embodiment may, in step 610, check information on a plurality of nodes in the source code. According to one embodiment, the processor (110) may generate data of a graph structure for the source code and check a plurality of nodes included in the data of the graph structure. According to one embodiment, the processor (110) may obtain an execution request of the source code and check information on a plurality of nodes based on the structure of a program called according to the execution request. For example, the processor (110) may check a class, field, or function included in the source code based on the structure of the program called according to the execution request, and check the checked class, field, or function as a plurality of nodes.

[0075] In one embodiment, the processor (110) may, at step 620, identify at least one entry node among a plurality of nodes. Whether a node corresponds to an entry node may be determined by the user or may be determined based on specific rules (e.g., class name, class hierarchy, dependency on a server). For example, at least one entry node may include a top-level class, a field dependent on an external server, or a function dependent on an external server.

[0076] According to one embodiment, the processor (110) may, at step 630, insert a test code for measuring the execution frequency into at least one entry node. The processor (110) may insert the test code for measuring the execution frequency into a code set corresponding to at least one entry node at compile time.

[0077] In one embodiment, the processor (110) may, at step 640, check the log records of the test code for a set period of time. For example, the processor (110) may check the log records indicating whether the test code was executed for one month. In one embodiment, the processor (110) may, at step 650, check the execution frequency of at least one entry node based on the log records of the test code.

[0078] In one embodiment, the processor (110) may determine the level of at least one entry node based on the execution frequency of at least one entry node at step 660. The processor (110) may determine the level of the entry node to be higher as the execution frequency of the entry node increases. For example, the level of the entry node may be one of 1 to 10.

[0079] For example, an entry code that has not been executed even once during a set period may be determined as Level 1. For example, an entry code that has been executed less than 40 times during a set period may be determined as Level 2. For example, an entry code that has been executed more than 40 times but less than 100 times during a set period may be determined as Level 3. For example, an entry code that has been executed more than 5,000 times during a set period may be determined as Level 10.

[0080] According to one embodiment, the processor (110) may perform a code coverage test on source code. The threshold for passing the code coverage test for at least one entry node may be determined based on the level of at least one entry node. Code coverage is an indicator of the extent to which software test cases have been satisfied, and may be a test that numerically indicates how much of the corresponding code has been executed. Code coverage testing can be measured through white box testing performed based on source code.

[0081] According to one embodiment, the processor (110) may, in step 670, identify a code set to be managed among source codes based on the level of at least one entry node. The processor (110) may identify a code corresponding to an entry node having a level lower than 3 as a code set to be managed. The processor (110) may also identify a code corresponding to at least one first sub-node associated with an entry node having a level lower than 3 as a code set to be managed. Meanwhile, in the case of at least one second sub-node associated with an entry node having a level higher than 3 among the at least one first sub-node, the code corresponding to at least one second sub-node may be excluded from the code set to be managed.

[0082] In one embodiment, the processor (110) may, at step 680, identify a set of codes to be managed as dead codes. In one embodiment, the processor (110) may, at step 690, delete the dead codes if the dead codes correspond to the set deletion conditions. For example, if the dead codes correspond to an entry node at level 1 and at least one sub-node associated therewith, the dead codes may be deleted. For example, if the dead codes are not executed for a set period of time, the dead codes may be deleted.

[0083] FIG. 7 is a diagram visualizing source code according to one embodiment of the present disclosure.

[0084] Referring to FIG. 7, the processor (110) of the electronic device (100) can generate a diagram (700) for the source code by analyzing the source code. The processor (110) can generate the diagram (700) for the source code using a source code visualization tool. The diagram (700) can include a plurality of nodes, and the plurality of nodes can represent classes, fields, or functions included in the source code. That is, the processor (110) can check information about a plurality of nodes in the source code, and generate a diagram (700) for the source code including the plurality of nodes. The processor (110) can check the execution frequency of the plurality of nodes. For example, the processor (110) can check at least one entry node among the plurality of nodes, check the execution frequency of the at least one entry node, and check the execution frequency of the plurality of nodes based on the execution frequency of the at least one entry node.

[0085] The processor (110) can determine the level of multiple nodes based on their execution frequency. For example, the processor (110) can assign a higher level to a node with a higher execution frequency. For example, the processor (110) can determine the level of multiple nodes using the method described in FIGS. 3 to 6 described above.

[0086] The plurality of nodes in the diagram (700) may include a first node having a (relatively) high execution frequency, a second node having a normal execution frequency, a third node having a low execution frequency, and an unidentified fourth node. For example, the explanation will be made assuming that the node levels are from 1 to 10. In the above case, a node having a level of 4 or higher may be classified as a first node, a node having a level of 3 may be classified as a second node, and nodes having levels 1 and 2 may be classified as a third node. A code block newly added to the source code but for which execution frequency measurement has not yet been performed may be classified as a fourth node.

[0087] That is, the processor (110) can determine the code corresponding to the first node with a high execution frequency as essential code for the source code, and manage the code corresponding to the first node as not to be deleted. The processor (110) can determine the code corresponding to the second node with a medium execution frequency as code that is not essential for the source code but is frequently used, and manage the code corresponding to the second node as code that requires additional monitoring. The processor (110) can determine the code corresponding to the third node with a low execution frequency as code that is not essential for the source code and can be deleted, and delete the code corresponding to the third node. The processor (110) can assign a low level (e.g., 1 to 2) as a default value to the fourth node for which the execution frequency has not been measured, and determine that the execution frequency measurement is necessary.

[0088] The processor (110) may determine the interval (or cycle) for measuring the execution frequency according to the level of each of the plurality of nodes. For example, the processor (110) may measure the execution frequency once a year for the first node, once a week for the second node, and determine that measurement of the execution frequency is necessary within a predetermined period (e.g., one month) for the fourth node. The processor (110) may delete the third node without performing additional execution frequency measurement.

[0089] Through the diagram (700), the user can visually check the execution frequency of multiple nodes included in the source code at a glance. Through the diagram (700), the user can identify nodes requiring additional monitoring and nodes that are desirable to delete, and can also check at a glance which nodes require execution frequency measurement. Through the electronic device (100), the user can measure and manage the execution frequency until all of the multiple nodes included in the source code become the first node with the highest execution frequency.

[0090] According to one embodiment, the processor (110) may determine a code block as dead code if the execution frequency for the code block is not measured until a predetermined period of time has elapsed from the time the code block is added to the source code. For example, if a new code block is added to the source code, the processor (110) may set the level of the node corresponding to the added code block to 1 as a default value. If the execution frequency for the code block is not measured until a predetermined period of time (e.g., 1 month) has elapsed from the time the code block is added, the processor (110) may determine the code block as dead code and delete it.

[0091] Meanwhile, the present specification and drawings disclose preferred embodiments of the present invention. Although specific terms have been used, they are used in a general sense only to easily explain the technical contents of the present invention and to assist in understanding the invention, and are not intended to limit the scope of the present invention. It will be apparent to those skilled in the art that other modified examples based on the technical concept of the present invention are possible in addition to the embodiments disclosed herein.

[0092] The device or terminal according to the above-described embodiments may include a processor, a memory for storing and executing program data, permanent storage such as a disk drive, a communication port for communicating with an external device, a user interface device such as a touch panel, a key, a button, etc. The methods implemented as software modules or algorithms may be stored on a computer-readable recording medium as computer-readable codes or program commands that can be executed on the processor. Here, the computer-readable recording medium includes a magnetic storage medium (e.g., read-only memory (ROM), random-access memory (RAM), floppy disk, hard disk, etc.) and an optical reading medium (e.g., CD-ROM, DVD: Digital Versatile Disc)). The computer-readable recording medium may be distributed to computer systems connected to a network, so that the computer-readable code can be stored and executed in a distributed manner. The medium is readable by a computer, stored in a memory, and executed by a processor.

[0093] The present embodiment may be represented by functional block configurations and various processing steps. These functional blocks may be implemented by various hardware and / or software configurations that perform specific functions. For example, the embodiment may employ integrated circuit configurations such as memory, processing, logic, look-up tables, etc., which may perform various functions under the control of one or more microprocessors or other control devices. Similarly, the present embodiment may be implemented in a programming or scripting language such as C, C++, Java, assembler, Python, etc., including various algorithms implemented as a combination of data structures, processes, routines, or other programming configurations. Functional aspects may be implemented as algorithms that execute on one or more processors. Furthermore, the present embodiment may employ conventional techniques for electronic configuration, signal processing, and / or data processing. Terms such as "mechanism," "element," "means," and "composition" can be used broadly and are not limited to mechanical or physical structures. These terms can also encompass a series of software routines, such as those associated with a processor.

[0094] The above-described embodiments are merely examples, and other embodiments may be implemented within the scope of the claims set forth below.

Claims

1. In a method of managing codes in an electronic device, A step for checking information about multiple nodes in the source code; A step of verifying at least one entry node among the plurality of nodes; a step of checking the execution frequency of at least one entry node; and A method for managing code, comprising the step of identifying a set of codes to be managed among the source codes based on the execution frequency of at least one entry node.

2. In paragraph 1, The step of checking the execution frequency of at least one entry node is: A step of inserting a test code for measuring the execution frequency into at least one of the above entry nodes; A step of checking the log records of the above test code for a set period of time; and A method for managing code, comprising a step of checking the execution frequency of at least one entry node according to a log record of the test code.

3. In paragraph 1, Further comprising a step of determining a level of the at least one entry node based on the execution frequency of the at least one entry node, The step of checking the code set to be managed above is: A method for managing code, comprising: a step of identifying a set of codes to be managed among the source codes based on the level of at least one entry node.

4. In paragraph 3, The step of checking the execution frequency of at least one entry node is performed repeatedly multiple times, A method for managing code, wherein the interval for checking the execution frequency of at least one entry node is determined based on the level of the at least one entry node.

5. In paragraph 3, A step of confirming the above-mentioned management target code set as a dead code; and A method for managing code, further comprising the step of deleting the dead code if the dead code corresponds to a set deletion condition.

6. In paragraph 5, A step of obtaining a call to the above deleted dead code; and A method of managing code, further comprising the step of recovering the dead code that has been deleted.

7. In paragraph 3, Further comprising a step of performing code coverage testing on the above source code, A method for managing code, wherein the threshold for passing the code coverage test of at least one entry node is determined based on the level of the at least one entry node.

8. In paragraph 1, The step of checking the code set to be managed above is: A step of identifying a first entry node whose execution frequency is less than a set threshold; A step of identifying at least one first sub-node associated with the first entry node; and A method for managing code, comprising the step of identifying a code corresponding to the first entry node and the at least one first sub-node as a set of codes to be managed.

9. In paragraph 8, The step of checking the code set to be managed above is: A step of identifying at least one second sub-node associated with a second entry node whose execution frequency is greater than or equal to the threshold among the at least one first sub-node; and A method for managing code, further comprising the step of excluding a code corresponding to at least one second sub-node from the set of codes to be managed.

10. In paragraph 1, Further comprising a step of generating data of a graph structure for the above source code, The step of checking information about the above multiple nodes is: A method for managing code, the method comprising: a step of checking information about the plurality of nodes included in the data of the above graph structure.

11. In paragraph 10, A step of determining the properties of the plurality of nodes based on the execution frequency of at least one entry node; and A method for managing code, further comprising the step of displaying data of the graph structure in which the properties of the plurality of nodes are reflected through an integrated development environment.

12. In paragraph 11, A method for managing code, wherein the properties of the plurality of nodes include at least one of the sizes or colors of the plurality of nodes.

13. In paragraph 1, Further comprising a step of obtaining an execution request of the above source code, The step of checking information about the above multiple nodes is: A method for managing code, the method comprising: a step of checking information about the plurality of nodes based on the structure of a program called according to the execution request.

14. In paragraph 13, The step of checking information about the above multiple nodes is: A step of checking a class, field or function included in the source code based on the structure of the program called according to the execution request; and A method for managing code, comprising a step of confirming the above-mentioned class, field or function with the plurality of nodes.

15. In paragraph 14, A method for managing code, wherein at least one entry node includes a top-level class, a field dependent on an external server, or a function dependent on an external server.

16. In paragraph 1, A step of adding a code block to the above source code; and A method for managing code, further comprising the step of identifying the code block as dead code if the execution frequency for the code block is not measured until a predetermined period of time has elapsed from the time the code block is added.

17. In electronic devices, A communication circuit connected to a terminal; one or more processors; and Contains one or more memories that store one or more instructions, The one or more processors, by executing the one or more instructions, Check information about multiple nodes in the source code, Check at least one entry node among the above multiple nodes, Check the execution frequency of at least one entry node, An electronic device configured to identify a set of codes to be managed among the source codes based on the execution frequency of at least one entry node.

Citation Information

Patent Citations

  • Display information storage controller, and program thereof

    JP2005301568A

  • Code transfer method to memory

    JP2009064112A

  • Dividing device, dividing method, and dividing program

    JP2013148987A

  • Automatic correction device

    JP2018163432A

  • Dead code analysis program, dead code analysis method, and dead code analysis device

    JP2020067697A