1 / 46

OpenGOOP Inheritance Project

OpenGOOP Inheritance Project. As presented by Jim Kring November 4th, 2003. What is OpenGOOP?. OpenGOOP is OpenG's version of GOOP that's 100% pure G and Open Source Provides Data encapsulation and multiple instances by reference. Visit http://OpenG.org/opengoop/ for more info.

ciqala
Download Presentation

OpenGOOP Inheritance Project

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenGOOP Inheritance Project As presented by Jim Kring November 4th, 2003

  2. What is OpenGOOP? • OpenGOOP is OpenG's version of GOOP that's 100% pure G and Open Source • Provides Data encapsulation and multiple instances by reference. • Visit http://OpenG.org/opengoop/ for more info. OpenG Group Meeting

  3. Who’s working on it • Niels Harre • Jean-Pierre Drolet • Jim Kring • others… OpenG Group Meeting

  4. Presentation Outline • What is inheritance? • Why is inheritance important? • How can we do OpenGOOP Inheritance OpenG Group Meeting

  5. What is inheritance? • Inheritance Nomenclature • VI Server Analogy (What LabVIEW User’s already know about Inheritance) • Inheritance of Attributes and Methods • Class Type • Polymorphism • Encapsulation OpenG Group Meeting

  6. Inheritance Nomenclature • Inheritance defines the relationship “is a” (as compared with “has a”). • It allows a class to inherit the attributes and methods of another class. OpenG Group Meeting

  7. OpenGOOP Inheritance Nomenclature • OpenG has adopted a “familial” inheritance terminology. • Parent, Child • Ancestor, Descendant • There many other nomenclatures used by many other programming languages... OpenG Group Meeting

  8. Other Inheritance Nomenclatures • parent class • superclass (smalltalk) • base class (C++) • child class • subclass (smalltalk) • derived class (C++) OpenG Group Meeting

  9. Inheritance and VI Server • LabVIEW users are already familiar (to some degree) with Inheritance, from experience with VI Server Object References. • All LV objects inherit from “Generic” • Front Panel “Controls” inherit from GObject which inherits from “Generic” OpenG Group Meeting

  10. VI Server Obj Inheritance (cont'd) • Not only do descendants inherit from ancenstors but they also “extend” them. • Control “extends” Gobject • Gobject “extends” Generic OpenG Group Meeting

  11. Inheritance of Attributes & Methods • A child class inherits the publicly accessible properties and methods of its parent. • A child class can add its own properties and methods. This “extends” the parent class. OpenG Group Meeting

  12. Class Type • Each class has a type. • Each object has a type. • The type of an object may be more specific than the type of the wire that it is flowing through. • We can make wires more specific, or more general by type coercion/casting… OpenG Group Meeting

  13. Class Type Coercion No Coercion of GObject (least common) Refnum • Descendants will coerce to an ancestor type. • Once coerced, we can only access properties and methods of the "less specific” class Generic is least common, here OpenG Group Meeting

  14. Upcasting and Downcasting Types • Again, Objects “know” their type, even when contained in a more generic reference type. • We can convert a generic typed wire to a more specific type, using “To More Specific Class”. OpenG Group Meeting

  15. Why not just TypeCast RefNums? • What if the object is not of the more specific class type? Run-Time Error 1057 occurred at To More Specific Class in MakeStrict.vi Possible reason(s): LabVIEW: Type mismatch: Object cannot be typecasted to the specified type. Run-Time Error 1058 occurred at Property Node (arg 1) in MakeStrict.vi Possible reason(s): LabVIEW: Specified property not found. No Error Checking on TypeCast OpenG Group Meeting

  16. RefNums are Analagous to Variants • Variants have Data and Type Descriptor • Refnums have Data and Class ID/Name In both cases: • the type of an object isn't known until run time. • run-time type/error checking is required. OpenG Group Meeting

  17. Polymorphism (Dynamic Dispatch) • A public method may be declared a Virtual Method. • Virtual Methods are placeholders (think call by reference/plug-in) • The Virtual Method dynamically calls the youngest descendant’s method of the same name. OpenG Group Meeting

  18. Polymorphism (Dynamic Dispatch) • A Virtual Method (generic function) can operate on many classes of objects (different types), because the specific class will provide the “real” method (at run-time). • This differs from LabVIEW’s “Polymorphic VIs” which require all types to be known at edit time… OpenG Group Meeting

  19. Static Polymorphism vs Virtual Methods • Static Polymorphism means that the VI must know how to handle all possible types ahead of time. • Virtual Method Polymorphism means that the class of the object received by a VI at run-time provides the implimentation and the VM dynamically invokes the class's VI. (think plug-in) OpenG Group Meeting

  20. Encapsulation • Classes Can have private and protected data • Private data is not visible (readable) outside the class, not even by descendants. • Protected data is visible (readable) by descendants, but descendants cannot write to an ancestors protected data. OpenG Group Meeting

  21. Why is Inheritance Important? • Advanced Software Reuse • Class Inheritance • Forward Compatibility through Polymorphism • Software Engineering • Design Patterns • UML • CASE Tools OpenG Group Meeting

  22. Advanced Software Reuse • Inheritance - We can reuse an existing class by inheriting from it and customizing it to suite our more specific needs. Upgrading an ancestor automatically upgrades all descendants. • Polymorphism - We can create generic tools that will operate on classes that don’t yet exist! This is forward compatibility. OpenG Group Meeting

  23. Software Engineering • Inheritance will open up new worlds in LabVIEW Software development. Computer Scientist and Software Engineers have been doing OOP for a long while so the roadmaps already exist. • Design Patterns • UML • CASE Tools OpenG Group Meeting

  24. Design Patterns* Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice. -- Christopher Alexander, architect and professor emeritus at Berkeley * But, most of these patterns require inheritance and polymorphism (virtual methods) in order to implement. OpenG Group Meeting

  25. Design Patterns • Creational Patterns • Abstract Factory • Builder • Factory Method • Monostate • Prototype • Singleton • Behavioral Patterns • Balking • Chain Of Responsibility • Command • Hierarchical Visitor • Interpreter • Lock • Mediator • Memento • Observer • Scheduled Task • State • Strategy • Template Method • Visitor • Structural Patterns • Adapter • Bridge • Composite • Decorator • Designs • Facade • Flyweight • Iterator • Proxy • Retrofit Interface OpenG Group Meeting

  26. Unified Modeling Language (UML) The Unified Modeling Language (UML) is the industry-standard language for specifying, visualizing, constructing, and documenting the artifacts of software systems. It simplifies the complex process of software design, making a "blueprint" for construction. OpenG Group Meeting

  27. UML – at a glance • Class Diagram and so many others… OpenG Group Meeting

  28. CASE Tools Computer Aided Software Engineering Tools provide environments for developing models and often times integrate with a development environment to automate code generation. OpenG Group Meeting

  29. LabCASE? • With LabVIEW Scripting on the horizon, maybe we will someday have CASE tools that integrate with LabVIEW. • Today, use of class/pattern templates may be a stop-gap solution OpenG Group Meeting

  30. OpenGOOP Inheritance OpenGOOP Inheritance Roadmap: • Define requirements and features • Options and their feasibility • Analyze options and define specification • Development and release Actually, there’s a lot happening in parallel! OpenG Group Meeting

  31. Requirements and Features • Single inheritance • Encapsulation - Protected and Private Object Attributes • Dynamic Dispatch to Virtual Methods • Descendants can override Virtual Methods of ancestors • Descendents can extend Virtual Methods and VM implementations of ancestors • Data access interface should abstract storage implementation • Must be able to implement Certain OOP Design Patterns (GHJV) OpenG Group Meeting

  32. Options • Refnum • Object Data Store • Virtual Method • Encapsulation OpenG Group Meeting

  33. Refnum • One Option – use the same Refnum type for all classes in a hierarchy? • OpenGOOP Inheritance will use the Class Type Inheritance Refnum which exhibits coercion properties similar to VI Server RefNums… OpenG Group Meeting

  34. Class Type Inheritance RefNum • Uses Variant Coercion within clusters… OpenG Group Meeting

  35. CTIR - Coercion • Uses Variant Coercion within clusters… Upcasting Works, but downcasting doesn’t OpenG Group Meeting

  36. CTIR – Sister Classes • Note that sister classes don’t coerce, and they shouldn’t. OpenG Group Meeting

  37. CTIR - Coercion Example OpenG Group Meeting

  38. Object Data Store • Same a OpenGOOP – Reentrant LV2 Global Called By Reference (RLV2GCBR) • Each Class stores its own data. • Inherited data is obtained from the parent class, which obtained from its parent, etc. • CTIR is used to store individual class references. OpenG Group Meeting

  39. Virtual Methods • The Virtual Method looks for a descendant implementation OpenG Group Meeting

  40. Method Registration • At object construction time, each class populates a method table, caches it, and passes it to its parent. The parent populates it, caches it, and passes it to its parent, and so on. OpenG Group Meeting

  41. Method Implementation Look-up • Look up method from Virtual Methods Cluster OpenG Group Meeting

  42. Extending Methods • A method can call an ancestor’s implementation, to avoid rewriting code. OpenG Group Meeting

  43. Encapsulation • Inheritance Data • Public, Protected, Private OpenG Group Meeting

  44. OpenGOOP Inheritance Example • Drawing Geometric Figures… OpenG Group Meeting

  45. A Wizard • … OpenG Group Meeting

  46. Recap… • We need inheritance! • Then we can do SW Engineering! • OpenG is trying to find the most natural framework for G. • Join in… OpenG Toolkit Developers List OpenG.org >> Navigate >> Developers >> Mailing List OpenG Group Meeting

More Related