The present invention relates to software code processing, and in particular review and editing of software code.
The tools and methodologies associated with software code editing have evolved over time in parallel with the evolution of the computer systems used to run the resulting code. While in the era of punch cards, programs were developed on paper, with the availability of terminals it became feasible to develop software directly in the computing environment. Since then, programming has largely revolved around editing text based code, in general purpose text editing software, or increasingly over time in a dedicated Integrated Development Environment, generally offering additional tools for compiling and debugging the code. Certain environments support visual coding, in which a user may edit code by the manipulation of graphical representations of code entities in some computer generated space. Both text based and visual programming environments tend to present code with a structure built around a number of modules, with the elements in each module being presented in the sequence in which they will be executed subject to any loops and forks within the module.
It is desirable to provide improved tools for reviewing software code, in particular facilitating the tracking of execution through the code.
In accordance with the present invention in a first aspect there is provided an apparatus for processing software code, the apparatus comprising a code converter adapted to prepare a representation of the code as a finite state machine;
a primary state selector adapted to select one or more states of the finite state machine for display,
a secondary state selector adapted to identify secondary states for the selected primary states, where
all the secondary states are states of the finite state machine comprising transitions that lead to the selected states, or
all the secondary states are states of the finite state machine comprising transitions that lead out of the selected states, or
the states belong to a valid sequence through a series of selected states of the finite state machine specified in user input received by the apparatus; and
a representation processor adapted to cause the presentation of a textual representation integrating a textual representation of the selected states with a textual representation of the secondary states.
In a development of the first aspect, the apparatus may be further adapted to receive a user input specifying whether the secondary states should comprise all states of the finite state machine comprising transitions that lead to the selected states, or otherwise all states of the finite state machine comprising transitions that lead out of the selected states; and to refresh the textual representation accordingly.
In a development of the first aspect, the apparatus may be further adapted to receiving a user input specifying which state of the finite state machine is to constitute the selected states.
In a development of the first aspect, the apparatus may be further adapted to receive a user input specifying an amendment to a part of the textual representation,
to Identify the amended state corresponding to the amendment,
to identify the amended code corresponding to the amended state, and
to update the amended code to reflect the amendment.
In a development of the first aspect, the apparatus may be further adapted to select one or more secondary states as expanded secondary states, whereby further states of the finite state machine are selected for display as secondary states in the case where they are states of the finite state machine comprising transitions that lead to the expanded secondary states, or are states of the finite state machine comprising transitions that lead out of the expanded secondary states.
In a development of the first aspect, the apparatus may be further adapted to select one or more states of the finite state machine for display where the selected states lie within a current flow of execution.
In accordance with the present invention in a second aspect there is provided a method of processing software code, the method comprising the steps of:
preparing a representation of the code as a finite state machine;
selecting one or more states of the finite state machine for display;
for each of the selected states, identifying secondary states, where
all the secondary states are states of the finite state machine comprising transitions that lead to the selected states, or
all the secondary states are states of the finite state machine comprising transitions that lead out of the selected states,
or receiving user input specifying a valid sequence through a series of selected states of the finite state machine; and
presenting a textual representation integrating a textual representation of the selected states with a textual representation of the secondary states.
In a development of the second aspect, the method may comprise the additional steps of receiving a user input specifying whether the secondary states should comprise all states of the finite state machine comprising transitions that lead to the selected states, or otherwise all states of the finite state machine comprising transitions that lead out of the selected states; and refreshing the textual representation accordingly.
In a development of the second aspect, the method may comprise the additional step of receiving a user input specifying which state of the finite state machine is to constitute the selected states.
In a development of the second aspect, the method may comprise the additional steps of receiving a user input specifying an amendment to a part of the textual representation,
Identifying the amended state corresponding to the amendment,
Identifying the amended code corresponding to the amended state, and
updating the amended code to reflect the amendment.
In a development of the second aspect, the method may comprise the additional steps of selecting one or more secondary states as expanded secondary states, whereby further states of the finite state machine are selected for display as secondary states in the case where they are states of the finite state machine comprising transitions that lead to the expanded secondary states, or are states of the finite state machine comprising transitions that lead out of the expanded secondary states.
In a development of the second aspect, the step of selecting one or more states of the finite state machine for display may comprise selecting states that lie within a current flow of execution.
In accordance with the present invention in a third aspect there is provided a computer program adapted to implement the steps of the second aspect.
In accordance with the present invention in a fourth aspect there is provided a computer readable medium incorporating the computer program of the third aspect.
The above and other advantages of the present invention will now be described with reference to the accompanying drawings, for illustration purposes only, in which:
Generally speaking, interactive computer software can be represented in terms of a Finite State Machine. A Finite State Machine is a representation of a process in terms of a machine having a number of defined states, whereby at any time the machine must be in one, and only one of these states, and where states are linked by defined transitions, whereby movement between states can only occur in accordance with one of these defined transitions. Any such Finite State Machine may be implemented in software and/or hardware.
The design of current programming tools is based on an implicit choice that consists in displaying code in a single, canonical representation. The textual canonical representation of interactive code consists of displaying the leaving transitions in the context of a state. However, in order to understand the behavior of a sequence of events, it is sometimes necessary to look at the code of the transitions that led to the particular state currently investigated. This requires the programmer to find the transitions by scanning all the code, and once found, hop from transition to transition to understand the sequence of instructions.
A difficulty arises in reading and debugging code prepared using prior art interfaces since for a reader viewing the current line of code under execution, there is no indication what preceding steps led execution to arrive at that point. The flow of execution through a piece of software can be modified by subtle factors which are not always obvious or easy to predict, and mean that this determination may often call for a complete understanding of the code structure of the code itself. In substantial software projects, this level of understanding is often unrealistic for human operators.
As shown in
Although most programming languages do not directly define Finite State Machines, it is possible to convert any computer program into a Finite State Machine, either in software or hardware form.
Although traditionally Finite State Machines are represented by means of drawings such as described above with respect to
The following text is a representation of the Finite State Machine of
Accordingly, this code defines a drag and drop interaction. The programmer might want to fix a bug that occurs when a user of that program performs a particular sequence of events: the shape that was dragged is supposed to be highlighted during the drag. Since the “start” state is also the final state of the interaction (at the end of the interaction and whatever the end is, the interaction should start over), the shape being manipulated should be unhighlighted. With a traditional editor, this requires finding all transitions coming to the “start” state, and browsing through them. Furthermore, the fact that related pieces of code are spread apart implies that the programmer has to use his memory to compare them. The cognitive activity required to navigate into the code is thus not allocated to the more important cognition activity required to understand and design the code.
It will be appreciated with regard to the issue highlighted above that a formulation in terms of a Finite State Machine has the benefit of rendering explicit the possible paths for arriving at a particular point in the code.
This property may be used to facilitate software development, coding, debugging and the like.
As shown, the method starts at step 200 before proceeding to step 205 at which a representation of the code to be processed as a finite state machine is prepared. This may be on the basis of a graphical representation or a text based or other encoded representation. The representation may be prepared by conversion of conventional software code, for example as implemented by the SwingStates library or may exist in a natively Finite State Machine representation.
The method next proceeds to step 210 at which one or more states of the finite state machine representation are selected for display. For grammatical reasons the following description will often refer to “selected states” in this regard, however it should be borne in mind that any embodiment may apply to only a single selected state.
In accordance with the method of
The selected states may comprise a StateMachine, a Hierarchical Parent State in the case of compound states such as described by David Harel in StateCharts: A visual Formalism for Complex Systems, Science of Computer Programming 8 (1987) 231-2741, or in the SCXML standard, or otherwise.
The method next proceeds for the state or states selected at step 210, to identify secondary states at step 215.
In various embodiments, secondary states may be:
As shown in
While for the sake of the present example the checkbox interface feature is presented, it will be appreciated that any suitable user input mechanism, whether in a graphical user interface, or otherwise, may be used.
As shown in
Depending on the selection criteria supported by particular implementations, the number of tests taken may be smaller or greater in number, and may comprise only a single test. Furthermore, while the tests are show in series, it will be appreciated that some or all of them may equally be processed in parallel.
As discussed above, there are many possible approaches to defining the selected state or states. For the purposes of the example of
Accordingly, the code 330 shown in
Accordingly the interactive code is initially represented with a textual representation of state machines: a machine contains states, which in turn contain transitions upon events that leave the state for the next one. The programmer/user can click on a check box to display transitions that enter one or more selected particular states. After clicking the checkbox, an animation may move the identified code corresponding to the ‘leaving’ transition to the bottom in order to make room for the code corresponding to the ‘entering’ transitions. As shown, the entering transitions then appear, displayed in grey and preceded with a “>> state” text. The entering transitions are copies of the leaving transitions that reside in other states.
The copies of the identified States may be linked: all changes made in the code of an entering transition may be reflected in the leaving transition and vice-versa. This may be implemented for example by means of a MVC mechanism (Model View Controller), where a Model of the code is provided in memory (for example in the form of strings of characters) and two Views (Representations) that are synchronized when the Model changes (usually because the user is modifying one of the views). This approach is known to programmers in interactive code as described for example by T. Reenskaug, in “Models—views—controllers.” Xerox PARC, 1979.
According, a user input may be received specifying an amendment to a part of the textual representation. This may lead to the steps of identifying the amended state corresponding to the amendment, identifying the amended code corresponding to the amended state, and updating the amended code to reflect the amendment.
On the basis of these features, programmers are able to see the sequence of instructions in the context of a state by displaying the entering transitions. As a result, programmers are able to see the instructions of all transitions that led to the state. Hence, one can quickly check whether all transitions coming to the “start” state actually unhighlight the graphical shape. In addition, this also allows the programmer to rely on very short-term memory to compare related pieces of code and detect potential flaws. This makes programmers more efficient in understanding the code, at editing it according to a view suitable to their problems at hand, and corresponding shorter development times and more efficient, less error prone software. This in turn translates into energy savings, improved safety and lower system maintenance costs.
While as described with reference to
Furthermore, the identified states may be identified on the basis of the actual flow of execution. This may be performed ‘live’ i.e. during execution, for example with the equivalent of a breakpoint on a state that pauses the execution, to avoid text appearing and disappearing everywhere very rapidly. For example, a debugging break point may be associated with a selected state such that when the code is executed and reaches that state, execution pauses and rather than selecting all secondary states feeding into, or out of, the selected states, only the states that did, in the current flow of execution lead to the selected state associated with the break point are displayed.
The disclosed methods can take form of an entirely hardware embodiment (e.g. FPGA), an entirely software embodiment (for example to control a system according to the invention) or an embodiment containing both hardware and software elements. As such, embodiments may comprise a number of subsystems, functional elements or means adapted to implement the invention in communication with each other, and/or with standard fixed function or programmable elements for example as described below.
all the secondary states are states of the finite state machine comprising transitions that lead to the selected states, or
all the secondary states are states of the finite state machine comprising transitions that lead out of the selected states, or
the states belong to a valid sequence through a series of selected states of the finite state machine specified in user input received by the apparatus. The apparatus further comprises a representation processor 514 adapted to cause the presentation of a textual representation integrating a textual representation of the selected state or states as retrieved from the Finite State Machine representation 522 with a textual representation of the identified secondary states as retrieved from the Finite State Machine representation 522.
Similarly, there is provided an apparatus adapted to perform the steps of any of the methods described above, for example with respect to
Accordingly, there is provided a mechanism for interacting with software code based on translation into a finite state machine is presented. The states of the translated code currently under review are presented, along with other related states. Related states may be states that feed into the states of the translated code currently under review, or that may follow those states in the process flow. User edits may be made to related states as they are presented in connection with states of the translated code currently under review, and the corresponding code updated accordingly. The states of the translated code currently under review, and the corresponding related states may be updated dynamically to reflect actual code execution.
Software embodiments include but are not limited to applications, firmware, resident software, microcode, etc. The invention can take the form of a computer program product accessible from a computer-usable or computer-readable medium providing program code for use by or in connection with a computer or an instruction execution system, or for implementation in dedicated or suitably programmable hardware, as a Finite State Machine or otherwise.
A computer-usable or computer-readable can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The medium can be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system (or apparatus or device) or a propagation medium.
In some embodiments, the methods and processes described herein may be implemented in whole or part by a user device. These methods and processes may be implemented by computer-application programs or services, an application-programming interface (API), a library, and/or other computer-program product, or any combination of such entities.
The user device may be a mobile device such as a smart phone or tablet, a drone, a computer or any other device with processing capability, such as a robot or other connected device, including IoT (Internet Of Things) devices.
A shown in
Logic device 601 includes one or more physical devices configured to execute instructions. For example, the logic device 601 may be configured to execute instructions that are part of one or more applications, services, programs, routines, libraries, objects, components, data structures, or other logical constructs. Such instructions may be implemented to perform a task, implement a data type, transform the state of one or more components, achieve a technical effect, or otherwise arrive at a desired result.
The logic device 601 may include one or more processors configured to execute software instructions. Additionally or alternatively, the logic device may include one or more hardware or firmware logic devices configured to execute hardware or firmware instructions. Processors of the logic device may be single-core or multi-core, and the instructions executed thereon may be configured for sequential, parallel, and/or distributed processing. Individual components of the logic device 601 optionally may be distributed among two or more separate devices, which may be remotely located and/or configured for coordinated processing. Aspects of the logic device 601 may be virtualized and executed by remotely accessible, networked computing devices configured in a cloud-computing configuration.
Storage device 602 includes one or more physical devices configured to hold instructions executable by the logic device to implement the methods and processes described herein. When such methods and processes are implemented, the state of storage 602 device may be transformed—e.g., to hold different data.
Storage device 602 may include removable and/or built-in devices. Storage device may be locally or remotely stored (in a cloud for instance). Storage device 602 may comprise one or more types of storage device including optical memory (e.g., CD, DVD, HD-DVD, Blu-Ray Disc, etc.), semiconductor memory (e.g., FLASH, RAM, EPROM, EEPROM, etc.), and/or magnetic memory (e.g., hard-disk drive, floppy-disk drive, tape drive, MRAM, etc.), among others. Storage device may include volatile, non-volatile, dynamic, static, read/write, read-only, random-access, sequential-access, location-addressable, file-addressable, and/or content-addressable devices.
In certain arrangements, the system may comprise an interface 603 adapted to support communications between the Logic device 601 and further system components. For example, additional system components may comprise removable and/or built-in extended storage devices. Extended storage devices may comprise one or more types of storage device including optical memory 632 (e.g., CD, DVD, HD-DVD, Blu-Ray Disc, etc.), semiconductor memory (not shown) (e.g., RAM, EPROM, EEPROM, FLASH etc.), and/or magnetic memory 631 (e.g., hard-disk drive, floppy-disk drive, tape drive, MRAM, etc.), among others. Such extended storage device may include volatile, non-volatile, dynamic, static, read/write, read-only, random-access, sequential-access, location-addressable, file-addressable, and/or content-addressable devices.
It will be appreciated that storage device includes one or more physical devices, and excludes propagating signals per se. However, aspects of the instructions described herein alternatively may be propagated by a communication medium (e.g., an electromagnetic signal, an optical signal, etc.), as opposed to being stored on a storage device.
Aspects of logic device 601 and storage device 602 may be integrated together into one or more hardware-logic components. Such hardware-logic components may include field-programmable gate arrays (FPGAs), program- and application-specific integrated circuits (PASIC/ASICs), program- and application-specific standard products (PSSP/ASSPs), system-on-a-chip (SOC), and complex programmable logic devices (CPLDs), for example.
The term “program” may be used to describe an aspect of computing system implemented to perform a particular function. In some cases, a program may be instantiated via logic device executing machine-readable instructions held by storage device 602. It will be understood that different modules may be instantiated from the same application, service, code block, object, library, routine, API, function, etc. Likewise, the same program may be instantiated by different applications, services, code blocks, objects, routines, APIs, functions, etc. The term “program” may encompass individual or groups of executable files, data files, libraries, drivers, scripts, database records, etc.
In particular, the system of
For example a program implementing the steps described with respect to
It will be appreciated that a “service”, as used herein, is an application program executable across multiple user sessions. A service may be available to one or more system components, programs, and/or other services. In some implementations, a service may run on one or more server-computing devices.
When included, display subsystem 611 may be used to present a visual representation of data held by a storage device. This visual representation may take the form of a graphical user interface (GUI). As the herein described methods and processes change the data held by the storage device 602, and thus transform the state of the storage device 602, the state of display subsystem 611 may likewise be transformed to visually represent changes in the underlying data. Display subsystem 611 may include one or more display devices utilizing virtually any type of technology for example as discussed above. Such display devices may be combined with logic device and/or storage device in a shared enclosure, or such display devices may be peripheral display devices.
When included, input subsystem may comprise or interface with one or more user-input devices such as a keyboard 612, mouse 613, touch screen 611, or game controller (not shown). In some embodiments, the input subsystem may comprise or interface with selected natural user input (NUI) componentry. Such componentry may be integrated or peripheral, and the transduction and/or processing of input actions may be handled on- or off-board. Example NUI componentry may include a microphone for speech and/or voice recognition; an infrared, colour, stereoscopic, and/or depth camera for machine vision and/or gesture recognition; a head tracker, eye tracker, accelerometer, and/or gyroscope for motion detection and/or intent recognition; as well as electric-field sensing componentry for assessing brain activity.
When included, communication subsystem 620 may be configured to communicatively couple computing system with one or more other computing devices. For example, communication module of communicatively couple computing device to remote service hosted for example on a remote server 676 via a network of any size including for example a personal area network, local area network, wide area network, or internet. Communication subsystem may include wired and/or wireless communication devices compatible with one or more different communication protocols. As non-limiting examples, the communication subsystem may be configured for communication via a wireless telephone network 674, or a wired or wireless local- or wide-area network. In some embodiments, the communication subsystem may allow computing system to send and/or receive messages to and/or from other devices via a network such as Internet 675. The communications subsystem may additionally support short range inductive communications with passive or active devices (NFC, RFID, UHF, etc).
The system of
It will be understood that the configurations and/or approaches described herein are exemplary in nature, and that these specific embodiments or examples are not to be considered in a limiting sense, because numerous variations are possible. The specific routines or methods described herein may represent one or more of any number of processing strategies. As such, various acts illustrated and/or described may be performed in the sequence illustrated and/or described, in other sequences, in parallel, or omitted. Likewise, the order of the above-described processes may be changed.
The subject matter of the present disclosure includes all novel and non-obvious combinations and sub-combinations of the various processes, systems and configurations, and other features, functions, acts, and/or properties disclosed herein, as well as any and all equivalents thereof.
Number | Date | Country | Kind |
---|---|---|---|
16306780.4 | Dec 2016 | EP | regional |