Tutorial on BoxScript: A Component-Oriented Language

Slides:



Advertisements
Similar presentations
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
Advertisements

1 Objectives To introduces the concept of software Design. To introduce the concept of Object- Oriented Design (OOD). To Define various aspects about object.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Abstract Data Types and Encapsulation Concepts
03 - ParnasCSC4071 A Sketchy Evolution of Software Design 1960s –Structured Programming (“Goto Considered Harmful”, E.W.Dijkstra) Emerged from considerations.
Systems Analysis and Design in a Changing World, Fifth Edition
Sadegh Aliakbary Sharif University of Technology Fall 2011.
1 On the Criteria To Be Used in Decomposing Systems into Modules by D.L.Parnas Dec presented by Yuanhua Qu for spring 2003 CS5391.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Java in the Box: Implementing the BoxScript Component Language Yi Liu Electrical Engineering and Computer Science South Dakota State University H. Conrad.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Key Principles of Software Architecture and Design (I) adapted from Dave Penny’s.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Object-Oriented Modeling Chapter 10 CSCI CSCI 1302 – Object-Oriented Modeling2 Outline The Software Development Process Discovering Relationships.
Generative Programming. Automated Assembly Lines.
Systems Analysis and Design in a Changing World, 3rd Edition
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.
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Salman Marvasti Sharif University of Technology Winter 2015.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
1 CS Programming Languages Class 22 November 14, 2000.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
Classes, Interfaces and Packages
72 4/11/98 CSE 143 Abstract Data Types [Sections , ]
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Introduction to Object-oriented Programming
Chapter 10 Thinking in Objects
CompSci 280 S Introduction to Software Development
More Sophisticated Behavior
Programming Logic and Design Seventh Edition
Testing Tutorial 7.
Chapter 10 Thinking in Objects
Abstract Data Types and Encapsulation Concepts
Chapter 10 Thinking in Objects
On the Criteria to Be Used in Decomposing Systems into Modules
Unified Modeling Language
Chapter 3: Using Methods, Classes, and Objects
11.1 The Concept of Abstraction
Prepared by Charlie Meyer, May 2009
Lecture 2 of Computer Science II
Abstract Data Types and Encapsulation Concepts
Component-Level Design
Chapter 9 Thinking in Objects
Abstract Data Types and Encapsulation Concepts
Introduction to Data Structures
Chapter 5 Designing the Architecture Shari L. Pfleeger Joanne M. Atlee
CSE 403: Notkin #2 of 3 on software change
On the Criteria To Be Used in Decomposing Systems into Modules D. L
Chapter 9 Thinking in Objects
An Introduction to Software Architecture
Data Structures and Algorithms for Information Processing
UNIT I OBJECT ORIENTED PROGRAMMING FUNDAMENTALS
Introduction to Data Structure
CIS16 Application Development and Programming using Visual Basic.net
CS 112 Programming 2 Lecture 02 Abstract Classes & Interfaces (2)
Object-Oriented PHP (1)
Module Structure David Parnas Discusses “modularization”
11.1 The Concept of Abstraction
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

Tutorial on BoxScript: A Component-Oriented Language Yi Liu Department of Computer Science

Outline What are Components? How to Componentize a System? What is BoxScript? How to use BoxScript?

Outline What are Components? How to Componentize a System? What is BoxScript? How to use BoxScript?

Software Components

A Simple Example Compositionality Flexibility Pricing Discounting2 CalPrice Compositionality Flexibility

Components – A Closer Look provided required interface inner component Component2

Need extra programming Components vs. Objects Component Object Strong Encapsulation Yes Some Yes Some No Compositionality Need extra programming Flexibility

Outline What are Components? How to Componentize a System? What is BoxScript? How to use BoxScript?

Goals of Component Design Components should be cohesive: all functionality fits together for coherent, easily understandable purpose independent: components are decoupled from each other changeable: implementation of one component can be changed without affecting others Component system should be robust with respect to change Likely changes should affect only a few components Unlikely changes might affect overall structure

Design Guidelines Decomposition: If some design issue is likely to change, hide it inside one component – information hiding Define interfaces of components to be stable in the face of likely changes – abstraction Specification: Precisely define everything one component may assume about another One component should assume no more than necessary about others

Examples Example1 Price Single component CalPrice public interface Price { double getPrice(int client, int item, int quantity); }

Examples Example2 CalPrice Price Discounting Discount

Outline What are Components? How to Componentize a System? What is BoxScript? How to use BoxScript?

BoxScript A language for component-oriented programming

Main Purposes of BoxScript Introducing component concepts Providing simple environment to user Supporting main properties of COP Compositionality Flexibility

Outline What are Components? How to Componentize a System? What is BoxScript? How to use BoxScript?

Key Concepts Built on top of Java Component Box Blackbox entity No externally visible state Only interfaces exposed

Key Concepts Interfaces Java Interface Provided interface Describes operations that a box implements and that other boxes may use Required interface Describes operations that the box uses and that must be implemented by another box Price.java public interface Price { double getPrice(int client, int item, int quantity); }

Key Concepts Boxes General characteristics of boxes Types of boxes Contains the descriptions of provided interfaces and required interfaces (.box) 1..n provided interfaces 0..m required interfaces Types of boxes Abstract box Concrete box Atomic box Compound box Box … P1 Pn R1 Rn 1…n 0…m

Key Concepts Abstract Box No implementations of the provided interfaces Should be implemented by concrete boxes

Key Concepts Abstract Box Example price Pr PricingAbs Discount Dc PricingAbs.box abstract box PricingAbs { provided interfaces Price Pr; required interfaces Discount Dc; } Interface type Interface Handle

Key Concepts Boxes Abstract box Concrete box Atomic box Compound box

Key Concepts Atomic Box Does not contain any other boxes Supplies implementations of the provided interfaces Pricing.box box Pricing implements PricingAbs { provided interfaces Price Pr; required interfaces Discount Dc; } price Pr Pricing Discount Dc Interface type Interface handle

Key Concepts Interface Implementation of Atomic Box Default name for interface implementation: Interface handle name + Imp PrImp.java public class PrImp implements Price { private BoxTop _box; Discount dc; // required interface public PrImp(BoxTop myBox) { _box = myBox; InterfaceName name = new InterfaceName("Dc"); dc = (Discount)_box.getRequiredItf(name); } public double getPrice(int client,int item,int quantity) { double disc = dc.getDiscount(client, item, quantity); return PriceList.p[item] * (1 - disc* 0.01) * quantity; price Pr Pricing Discount Dc

Key Concepts Compound Box Composed from atomic boxes or other compound boxes Follow composition rules By default, all provided interfaces are hidden unless explicitly exposed Expose a required interface of a constituent if not wired to a provided interface of another

Key Concepts Composition Strategy Box1 P11 P12 R11 R12 R13 Box2 P21 P22 R21 R22 Compose to Box1_2 Box1 P11 P12 R11 R12 R13 Box2 P21 P22 R21 R22 P11 P22 R11 R12 R22

Key Concepts Compound Box Example Two boxes price Pr PricingAbs Discount Dc [PricingAbs.box] abstract box PricingAbs { provided interfaces Price Pr; required interfaces Discount Dc; } Discount Dis DiscountingAbs [DiscountingAbs.box] abstract box DiscountingAbs { provided interfaces Discount Dis; }

Key Concepts Compound Box Example (cont.) Compose two boxes box handle box CalPrice implements CalPriceAbs { composed from PricingAbs boxP, DiscountingAbs boxD; provided interfaces Price tPrice from boxP.Pr; connect boxP.Dc to boxD.Dis; } tPrice Price CalPrice Discount Dis DiscountingAbs boxD Pr PricingAbs boxP Discount Dc Price

Box Elements For all boxes For atomic boxes only Interfaces (.java) by user Box description file (.box) by user For atomic boxes only Interface implementation (.java) by user For concrete boxes only Configuration information (.conf) by user Box manager code (.java) by compiler

Box Elements Configuration Information If abstract boxes participate in composition box CalPrice implements CalPriceAbs { composed from PricingAbs boxP, DiscountingAbs boxD; provided interfaces Price tPrice from boxP.Pr; connect boxP.Dc to boxD.Dis; } Directory for Pricing Box Handle Directory for PricingAbs [CalPrice.conf] (boxP, "D:\warehouse_root\boxes\PricingAbs\", "Pricing\Pricing"); (boxD, "D:\warehouse_root\boxes\DiscountingAbs\", "Discounting\Discounting");

Box Elements Configuration Information If concrete boxes participate in composition box CalPrice implements CalPriceAbs { composed from Pricing boxP, Discounting boxD; provided interfaces Price tPrice from boxP.Pr; connect boxP.Dc to boxD.Dis; } [CalPrice.conf] (boxP, "D:\warehouse_root\boxes\PricingAbs\Pricing\Pricing"); (boxD, "D:\warehouse_root\boxes\DiscountingAbs\Discounting\Discounting");

Box Elements Configuration Information Configuration for interface implementation when implementation file name is not default [Pricing.box] box Pricing implements PricingAbs { provided interfaces Price Pr; required interfaces Discount Dc; } Box Pricing has Priceimp.java implementing interface type Price. [Pricing.conf] (Pr, “Priceimp”); Implementation location Interface Handle

Box Elements Box Manager Code Generated by compiler To initiate box instances To assign references to interface handles

Box Run-time Structure <<Java class >> Pricing <<Java class >> Discounting <<Java class >> PrImp <<interface >> Price <<Java class >> DisImp <<interface >> Discount implements instantiates constructor Pricing constructor Discounting <<Java class >> CalPrice constructor CalPrice instantiates Pricing instantiates Discounting references

Box Processing Stages Locate Compile

Locate warehouse_root boxes interfaces datatypes

Locate Warehouse_root boxes CalPriceAbs PricingAbs DiscountingAbs CalPriceAbs.box PricingAbs.box DiscountingAbs.box CalPrice Pricing Discounting1 Discounting CalPrice.boxCalPrice.conf CalPrice.java Pricing.box PrImp.java Discounting1.box Disimp1.java Discounting.box DisImp.java

Locate For an atomic box, the implementation of an interface needs to specify the full path of its package name import interfaces and datatypes [d:\warehouse_root\boxes\PricingAbs\Pricing\PrImp.java] package boxes.PricingAbs.Pricing; import interfaces.Price; Import interfaces.Discount; Import datatypes. systems.*; public class PrImp implements Price { private BoxTop _box; Discount dc; // required interface public PrImp(BoxTop myBox) { _box = myBox; } ….. ….

Locate Warehouse_root interfaces Price.java Discount.java

Locate [d:\warehouse_root\interfaces\Discount.java] package interfaces; public interface Discount { double getDiscount(int client, int item, int quantity); }

Locate Warehouse_root datatypes PriceList.java

Locate package datatypes; public final class PriceList extends Object [d:\warehouse_root\datatypes\PriceList.java] package datatypes; public final class PriceList extends Object { public static double [] p = new double [] { 120.00, 14.45, 16.99, 23.78, 130.89, 239.99, 18.99, 234.70, 3.99, 6.78, 76.50, 1299.99, 34.67, 54.20, 67.89, 89.10, 17.50, 22.70 }; }

Compile BoxCompiler Implemented in BoxScript Checks the syntax of the source code Generates box manager code Usage boxc <box descrption> Eg. boxc <dir>CalPrice.box

Box Variants Support flexibility Variants One box is variant of another if implementations of same abstract box One box variant can be substituted by another variant where their abstract box is used Variant should conform to its abstract box

Box Conformity B conforms to BAbs Suppose IP2’ extends IP2 IR1’ extends IR1 IP1 IP2’ IP3 IP1 IP2 Provided interfaces P1 P2 P3 P1 P2 B BAbs R1 R2 Required interfaces R1 R2 R3 IR1 IR2 IR1’ IR2 IR3 B conforms to BAbs

Box Variant Example PricingAbs DiscountingAbs Pricing Pricing2 variants

Replacing Components box CalPrice implements CalPriceAbs { composed from PricingAbs boxP, DiscountingAbs boxD; provided interfaces Price tPrice from boxP.Pr; connect boxP.Dc to boxD.Dis; } [CalPrice.conf] (boxP, "D:\warehouse_root\boxes\PricingAbs\”, ”Pricing\Pricing"); (boxD, "D:\warehouse_root\boxes\DiscountingAbs\”, ”Discounting\Discounting"); Now, we want to use Pricing1 to substitute for Pricing

Replacing Components Things we need to do: Update conf file for CalPrice Re-compile CalPrice [CalPrice.conf] (boxP, "D:\warehouse_root\boxes\PricingAbs\”,”Pricing1\Pricing1"); (boxD, "D:\warehouse_root\boxes\DiscountingAbs\”,”Discounting\Discounting");

Demo Make an abstract box Make an atomic box Make a compound box

Example – KWIC Key Word In Context Accepts an ordered set of lines each line is an ordered set of words Circularly shifts each line repeatedly removes first word and appends it at end of line Outputs all lines in alphabetical order

Example – KWIC Key Word In Context Key Word In Context Word In context Key In context Key Word context Key Word In BoxScript example example BoxScript input Key Word In Context BoxScript example Circularly shift alphabetize BoxScript example In context Key Word Key Word In Context Word In context Key context Key Word In example BoxScript output

Example – KWIC Design Decisions [Parnas 72] Changes in algorithm Changes in data representation

Example – KWIC Design I Master Control Input Output Circular Shift Alphabetizing Output Procedure call

Example – KWIC Possible changes Input format Have lines partially stored in memory Take different formats for Word Partially alphabetize lines

Example – KWIC Design II Master Control Input Output Circular Shift Alphabetizing Line Storage Datatype word

Example – KWIC Design II Master Control Input Output Circular Shifter getLine Get ith Line Input Output Circular Shifter Alphabetizer Line Storage Datatype word

Example – KWIC Possible changes Input format Have lines partially stored in memory Take different formats for Word Partially alphabetize lines

KWIC in BoxScript Master Control Input Output Circular Shifter Alphabetizer Output Line Storage Datatype word IAccessLineStore IWriteLineStore ILine ICircularShift IReadIn IAlphabetizer IWriteOut IKwic KWIC