Replacement of data element in a graph

The generation and/or use of a hierarchical structure of model elements such as those that might be portions of a computer program. If it is determined that if a particular one of the model elements should be changed from one model element type to another model element type, that change is automatically made. The determination of whether the change should be made may be based on monitoring of actual behavior of the software program. The determination might alternatively be made based on expressed gestures of an author using an authoring program that visualizes the hierarchical structure of model elements.

BACKGROUND

Documents are often drafted in a hierarchically structured way in which portions of the document represents nodes in a hierarchy, and there is some convention for recognizing interrelationships between the nodes. Organization into some hierarchical structure is helpful as it enables data to be more effectively organized and identified within the document. That is one of the driving motivations for the development of eXtensible Markup Language or XML. As an example, there have even been standards for the definition of application programs based on hierarchically structured documents. One such standard is referred to as eXtensible Application Markup Language (XAML).

However, such hierarchically structured documents can become quite complex and cumbersome to deal with as the number of nodes in the hierarchy increase. However, increased nodes are often required to deal with complex data such as, for example, a complex XAML document that describes a sophisticated software program.

BRIEF SUMMARY

At least one embodiment described herein relates to the generation and/or use of a hierarchical structure of model elements. In one embodiment, the model elements may be components of a computer program. If it is determined that if a particular one of the model elements should be changed from one model element type to another model element type, that change is automatically made.

As an example, based on the actual usage of the computer program, it may be determined that one of the model elements of one particular type should be replaced by another model element of another type that is more suited towards the actual usage of the computer program. Based on this determination, the computer program is then modified accordingly automatically.

As another example, the author of a computer program may decide to replace one model element of a particular type with another. Using one or more simple gestures, the author may manipulate a visualization of the hierarchical structure of model elements. In response, the system underlying the visualization may automatically replace the model element while preserving the position of the model element in the hierarchical structure.

This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.

DETAILED DESCRIPTION

In accordance with embodiments described herein, a hierarchical structure of model elements is modified. The model elements may be, for example, portions of a computer program. If it is determined that if a particular one of the model elements should be changed from one model element type to another model element type, that change is automatically made. The determination of whether the change should be made may be based on monitoring of actual behavior of the software program. The determination might alternatively be made based on expressed gestures of an author using an authoring program that visualizes the hierarchical structure of model elements. First, some introductory discussion regarding computing systems will be described with respect toFIG. 1. Then, the embodiments in which a hierarchical structure is modified will be described with respect toFIGS. 2 through 8.

First, introductory discussion regarding computing systems is described with respect toFIG. 1. Computing systems are now increasingly taking a wide variety of forms. Computing systems may, for example, be handheld devices, appliances, laptop computers, desktop computers, mainframes, distributed computing systems, or even devices that have not conventionally been considered a computing system. In this description and in the claims, the term “computing system” is defined broadly as including any device or system (or combination thereof) that includes at least one processor, and a memory capable of having thereon computer-executable instructions that may be executed by the processor. The memory may take any form and may depend on the nature and form of the computing system. A computing system may be distributed over a network environment and may include multiple constituent computing systems.

As illustrated inFIG. 1, in its most basic configuration, a computing system100typically includes at least one processing unit102and memory104. The memory104may be physical system memory, which may be volatile, non-volatile, or some combination of the two. The term “memory” may also be used herein to refer to non-volatile mass storage such as physical storage media (e.g., physical storage devices, which are separate from and do not include wireless media or signals, as discussed below in connection with the term communications media, which does). If the computing system is distributed, the processing, memory and/or storage capability may be distributed as well. As used herein, the term “module” or “component” can refer to software objects or routines that execute on the computing system. The different components, modules, engines, and services described herein may be implemented as objects or processes that execute on the computing system (e.g., as separate threads).

In the description that follows, embodiments are described with reference to acts that are performed by one or more computing systems. If such acts are implemented in software, one or more processors of the associated computing system that performs the act direct the operation of the computing system in response to having executed computer-executable instructions. An example of such an operation involves the manipulation of data. The computer-executable instructions (and the manipulated data) may be stored in the memory104of the computing system100. The computing system100also may include a display112that may be used to provide various concrete user interfaces, such as those described herein.

Computing system100may also contain communication channels108that allow the computing system100to communicate with other message processors over, for example, network110. Communication channels108are examples of communications media. Communications media typically embody computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism and include any information-delivery media. By way of example, and not limitation, communications media include wired media, such as wired networks and direct-wired connections, and wireless media such as acoustic, radio, infrared, and other wireless media. The term computer-readable media as used herein includes both storage media (e.g., physical storage devices that do not include wireless media or signals), and communications media. Physical storage media (devices) and communications media are thus distinct and separate kinds of media, as noted.

Computer-executable instructions comprise, for example, instructions and data which cause a general purpose computer, special purpose computer, or special purpose processing device to perform a certain function or group of functions. Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described herein. Rather, the specific features and acts described herein are disclosed as example forms of implementing the claims. The computer-executable instructions cause the computer or processing device to perform the function or group of functions because the computer-executable instructions have a certain structure. If digitally represented, for example, such structures may represent one or more bits of information. In the case of magnetic storage media, for example, such a structure may be a level and/or orientation of magnetism on the media at predetermined parts of the magnetic storage media. In the case of optical storage media, for example, such a structure may be a level of reflectivity of the media at particular predetermined parts of the optical media.

The computing system100may execute viewer/editor such as that to be described further herein. The computing system100may also have access to hierarchically structured documents such as the example document described further herein.

FIG. 2abstractly illustrates a hierarchically structured document200that represents a certain hierarchy of nodes. The hierarchically structured document200is just a simple example in which there are four nodes in the hierarchy, including parent node201, and child nodes202through205. However, the principles described herein may apply to any hierarchy, even complex hierarchies of hundreds or thousands of nodes.

Although not required, each of the nodes may have zero or more fields. For instance, node201contains field201A; node202contains field202A; node203has no fields; node204has three fields204A,204B, and204C; and node205has two fields205A and205B. In this example, field201A is a body field of node201and is defined as including node202. Likewise, node202A is a body field of node202and is defined as including nodes203and204. Finally, node204C is a body field of node204and is defined as including node205. Thus, some fields define relationships with one or more child nodes. Other fields define parameters of the node. For instance, fields204A and204B define properties of the node204, and node205A defines a property for node205. Field205B may be a body field for node205and thus may be used to add a child node relation to the node205. Furthermore, body fields201A,202A and204C may be further used to add additional child nodes for respective nodes201,202and204.

FIG. 3illustrates one example usage300of a hierarchically structured document. In this case, the hierarchically-structured document200is provided to a computing system301, where the document200undergoes one or more stages of compilation and/or interpretation311to cause the computing system to formulate computer-executable instructions312that may be executed by the computing system. One example of a standard for formulating hierarchical descriptions of computer programs is eXtensible Application Markup Language (or XAML). XAML is a standard for drafting application descriptions in eXtensible Markup Language (or XML) such that the XML may be interpreted and an application formulated at run-time or prior to run-time. XML is a standard often used for drafting hierarchically structured documents, although the principles described herein are not limited to the viewing and/or editing of documents that are based on XML or XAML.

The following is an XAML document that will be provided as an example only. The example is provided by realizing that the principles described herein are not limited to any specific type or structure for the hierarchically structured document, but recognizing that an example can be helpful in understanding the broader principles described herein. The example XAML document is as follows with line numbering added for clarity:

The document extends from lines1through31. Lines2through6represent certain properties of the document. In particular, line4in this context indicates that the view of the document should expand all of the nodes upon opening. Thus, prior state regarding the expansion properties of the document as a whole are preserved within the document itself.

Lines7through30represent a sequence activity, and is an example of the node201ofFIG. 2. Line10is once again a persisted expansion state, and indicates that this sequence should be expanded upon opening. The editor may change this setting at some point in response to user interaction with the editor.

The sequence activity contains a child parallel activity that extends from lines13through29. The parallel activity is an example of the node202ofFIG. 2, and will be interpreted to be the child of the sequence activity due to its nested position within the sequence activity.

The parallel activity includes a first child activity that is represented wholly at line14. The delay activity represents an example of the node203ofFIG. 2. This first activity is a delay activity and will be interpreted to be the child of the parallel activity due to its nested position within the parallel activity.

The parallel activity also includes a second child activity, a “For Each” activity that extends from lines15through28. The For Each activity represents an example of the node204ofFIG. 2, and will be interpreted to be the child of the parallel activity due to its nested position within the parallel activity. Line18represents that the current persistent expansion state of the For Each activity is collapsed.

The For Each activity includes a child while activity that is represented wholly at line26. The while activity represents an example of the node205ofFIG. 2. This while activity will be interpreted to be the child of the For Each activity due to its nested position within the For Each activity.

The viewer/editor described herein need not actually execute the hierarchical document200, but does provide a view of the hierarchical document such that the document can be easily navigated through. A walkthrough of one example of the operation of the viewer/editor will be described with respect toFIGS. 4 through 12.

FIG. 4illustrates a user interface400that represents a beginning point in an example replacement that will be described herein. The user interface400illustrates the hierarchical document represented by the XAML document described above. In this case, each node in the hierarchical document (i.e., an activity in the document in this example) is represented by a window. For instance, a sequence window401represents the sequence activity. In this initial state, the visualization is completely expanded in that each window associated with each activity is viewable, along with all of the property fields of the activity.

The parallel window402represents the parallel activity. The fact that a node (in the example an activity) is a child of another node (also an activity in the example) is represented visually in this example by the window representing the child node being included within the window representing the parent node. Thus, the parallel window402is included within the sequence window401, since the parallel activity is the child of the sequence activity. Populated or unpopulated properties of a particular node are presented also within the corresponding window that represents the node, but outside any window that represents a child node of that particular node. Thus, inFIG. 4, since there are no properties within sequence window that are not also in parallel window, there are no properties of the sequence activity represented.

The delay window403represents the delay activity of the XAML example. The delay window403does not contain any properties and thus is represented only as a small window.

The For Each window404represents the For Each activity of the XAML example. The For Each window404shows two properties404A and404B (unpopulated in both cases) of the For Each activity. Properties404A and404B are examples of the fields204A and204B ofFIG. 2. The body field403C may contain one or more activities. In this case the body field403C includes a while window405.

The while window405represents the while activity of the XAML example. The while window405shows two fields. One field405A is an expression field into which an expression may be inserted which is the condition for continuing the while activity. Once the condition is false, the while activity finishes executing. A body field405B is shown empty with a mere prompt that an activity may be dropped within the body field405B to create a child activity of the while activity.

FIG. 5illustrates a flowchart of a method500for altering a hierarchical structure of multiple model elements constituting a computer program. The method500may be performed by the computing system100in response to the execution, by the computing system, of one or more computer-executable instructions.

The method initiates by accessing a hierarchical structure of model elements (act501). An example of such a hierarchical structure was provided above. The model elements may be, for example, components of a computer program. In the example above, the components of the computer program were activities in a workflow. However, even if the computer program contained activities, they may contain other types of model elements as well, such as, for example, a try-catch block which is a common C# model element.

For at least one of the model elements, the computing system determines that a model element of the hierarchical structure is to be replaced by another model element (act502). Specifically, the model element of one particular model element type is to determined to be replaced by a model element of another particular model element type (act502).

In response to this determination, the model element of the first model element type is replaced by the model element of a second model element type (act503). This replace operation is completed while maintaining the ancestral relationship status of the model element within the hierarchical structure of model elements. In other words, the model element that replaced that prior model element retains the same position in the hierarchical structure as the prior model element had. In a final step, the properties of the replacing model element are populated (act504).

The replacement operation may be behavior-based. In other words, the computing system determines that a model element should be replaced by another model element by monitoring usage of the computer program that is constructed from the hierarchical structure of model elements. If there is a change in usage that warrants a replacement from one model element to another, the computing system may automatically perform the replace operation.

As an example, suppose that one of the functions of a computer program is to send an e-mail. Now suppose there are three types of model elements that send e-mail, 1) a full e-mail model element that functions to send of e-mails with headings, a body, and with multiple attachments, 2) an intermediate e-mail model element that functions to send e-mails with headings, and a body, but no attachments, and 3) a simple e-mail model element that functions to send e-mails with headings and with a body, but with the size of the body limited to 128 characters, and without the ability to send attachments. The hierarchical structure of model elements may first operate using the full e-mail model element that permits attachments to be sent. However, the computer program may detect that the user never really sends e-mails with attachments. In fact, the computer program only ever needs to send e-mails with a short body. In that case, the computing system may replace the full e-mail model element with the simple e-mail model element. Then, should the behavior change further in the future, the model element may yet be replaced again as needed. This occasional replacement operation may be performed for other model elements as well, where there are alternative model elements available. In this way, the computer program may be kept as simple as the behavior of the program warrants, while becoming more complex as behaviors change.

The replacement may alternatively be initiated by the user, through one or more gestures made in a viewer in which is displayed a hierarchical visualization of multiple model elements in the hierarchical structure of model elements. An example of such a viewer has been illustrated inFIG. 4with respect to the example XAML document that includes four model elements.

In the case of a gesture-based replacement, the computing system determines that the model element should be changed in response to one or more user gestures interfacing with the viewer in a manner to convey user intent to perform the replacement. For instance, inFIG. 4, suppose that the user desires to replace the For Each activity404with another type of activity, perhaps a sequence activity. In this case, the user might select the For Each activity404, right click to present a list of options, select an option to replace the activity, then select a sequence activity template. Then, based on these simple gestures, a sequence activity window might appear in the same position as the For Each activity window404. In this case, the while activity window405might disappear. Underlying this window replacement, the computing system actually changes the model element itself, in this case, the activity is replaced in the underlying XAML, of course, while preserving position of the activity within the ancestral chain of the hierarchical structure.

As another example, suppose that the user wants to replace the For Each activity with a Try-Catch block that contains the For Each activity. A Try-Catch block is not an activity, but is a model element that can be included within a workflow. The try-catch block includes try block that contains code to be executed, and which is protected by exception handling, and a catch block that contains the exception code to be executed should the code in the try block fail. Referring toFIG. 4, the user might, in that case, again select the For Each activity window404, and then right click and select a replace operation. Now, the user selects a Try-Catch block.

In this case, the try-catch block window then replaces the For Each activity window404within the hierarchical visualization, with the computing system enforcing a corresponding replacement in the underlying hierarchical structure of model elements. In this case, however, some of the fields of the try-catch block may be populated (reference act504ofFIG. 5). For instance, when a replace operation is performed, some of the fields may be automatically populated based on the identity of the replaced model element type and/or based on the identity of the replacing model element type. In the case of a try-catch block replacing another model element, the try field of the try-catch block are populated by the same model element that the try-catch block replaced, with all of the descendent chains of the old model element preserved. Referring toFIG. 4, the result would be that a try-catch block window replaces the For Each Window404. However, the For Each window404is then contained within the try-catch block window. The For Each Window404still contains the While window405since the descendent chains are preserved. The computing system enforces corresponding changes in the underlying model elements.

Note that these changes can be easily made by the user without having to first delete the prior model element, then manually add a new model element and insert the new model element into the hierarchic structure. Instead, the model element to be replaced is selected, then a simple user gesture is performed indicative of a user intent to replace. Then, the replacement model element type is selected. The new model element automatically takes the same position as the prior selected model element. Thus, there is no separate gesture required to delete the model element, and there is no separate gesture required to add the new model element. The two functions are integrated in a single replace gesture.

The principles described herein also allow the user of a simple placeholder model element to be used in the hierarchical structure during the authoring process. The placeholder model element may be used when the author is not quite sure yet what kind of model element to use at a particular position within the hierarchy, but the author knows that some type of model element will be used at that position. In such cases, the placeholder model element may be deposited in the visualization, with the computing system enforcing a corresponding placeholder model element within the model element hierarchy. Then, regardless of how entangled the placeholder model element is within the hierarchical structure, the replace operation may be used to replace the placeholder element within the hierarchy of model elements.FIG. 6illustrates an environment600in which the placeholder model element is used within a sequence model element.FIG. 7illustrates an environment700in which the placeholder model element is replaced with another model element.

Referring toFIG. 6, the initial environment includes a viewer601that is providing a visualization of an underlying activities collection620present in memory602. The collection620includes a sequence activity that includes three activities in sequence including 1) ActivityOne, 2) PlaceHolderActivity, and 3) ActivityThree. The viewer thus includes a visualization610of the sequence activity, a visualization611of the Activity One, a visualization612of the PlaceHolder Activity, and a visualization613of Activity Three.

Once the author has a better idea of the type of model element that is to replace the PlaceHolder Activity, the author may simply select the placeholder activity visualization612, indicate that a replacement is to be made, and select the replacement model element (in this case, the MyElementActivity). The result is shown inFIG. 7, which illustrates an environment in which the sequence visualization710has been modified from the prior sequence visualization610to replace the PlaceHolder Activity visualization612with the MyElement Activity visualization712. The computing system enforces a change to the activity collection in memory602to change the references to the PlaceHolderActivity to properly refer to the myElementActivity720.

In one embodiment, when a particular model element is selected for replacement, the computing system may replace all of the model elements of that type with model elements of the replacement type, either by default, or at the selection of the author.

Recall that the try-catch block replacement replaces the prior selected model element with a try-catch block, and reinserts the replaced model element as a child model element of the try-catch block, preserving any descendent model elements of the replaced model element. A similar example is the replacement of portion of the hierarchical model elements with a refactored activity.

The refactored activity retains all of the functionality of the replaced portion of the hierarchical model elements, but allows the visualization to be simplified. A refactored activity is really just a container. When a particular portion of the hierarchy is replaced by a refactored activity, the refactored activity (i.e., a container) replaces the portion of the hierarchy. In order to allow the refactored activity to retain the same functionality as the portion replaced, the portion replaced then becomes a child of the refactored activity, wherein the portion retains the same hierarchical form that it possessed prior to the replacement. In order to allow for the benefit of a simplified visualization, the visualizations for the replaced portion may be hidden in the visualization itself. Thus, refactorization creates a new model element with a simple visualization, while retaining the same functionality as the replaced portion of the hierarchy.

Referring back toFIG. 5, recall that once a model element is replaced by another model element, the replacement model element has fields that are then populated. Some model elements may not have any fields to populate at all. In that case, act504ofFIG. 4is not performed. However, in cases in which there are property fields to be populated, there may be one or more mechanisms used to populate the fields.

In some cases, population might be performed based on context of the replaced model element and the replacement model element. For example, if a portion of the hierarchy is replaced by a try-catch block, the try field of the try-catch block is populated by that portion of the hierarchy that was replaced by the try-catch block. Similarly, the refactored activity has a body field that is populated by the portion of the hierarchy that was replaced by the refactored activity.

Likewise, other fields may be populated based on context. For instance, the value of the DateTime field of one model element may be used to populate a DateTime field of a replacement model element. Some transformation modules may be available to assist when the value of a field of the replaced model element cannot be copied directly into the field of the replacement model element. There may be a collection of transformation modules available to perform such transformations. An API may be provided to extend the availability of such transformation modules, as well as to author new custom model elements.

FIG. 8illustrates a flowchart of a method800for automatically populating a property value in a case where transformation is used. The property value of the replaced model element is accessed (act801) and then transformed (act802). The transformed value is then used to populate the property field of the replacement model element (act803).

The principles described herein thus provide an efficient mechanism for replacing model element with other model elements in a hierarchical structure of model elements. The replacement may be behavior-based in response to usage changes in a computer program. The replacement may also be in response to author gestures, and without requiring separate gestures to delete an element, add an element, and insert the element into the hierarchical structure.