Jump to content

Metaobject

From Wikipedia, the free encyclopedia
(Redirected fromMeta-object)

Incomputer science,ametaobjectis anobjectthat manipulates, creates, describes, or implements objects (including itself). The object that the metaobject pertains to is called the base object. Some information that a metaobject might define includes the base object'stype,interface,class,methods,attributes,parse tree,etc. Metaobjects are examples of the computer science concept ofreflection,where a system has access (usually at run time) to its own internal structure. Reflection enables a system to essentially rewrite itself on the fly, to alter its own implementation as it executes.[1]

Metaobject protocol

[edit]

Ametaobject protocol(MOP) provides the vocabulary (protocol) to access and manipulate the structure and behaviour of systems of objects. Typical functions of a metaobject protocol include:[2]

  • Create or delete a new class
  • Create a new property or method
  • Cause a class to inherit from a different class ( "change the class structure" )
  • Generate or change the code defining the methods of a class

Metaobject protocol is contrary toBertrand Meyer'sopen/closed principle,which holds that software object systems should beopen for extensionbutclosed for modification.This principle effectively draws a distinction betweenextendingan object by adding to it, andmodifyingan object by redefining it, proposing that the former is a desirable quality ( "objects should be extensible to meet the requirements of future use cases"), while the latter is undesirable ("objects should provide a stable interface not subject to summary revision"). Metaobject protocol, by contrast, transparently exposes the internal composition of objects and the entire object system in terms of the system itself. In practice, this means that programmers may use objects to redefine themselves, possibly in quite complex ways.

Furthermore, metaobject protocol is not merely aninterfaceto an "underlying" implementation; rather, through metaobject protocol the object system isrecursively implementedin terms of ameta-object system, which itself is theoretically implemented in terms of ameta-metaobject system, and so on until an arbitrarybase case(a consistentstateof the object system) is determined, with the protocol as such being the recursive functional relationship between these implementation levels.

Implementing object systems in such a way opens the possibility for radical discretionary redesign, providing deep flexibility but introducing possibly complex or difficult-to-understand metastability issues (for instance, the object system must notdestructively updateits own metaobject protocol - its internal self-representation - but the potential destructiveness of some updates is non-trivial to predict and may be hard to reason about), depending on the recursive depth to which the desired modifications are propagated.[3]For this reason, metaobject protocol, when present in a language, is usually used sparingly and for specialised purposes such as software that transforms other software or itself in sophisticated ways, for example in reverse engineering.[4]

Runtime and compile time

[edit]

When compilation is not available at run-time there are additional complications for the implementation of metaobject protocol. For example, it is possible to change the type hierarchy with such a protocol but doing so may cause problems for code compiled with an alternative class model definition. Some environments have found innovative solutions for this, e.g., by handling metaobject issues at compile time. A good example of this isOpenC++.[5] TheSemantic Webobject-oriented model is more dynamic than most standard object systems, and is consistent with runtime metaobject protocols. For example, in the Semantic Web model classes are expected to change their relations to each other and there is a specialinference engineknown as a classifier that can validate and analyze evolving class models.[6]

Usage

[edit]

The first metaobject protocol was in theSmalltalkobject-oriented programming language developed atXerox PARC.TheCommon Lisp Object System(CLOS) came later and was influenced by the Smalltalk protocol as well as byBrian C. Smith's original studies on 3-Lisp as an infinite tower of evaluators.[7]The CLOS model, unlike the Smalltalk model, allows a class to havemore than one superclass;this raises additional complexity in issues such as resolving the lineage of the class hierarchy on some object instance. CLOS also allows fordynamic multimethod dispatch,which is handled viageneric functionsrather thanmessage passinglike in Smalltalk'ssingle dispatch.[8]The most influential book describing the semantics and implementation of the metaobject protocol in Common Lisp isThe Art of the Metaobject ProtocolbyGregor Kiczaleset al.[9]

Metaobject protocols are also extensively used in software engineering applications. In virtually all commercial CASE, re-engineering, and Integrated Development Environments there is some form of metaobject protocol to represent and manipulate the design artifacts.[10][11][12]

A metaobject protocol is one way to implementaspect-oriented programming.Many of the early founders of MOPs, includingGregor Kiczales,have since moved on to be the primary advocates for aspect-oriented programming. Kiczales et al. ofPARCwere hired to designAspectJforJava,a language which does not possess a native metaobject protocol.

See also

[edit]

References

[edit]
  1. ^Smith, Brian C (1982-01-01)."Procedural Reflection In Programming Languages".MIT Technical Report(MIT-LCS-TR-272). Archived fromthe originalon 13 December 2015.Retrieved16 December2013.
  2. ^Foote, Brian; Ralph Johnson (1–6 October 1989)."Reflective facilities in Smalltalk-80".Conference proceedings on Object-oriented programming systems, languages and applications.pp. 327–335.doi:10.1145/74877.74911.ISBN0897913337.Retrieved16 December2013.
  3. ^The Art of the Metaobject Protocol,Appendix C — Living with Circularity
  4. ^Favre, Lilliana; Liliana Martinez; Claudia Pereira (2009). "MDA-Based Reverse Engineering of Object Oriented Code".Enterprise, Business-Process and Information Systems Modeling.Lecture Notes in Business Information Processing. Vol. 29. Springer. pp. 251–263.doi:10.1007/978-3-642-01862-6_21.ISBN978-3-642-01861-9.
  5. ^Chiba, Shigeru (1995)."A metaobject protocol for C++".Proceedings of the tenth annual conference on Object-oriented programming systems, languages, and applications.pp. 285–299.doi:10.1145/217838.217868.ISBN978-0897917032.S2CID3090058.Retrieved27 December2013.
  6. ^Knublauch, Holger; Oberle, Daniel; Tetlow, Phil; Wallace, Evan (2006-03-09)."A Semantic Web Primer for Object-Oriented Software Developers".W3C.Retrieved2008-07-30.
  7. ^Daniel P. Friedman; Mitchell Wand (1988). "The mystery of the tower revealed: A non-reflective description of the reflective tower".Proceedings of the 1986 ACM conference on LISP and functional programming - LFP '86.pp. 298–307.doi:10.1145/319838.319871.ISBN978-0897912006.S2CID7974739.
  8. ^"Integrating Object-Oriented and Functional Programming"(PDF).Retrieved7 July2016.
  9. ^Kiczales, Gregor; Jim des Rivieres; Daniel G. Bobrow (July 30, 1991).The Art of the Metaobject Protocol.The MIT Press.ISBN978-0262610742.
  10. ^Johnson, Lewis; David R. Harris; Kevin M. Benner; Martin S. Feather (October 1992). "Aries: The Requirements/Specification Facet for KBSA".Rome Laboratory Final Technical Report.RL-TR-92-248.
  11. ^"The Origin of Refine"(PDF).www.metaware.fr.Metaware White Paper. Archived fromthe original(PDF)on 7 January 2014.Retrieved6 January2014.
  12. ^"OMG's MetaObject Facility".omg.org.Object Management Group.Retrieved7 January2014.
[edit]