Java in the Box: Implementing the BoxScript Component Language Yi Liu Electrical Engineering and Computer Science South Dakota State University H. Conrad.

Slides:



Advertisements
Similar presentations
Abstract Class and Interface
Advertisements

Keeping Secrets Within a Family: Rediscovering Parnas H. Conrad Cunningham Computer & Information Science, University of Mississippi Cuihua Zhang Computer.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Intro to OOP with Java, C. Thomas Wu Inheritance and Polymorphism
Inheritance Java permits you to use your user defined classes to create programs using inheritance.
Encapsulation by Subprograms and Type Definitions
1 Chapter 6 Inheritance, Interfaces, and Abstract Classes.
UML Class Diagram: class Rectangle
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
Chapter 10 Classes Continued
Inheritance using Java
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Chapter 11 Inheritance and Composition. Chapter Objectives Learn about inheritance Learn about subclasses and superclasses Explore how to override the.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Programming With Java ICS201 University Of Ha’il1 Chapter 8 Polymorphism and Abstract Classes.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Computer Science and Engineering College of Engineering The Ohio State University Interfaces The credit for these slides goes to Professor Paul Sivilotti.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Inheritance Objectives: Creating new classes from existing classes The protected modifier Creating class hierarchies Abstract classes Indirect visibility.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
Chapter 7: Class Inheritance F Superclasses and Subclasses F Keywords: super and this F Overriding methods F The Object Class F Modifiers: protected, final.
Computer Science 209 Software Development Inheritance and Composition.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 11 Inheritance and Polymorphism.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Evolve What is a Component? A component is a unit of software that can be instantiated, and uses interfaces to describe which services it provides and.
21. PHP Classes To define a class, use the keyword class followed by the name and a block with the properties and method definitions Properties are declared.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Object Oriented Programming in Java Habib Rostami Lecture 10.
This In Java, the keyword this allows an object to refer to itself. Or, in other words, this refers to the current object – the object whose method or.
Lecture 5:Interfaces and Abstract Classes Michael Hsu CSULA.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Multiple inheritance Composition Interfaces Polymorphism Inheritance in Java (part 2)
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Java Interfaces CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University (see Chapter 9 of.
Modern Programming Tools And Techniques-I
Web Design & Development Lecture 9
Sections Inheritance and Abstract Classes
Objects as a programming concept
Inheritance and Polymorphism
Tutorial on BoxScript: A Component-Oriented Language
Chapter 3: Using Methods, Classes, and Objects
Packages, Interfaces & Exception Handling
UML Class Diagram: class Rectangle
Interface.
Week 6 Object-Oriented Programming (2): Polymorphism
CSE 1020:Programming by Delegation
ITEC 3220A Using and Designing Database Systems
Inheritance and Polymorphism
CIS 199 Final Review.
OOP Aga private institute for computer science 5th grade
Lecture 10 Concepts of Programming Languages
INTERFACES Explained By: Sarbjit Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Presentation transcript:

Java in the Box: Implementing the BoxScript Component Language Yi Liu Electrical Engineering and Computer Science South Dakota State University H. Conrad Cunningham Computer and Information Science University of Mississippi

2 Software Components

3 Components – A Closer Look Component1 provided required interface inner component Component2 required provided

4 A Simple Example Discounting CalPrice Discounting2 Compositionality Flexibility StoragePricing Discounting Storage Discounting2

5 Key Concepts Interface Interface (type) Interface (type) –Java interface gives operation signatures Provided interface Provided interface –describes operations the component implements that other components may use Required interface Required interface –describes operations the component uses that must be implemented by another component Price.java public interface Price { double getPrice(int client, int item, int quantity); }

6 Key Concepts Box A box is a component A box is a component –whose description includes provided and required interfaces –has 1..n provided interfaces –has 0..m required interfaces Boxes may be Boxes may be –abstract –concrete atomic atomic compound compound Box … P 1 Pn … R 1 Rn 1…n 0…m

7 Key Concepts Abstract Box Abstract box Abstract box –does not implement provided interfaces –implemented by concrete boxes PricingAbs.box abstract box PricingAbs { provided interface Price Pr; required interface Discount Dc, required interface Discount Dc, PriceRetrieve PrRt; PriceRetrieve PrRt;} Interface type Interface Handle Price Pr PricingAbs Discount Dc PriceRetrieve PrRt

8 Key Concepts Concrete Box Atomic box Atomic box –does not contain any other boxes –implements the provided interfaces Pricing.box box Pricing implements PricingAbs { provided interface Price Pr; required interface Discount Dc; required interface Discount Dc;} Interface handle Interface type Price Pr Pricing Discount Dc PriceRetrieve PrRt

9 Key Concepts Interface Implementation for Atomic Box PrImp.java public class PrImp implements Price { private BoxTop _box; Discount dc; // required interface Discount dc; // required interface PriceRetrieve prRt; //required interface PriceRetrieve prRt; //required interface public PrImp(BoxTop myBox) public PrImp(BoxTop myBox) { _box = myBox; { _box = myBox; InterfaceName name = new InterfaceName("Dc"); InterfaceName name = new InterfaceName("Dc"); dc = (Discount)_box.getRequiredItf(name); dc = (Discount)_box.getRequiredItf(name); name = new InterfaceName(“PrRt"); name = new InterfaceName(“PrRt"); prRt = (PriceRetrieve)_box.getRequiredItf(name); prRt = (PriceRetrieve)_box.getRequiredItf(name); } public double getPrice(int client,int item,int quantity) public double getPrice(int client,int item,int quantity) { double price = prRt.itemPrice(item); { double price = prRt.itemPrice(item); double disc = dc.getDiscount(client, item, quantity); double disc = dc.getDiscount(client, item, quantity); return price * (1 – disc * 0.01) * quantity; return price * (1 – disc * 0.01) * quantity; }} Price Pr Pricing Discount Dc PriceRetrieve PrRt

10 Key Concepts Compound Box Compound box Compound box –Composed from atomic boxes or other compound boxes –Follows composition rules hide provided interfaces unless explicitly exposed hide provided interfaces unless explicitly exposed must expose required interface of constituent unless connected to provided interface of another constituent must expose required interface of constituent unless connected to provided interface of another constituent

11 Key Concepts Compound Box Example box CalPrice implements CalPriceAbs { composed from PricingAbs boxP, DiscountingAbs boxD, StorageAbs boxS ; provided interface Price tPrice from boxP.Pr; provided interface Price tPrice from boxP.Pr; connect boxP.Dc to boxD.Dis, boxP.PrRt to boxS.PrRt; connect boxP.Dc to boxD.Dis, boxP.PrRt to boxS.PrRt;} tPrice Price CalPrice Discount Dis DiscountingAbs boxD box handle PriceRetrieve PrRt StorageAbs boxS Pr PricingAbs boxP Discount Dc Price PriceRetrieve PrRt

12 Key Concepts Box Variant Box variants Box variants –Enable flexibility –Implement same (parent) abstract box –Can be substituted for each other –Conform to their (parent) abstract box provide at least the provided interfaces of parent provide at least the provided interfaces of parent require at most the required interfaces of parent require at most the required interfaces of parent

13 Key Concepts Box Conformity B BAbs P1 P2 P3 IP1 IP2’ IP3 R1R2 IR1 IR2 P1 P2 IP1 IP2 R1R2 IR1’ IR2 IR3 R3 Suppose IP2’ extends IP2 IP2’ extends IP2 IR1’ extends IR1 IR1’ extends IR1 B conforms to BAbs Provided interfaces Required interfaces

14 BoxScript Implementation Box Source Code and Compilation For all boxes For all boxes –interfaces (.java) by user –box description (.box) by user For atomic boxes only For atomic boxes only –interface implementation (.java) by user For concrete boxes only For concrete boxes only –configuration information (.conf) by user –box manager code (.java) by compiler Box code BoxCompiler Java code Java Compiler

15 BoxScript Implementation Box Manager Implementation package declaration package declaration –define filesystem usage import import –interface declarations –data type declarations variable declarations variable declarations –instance variables for class class definition class definition Concrete Box B B.java Box manager

16 BoxScript Implementation Box Runtime Structure > Pricing > Discounting > PrImp > Price > DisImp > Discount implements instantiates constructor Pricing constructor Discounting > CalPrice constructor CalPrice instantiates Pricing instantiates Discounting references Lazy instantiation

17 BoxScript Implementation Box Manager Code Generated by compiler Generated by compiler –to instantiate box instances –to assign references to interface handles

18 BoxScript Implementation Box Manager Implementation Supports lazy instantiation Supports lazy instantiation –BoxTop BoxTop BoxTop() void setProvInterfacceDsc(InterfaceDsc pItfDsc) void setRequInterfaceDsc(InterfaceDsc rItfDsc) Object getProvidedItf(InterfaceName name) Object getRequiredItf(InterfaceName name) void setRequiredItf(InterfaceName iname, Object objRef)

19 BoxScript Implementation Box Manager Implementation Code generation Code generation generateCode (B’dscFile, mngFile) //mngFile : filename for box manager read in dscFile read in dscFile genPackage(); genPackage(); genImports(); genImports(); genVars(); genVars(); genConstructor(); genConstructor(); genGetProvidedItf(); // generate overriding method getProvidedItf genGetProvidedItf(); // generate overriding method getProvidedItf if B is compound if B is compound genSetRequiredItf(); // generate overriding method genSetRequiredItf(); // generate overriding method setRequiredItf setRequiredItf writeIntoFile(mngFile); writeIntoFile(mngFile);

20 Conclusion Component-oriented programming language BoxScript Component-oriented programming language BoxScript –Builds upon Java –Provides novel concepts of box type structure box type structure box variants box variants box conformity box conformity interface satisfaction interface satisfaction to support composition and flexibility

21 Questions