News Column

Patent Issued for Instantiating an Interface Or Abstract Class in Application Code

September 11, 2014



By a News Reporter-Staff News Editor at Computer Weekly News -- A patent by the inventors Barcia, Roland (Leonia, NJ); Bhogal, Kulvir S. (Pflugerville, TX); Hambrick, Geoffrey M. (Round Rock, TX); Peterson, Robert R. (Austin, TX), filed on May 10, 2012, was published online on August 26, 2014, according to news reporting originating from Alexandria, Virginia, by VerticalNews correspondents.

Patent number 8819650 is assigned to International Business Machines Corporation (Armonk, NY).

The following quote was obtained by the news editors from the background information supplied by the inventors: "The present application relates generally to an improved data processing system and method. More specifically, the present application is directed to a system and method for instantiating an interface or abstract class in application code.

"In object-oriented programming, classes are used to group related variables and functions. A class describes a collection of encapsulated instance variables and methods (functions), possibly with implementation of those types together with a constructor function that can be used to create objects of the class.

"A class is a cohesive package that consists of a particular kind of compile-time metadata. A class describes the rules by which objects, i.e. instances of the class, behave. The class specifies the structure of data which each instance of the class, i.e. an object, contains as well as the methods which manipulate the data of the object and perform tasks. A method is a function with a special property that it has access to data stored in an object.

"Instances of a class, i.e. objects, will have certain aspects, i.e. features, attributes or properties, in common. One of the benefits of programming with classes is that all instances of a particular class will follow the defined behavior of the class they instantiate.

"A class can 'implement' (or 'realize') multiple interfaces, each of which specify one or more abstract method signatures (name and type of the method and its parameters) which must be defined in that class. Unlike multiple inheritance where actual code is inherited (along with naming and logical conflicts) interfacing allows one to define a behavior-interface (methods) that all classes implementing the interface should be able to fulfill.

"Interfaces are a type of abstract class. Abstract classes, or abstract base classes (ABCs), are classes that are designed only as a parent class and from which child classes may be derived, and which is not itself suitable for instantiation. Concrete classes, on the other hand, are classes for which instances, i.e. objects, may be created. Abstract classes are often used to represent abstract concepts or entities. The incomplete features of the abstract class are then shared by a group of sibling sub-classes which add different variations of the missing pieces.

"Interfaces and abstract classes allow for separation of concerns and inter-operability when architecting and developing applications. The interfaces and abstract classes must be implemented in concrete classes when generating such applications. Such implementation of interfaces and abstract classes requires 'hard coding' of the interface or abstract class implementation in the concrete class. As a result, if the interface or abstract class implementation is to be replaced, a source code update and recompilation would be necessary.

"Consider the following example where an AudioDevice interface is provided and two concrete classes 'Radio' and 'MP3Player' implementing the AudioDevice interface are provided:

"TABLE-US-00001 public interface AudioDevice { public void play( ) throws playbackException; public void stop( ) throws discontinuationException; } public class Radio implements AudioDevice { public void play( ) throws playbackException {...} public void stop( ) throws discontinuationException{...} } public class MP3Player implements AudioDevice { public void play( ) throws playbackException{...} public void stop( ) throws discontinuationException{...} public void shuffle( ) {...} }

"Consider also the following snippet of application source code:

"TABLE-US-00002 ... [36] AudioDevice myStereo = new MP3Player( ); [37] myStereo.play( ); ... [52] myStereo.stop( ); ...

"As shown in the example, the instantiation of the AudioDevice interface requires the specification in the application source code of a concrete class that implements the interface. As a result, if a programmer later wishes to switch to alternate implementations of the AudioDevice interface, the programmer must modify the application source code itself to change the concrete class implementation of the interface. For example, if a new MP3 PDA combination device is to be utilized, a new concrete class for the MP3 PDA combination device must be provided and the application source code must be modified as follows to implement the AudioDevice interface using the new MP3PDA concrete class:

"[36] AudioDevice myStereo=new MP3PDA( );

"Even a single application source code change, such as the one above, still requires new development of application source code and a recompilation of the application source code. Such development and recompilation takes time, effort, and resources to accomplish. This is made even more troublesome when considered in light of modern applications where there may be thousands of lines of application source code."

In addition to the background information obtained for this patent, VerticalNews journalists also obtained the inventors' summary information for this patent: "The illustrative embodiments provide a system and method for instantiating an interface or abstract class in application code. With the mechanisms of the illustrative embodiments, an object-oriented programming language is extended such that interfaces and abstract classes can be instantiated in application code without a concrete class specified. Metadata is defined which maps each interface or abstract class instantiation in the application code to a concrete class to be used either by the compiler at build time, or the virtual machine at runtime. Once the appropriate concrete class is determined from the metadata, the class is instantiated with a conventional class loader. The metadata may be provided, for example, as a separate file, such as a markup language file, defined with a virtual machine switch, as annotations in the application code, or the like.

"In one illustrative embodiment, a method for instantiating an abstract class is provided. The method may comprise providing mapping metadata for mapping an abstract class to a corresponding concrete class implementing the abstract class. The method may further comprise encountering an instantiation statement for the abstract class during processing of application code, the instantiation statement not specifying a concrete class implementing the abstract class. The method may also comprise converting the instantiation statement to specify the concrete class implementing the abstract class based on the mapping metadata. The abstract class may be an interface class. The mapping metadata may be provided as part of a mapping metadata file data structure separate from the application code.

"The mapping metadata may be provided as annotations within the application code. The annotations may be provided at one of a class-level, a method-level, a declaration-level, or a package-level.

"The encountering and converting operations may be performed by a compiler at build-time of the application code. Alternatively, the encountering and converting operations may be performed at runtime by a virtual machine interpreting byte code instructions.

"The application code may be application source code and the mapping metadata may be provided as both annotation metadata provided in the application source code and as mapping metadata provided in a separate mapping metadata file. Conflicts between annotation metadata provided in the application source code and mapping metadata provided in a separate mapping metadata file may be resolved in favor of the mapping metadata provided in the separate mapping metadata file.

"The encountering and converting operations may be performed as part of context checking by a compiler. Moreover, the converting operation may comprise checking for a concrete class mapping in a separate mapping metadata file and checking for a concrete class mapping in application source code annotations if a concrete class mapping is not found in the separate metadata file. The converting operation may be performed using a concrete class mapping found in either the separate mapping metadata file or the application source code annotation.

"In other illustrative embodiments, a computer program product comprising a computer useable medium having a computer readable program is provided. The computer readable program, when executed on a computing device, causes the computing device to perform various ones, and combinations of, the operations outlined above with regard to the method illustrative embodiment.

"In yet another illustrative embodiment, a system is provided. The system may comprise a processor and a memory coupled to the processor. The memory may comprise instructions which, when executed by the processor, cause the processor to perform various ones, and combinations of, the operations outlined above with regard to the method illustrative embodiment

"These and other features and advantages of the present invention will be described in, or will become apparent to those of ordinary skill in the art in view of, the following detailed description of the exemplary embodiments of the present invention."

URL and more information on this patent, see: Barcia, Roland; Bhogal, Kulvir S.; Hambrick, Geoffrey M.; Peterson, Robert R.. Instantiating an Interface Or Abstract Class in Application Code. U.S. Patent Number 8819650, filed May 10, 2012, and published online on August 26, 2014. Patent URL: http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PALL&p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&r=1&f=G&l=50&s1=8819650.PN.&OS=PN/8819650RS=PN/8819650

Keywords for this news article include: International Business Machines Corporation, Object-oriented Programming, Software.

Our reports deliver fact-based news of research and discoveries from around the world. Copyright 2014, NewsRx LLC


For more stories covering the world of technology, please see HispanicBusiness' Tech Channel



Source: Computer Weekly News


Story Tools






HispanicBusiness.com Facebook Linkedin Twitter RSS Feed Email Alerts & Newsletters