Object-oriented programming is a paradigm that uses objects and interactions amongst objects as a basis for computer program design. In particular, programmers create a number of classes identifying properties and characteristics of an abstract thing as well as methods describing class behavior or abilities. Specific programmatic logic can then be specified as interactions between instances of classes or objects, among other things.
An object model is an object-oriented description of a system, service, or the like. More specifically, an object model is a collection of objects or classes that are available for inspection and manipulation by a program. By way of example, a document object model (DOM) is a collection of objects that represents a browser webpage that enables dynamic modification of the webpage. The DOM is platform and program language independent and facilitates representation of HTML (HyperText Markup Language) and XML (eXtensbile Markup Language) formats, among others. In fact, the World Wide Web Consortium (W3C) specifies a standard DOM that is utilized by most browsers today.
The DOM provides an omnipresent XML object model. In particular, this is the XML object model supported by most browsers, for instance as the “responseXML” attribute of an “XMLHTTP Request”:
However, the DOM is a very imperative object model, which enforces a convoluted manner of specifying programs as sequences of side-effect ridden statements. By contrast, compositional object models are much simpler and intuitive, and allow programs to be defined as compositions of expressions. As a result of the DOM's imperative nature, it is not suitable for compositional query and construction.
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed subject matter. This summary is not an extensive overview. It is not intended to identify key/critical elements or to delineate the scope of the claimed subject matter. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented later.
Briefly described, the subject disclosure pertains to employment of a compositional view of an imperative object model. More specifically, a compositional or alternate object model can be employed over or as a proxy for an imperative object model such as but not limited to the DOM. Transformations can be performed between the object models to provide a bridge between different worlds. Various systems, architectures, and/or design patterns can be employed to afford transformation, wherein the object models are decoupled, loosely coupled, or tightly coupled. Among other things, this allows developers to program against user-friendly imperative object models as opposed to convoluted imperative models. Moreover, in at least some embodiments this advantage can be attained without modification or even access to an underlying or proxy object model.
To the accomplishment of the foregoing and related ends, certain illustrative aspects of the claimed subject matter are described herein in connection with the following description and the annexed drawings. These aspects are indicative of various ways in which the subject matter may be practiced, all of which are intended to be within the scope of the claimed subject matter. Other advantages and novel features may become apparent from the following detailed description when considered in conjunction with the drawings.
a is block diagram of a system for translating between imperative and compositional aspects according to a disclosed aspect.
b is a graphical illustration of a wrapper pattern employed in accordance with an aspect of the disclosed subject matter.
Systems and methods concerning employment of a compositional or alternate object model over an imperative object model are described in detail hereinafter. Transformations can be provided between compositional and imperative object model representations. Extension methods can be employed for this purpose. In one instance, the compositional object model can act as a proxy for the imperative object model. Furthermore, various architectures or design patterns can be employed to effect the transformations.
Various aspects of the subject disclosure are now described with reference to the annexed drawings, wherein like numerals refer to like or corresponding elements throughout. It should be understood, however, that the drawings and detailed description relating thereto are not intended to limit the claimed subject matter to the particular form disclosed. Rather, the intention is to cover all modifications, equivalents and alternatives falling within the spirit and scope of the claimed subject matter.
Referring initially to
Similar to the imperative object model 110, the compositional object model 120 provides a description of a system, service, construct, or the like. However, the compositional object model 120, as the name suggests, is compositional (expression-oriented) in style rather than imperative. Further, the compositional object model 120 includes application-programming interface (API) 122 (a component as defined herein) that identifies functions, procedures, or the like defined by implementation 224 (a component as defined herein) that can be employed or called by a program or other entity.
In accordance with one aspect, the imperative object model 110 and the compositional object model 110 can relate to the same service, construct, or the like. By way of example and not limitation, both the imperative object model 110 and the compositional object model 120 can correspond to an XML object model that enables interaction with an XML document.
It is often desirous to utilize a compositional object model 110 rather than an imperative object model 120, since it is more intuitive and user friendly by virtue of its declarative and compositional nature than a rigid step-by-step imperative approach. However, some systems are tightly bound with an imperative object model 110. For instance, a majority of web browsers support a standard document object model that supports XML, among other things. In such instances, one is not likely to be able to simply swap an imperative object model 110 for a compositional object model. However, in accordance with an aspect of the claimed subject matter, the compositional object model 120 can be employed in conjunction with and/or over the imperative object model 110. In effect, the compositional object model 120 can act as a proxy for the imperative object model thereby leveraging the benefits of the compositional style.
Differences between the imperative object model 110 and the compositional object model 120 can be addressed by transformation component 130 via transformation or mapping between the object models. In particular, the transformation component includes an interface component 132 and transform component 134. The interface component 132 can receive or otherwise identify operations or calls from an object model such as the compositional object model 120 and provide them to the transform component 134 that transforms compositional actions into imperative actions with respect to the imperative object model 110. Of course, the opposite is also possible, in which the transformation component 130 acquires imperative actions and transforms them into compositional actions. As will be discussed further below and in accordance with another aspect, transformation can be performed with extension methods.
Various architectures, design patterns or the like can be employed with respect employing a compositional or alternate object model 120 over an imperative object model. Turning to
Appendix A provides exemplary code for converting a DOM tree into an alternate compositional XML object model. In general, the compositional XML object model can include several methods to load as well as print or save documents. For instance, data can be loaded from a string or an XML reader employed and written to a string or output by an XML writer. In accordance with a disclosed aspect, the repertoire of loading and writing, printing or saving can be extended to support reading and writing a DOM tree. Further, the “GetContent” method illustrates one example of how the imperative and compositional worlds can be bridged. In particular, a switch construct is employed that switches on DOM nodes and produces compositional XML nodes.
One issue with this type of architecture is that the imperative and compositional structures may not be synchronized. After the first imperative structure is converted into a compositional structure, many modifications can be made which will not be reflected in the imperative world until another imperative structure is generated that captures the current state. Further, it is not very efficient to require complete regeneration of imperative structures. Nevertheless, this is one possible manner of interaction in which the imperative and compositional object model are decoupled and a type of serialization and/or deserialization employed.
It should be appreciated that while system 400 of
Furthermore, conventional model-view-controller patterns focus on a single model with one or more views. Here, the opposite is true, where one view is to be employed over one or more models (albeit not necessarily at the same time). For example, web browsers may implement a document object model in slightly different manners. However, any differences or idiosyncrasies can be avoided by interacting with a single view or associated object model.
Turning to
What has been presented is a spectrum of possibilities relating to employment of imperative or alternate object model over or as a proxy for an imperative object model. Specifically, interactions can vary in degrees between loose and tight coupling. For example, employment of a model-view-controller pattern is looser in coupling than a wrapper pattern but tighter than simple serialization or transformation between constructs. It is to be appreciated that this is only a sample of the manners in which object models can interact. Other systems, architectures, and/or design patters are also possible and are to be deemed within the scope of innovation including but not limited to bridge, facade or proxy patterns.
Interactions between object models including transformations, translations, conversions or the like can be embodied or implemented by extension methods or the like in accordance with one aspect of the claimed subject matter. Extension methods enable new methods to be added to types or classes without requiring recompilation of the original type. This is especially helpful where an object model or functionality associated there with is inaccessible or unable to be modified.
In particular, it may be desirable to connect two different object models, APIs or the like that are designed and implemented completely independent of each other. In other words, they are unaware of each other. Extension methods provide a mechanism to make this connection after the fact. The object models, APIs, or the like can be related without changing them.
Furthermore and in accordance with an aspect of the disclosure, an object model sought to be employed as a view over another object model can generate events that aid in building a bridge between the models. For example, an event can be raised or fired just before something is changed and after the change is complete. Since events are fired just before and after a change, the difference or delta can be computed to identify what has changed. Using event handlers, changes can be made to an underlying model state, structure, or representation. By way of example and not limitation, in a model-view-controller pattern changes in the view can be detected by raised events, which can subsequently be employed to update the model.
It is also to be appreciated that conversions, transformations, translations, or the like can leverage functionality exposed by an underlying object model, API and/or the like. For example, the open method of the “XMLHTTP” object of an underlying document object model can be considered an asynchronous factory method for DOM trees. Where a compositional or alternative object model does not support such asynchronous processing but rather is synchronous in nature, a transformation can expose and/or leverage such functionality in the underlying DOM.
The aforementioned systems, architectures, and the like have been described with respect to interaction between several components. It should be appreciated that such systems and components can include those components or sub-components specified therein, some of the specified components or sub-components, and/or additional components. Sub-components could also be implemented as components communicatively coupled to other components rather than included within parent components. Further yet, one or more components and/or sub-components may be combined into a single component to provide aggregate functionality. Communication between systems, components and/or sub-components can be accomplished in accordance with either a push and/or pull model. The components may also interact with one or more other components not specifically described herein for the sake of brevity, but known by those of skill in the art.
Furthermore, as will be appreciated, various portions of the disclosed systems above and methods below can include or consist of artificial intelligence, machine learning, or knowledge or rule based components, sub-components, processes, means, methodologies, or mechanisms (e.g., support vector machines, neural networks, expert systems, Bayesian belief networks, fuzzy logic, data fusion engines, classifiers . . . ). Such components, inter alia, can automate certain mechanisms or processes performed thereby to make portions of the systems and methods more adaptive as well as efficient and intelligent. By way of example and not limitation, such mechanisms can be employed to automatically infer transformations representations and/or leverage functionality associated with an underlying implementation.
In view of the exemplary systems described supra, methodologies that may be implemented in accordance with the disclosed subject matter will be better appreciated with reference to the flow charts of
Referring to
By way of example and not limitation, consider a scenario in which it is desired that an XML document be dynamically produced for a page within a web browser, and the document object model associated with the browser affords an imperative API for such purpose. While this can certainly be employed to produce the XML document, it is not the most developer friendly manner of document production due to the rigid and convoluted nature of imperative programming. Alternatively, a compositional object model and/or associated API can be targeted to take advantage of the declarative and/or compositional nature of compositional programming. Subsequently, compositional actions and/or state can be transformed into the imperative world. For instance, compositional API calls can be transformed to imperative API calls or a produced document can be transformed or serialized to an imperative structure.
Disclosed aspects have been described with respect to a browser DOM and compositional XML object model to facilitate clarity and understanding. It is to be appreciated that there are various other concrete instances that benefit from implementing a compositional object model or the like over an imperative object model. By way of example and not limitation, consider an imperative API associated with generation of graphical user interface elements such as buttons that requires a specific form or sequence of actions to construct the elements and a compositional API designed for a similar purpose. Where one desires to construct elements in more of a declarative and compositional manner, the compositional API can be layered on top of the imperative API.
Further yet, aspects of the disclosure are applicable to any scenario in which one representation is viewed as or through another representation. In other words, there can be an abstraction and an implementation. By way of example and not limitation, there is applicability to versioning. Suppose there is a first version of a library and a newer second version of the library and one desires that individuals program against the newer second version but in terms of the old first version.
The word “exemplary” or various forms thereof are used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other aspects or designs. Furthermore, examples are provided solely for purposes of clarity and understanding and are not meant to limit or restrict the claimed subject matter or relevant portions of this disclosure in any manner. It is to be appreciated that a myriad of additional or alternate examples of varying scope could have been presented, but have been omitted for purposes of brevity.
As used herein, the term “inference” or “infer” refers generally to the process of reasoning about or inferring states of the system, environment, and/or user from a set of observations as captured via events and/or data. Inference can be employed to identify a specific context or action, or can generate a probability distribution over states, for example. The inference can be probabilistic—that is, the computation of a probability distribution over states of interest based on a consideration of data and events. Inference can also refer to techniques employed for composing higher-level events from a set of events and/or data. Such inference results in the construction of new events or actions from a set of observed events and/or stored event data, whether or not the events are correlated in close temporal proximity, and whether the events and data come from one or several event and data sources. Various classification schemes and/or systems (e.g., support vector machines, neural networks, expert systems, Bayesian belief networks, fuzzy logic, data fusion engines . . . ) can be employed in connection with performing automatic and/or inferred action in connection with the subject innovation.
Furthermore, all or portions of the subject innovation may be implemented as a method, apparatus or article of manufacture using standard programming and/or engineering techniques to produce software, firmware, hardware, or any combination thereof to control a computer to implement the disclosed innovation. The term “article of manufacture” as used herein is intended to encompass a computer program accessible from any computer-readable device or media. For example, computer readable media can include but are not limited to magnetic storage devices (e.g., hard disk, floppy disk, magnetic strips . . . ), optical disks (e.g., compact disk (CD), digital versatile disk (DVD) . . . ), smart cards, and flash memory devices (e.g., card, stick, key drive . . . ). Additionally it should be appreciated that a carrier wave can be employed to carry computer-readable electronic data such as those used in transmitting and receiving electronic mail or in accessing a network such as the Internet or a local area network (LAN). Of course, those skilled in the art will recognize many modifications may be made to this configuration without departing from the scope or spirit of the claimed subject matter.
In order to provide a context for the various aspects of the disclosed subject matter,
With reference to
The system memory 1116 includes volatile and nonvolatile memory. The basic input/output system (BIOS), containing the basic routines to transfer information between elements within the computer 1112, such as during start-up, is stored in nonvolatile memory. By way of illustration, and not limitation, nonvolatile memory can include read only memory (ROM). Volatile memory includes random access memory (RAM), which can act as external cache memory to facilitate processing.
Computer 1112 also includes removable/non-removable, volatile/non-volatile computer storage media.
The computer 1112 also includes one or more interface components 1126 that are communicatively coupled to the bus 1118 and facilitate interaction with the computer 1112. By way of example, the interface component 1126 can be a port (e.g., serial, parallel, PCMCIA, USB, FireWire . . . ) or an interface card (e.g., sound, video, network . . . ) or the like. The interface component 1126 can receive input and provide output (wired or wirelessly). For instance, input can be received from devices including but not limited to, a pointing device such as a mouse, trackball, stylus, touch pad, keyboard, microphone, joystick, game pad, satellite dish, scanner, camera, other computer and the like. Output can also be supplied by the computer 1112 to output device(s) via interface component 1126. Output devices can include displays (e.g., CRT, LCD, plasma . . . ), speakers, printers and other computers, among other things.
The system 1200 includes a communication framework 1250 that can be employed to facilitate communications between the client(s) 1210 and the server(s) 1230. The client(s) 1210 are operatively connected to one or more client data store(s) 1260 that can be employed to store information local to the client(s) 1210. Similarly, the server(s) 1230 are operatively connected to one or more server data store(s) 1240 that can be employed to store information local to the servers 1230.
Client/server interactions can be utilized with respect to various aspects of the claimed subject matter. By way of example and not limitation, one or more components can function as a network or web service provided by one or more servers 1230 to one or more clients 1210 across the communication framework 1250. For instance, transformation logic that provides a bridge between object models or the like can be embodied as a web service. Furthermore, where loosely coupled or decoupled architectures, design patters or the like are employed a view and a model or an abstraction and an implementation can be resident on different servers 1230 and/or clients 1210 and communicate by way of the communication framework 1250.
What has been described above includes examples of aspects of the claimed subject matter. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the claimed subject matter, but one of ordinary skill in the art may recognize that many further combinations and permutations of the disclosed subject matter are possible. Accordingly, the disclosed subject matter is intended to embrace all such alterations, modifications and variations that fall within the spirit and scope of the appended claims. Furthermore, to the extent that the terms “includes,” “contains,” “has,” “having” or variations in form thereof are used in either the detailed description or the claims, such terms are intended to be inclusive in a manner similar to the term “comprising” as “comprising” is interpreted when employed as a transitional word in a claim.