Design Aspects of the Standard I/O Library. Design with Java:

Size: px
Start display at page:

Download "Design Aspects of the Standard I/O Library. Design with Java:"

Transcription

1 Design Aspects of the Standard I/O Library Design with Java: QUOIN 1208 Massachusetts Avenue, Suite 3 Cambridge, Massachusetts tel: fax: info@quoininc.com web:

2 Design with Java Design Aspects of the Standard I/O Library by David M. Papurt and Jean Pierre LeJacq printed in the Journal of Object-Oriented Programming, September 1996 Introduction This is the first column in a series discussing design in the Java programming language that will appear regularly here in JOOP. Each column will focus on one aspect of design; the topics will be taken from a variety of areas: design elements of the standard Java library; patterns for solving particular design problems adapted to the peculiarities of Java; and fundamental Java language design issues. Providing a variety of compile-time, load-time, and run-time error checks, Java is a relatively safe programming language. Nontheless, experience shows that without satisfactory attention paid to program design, brittle, non-extendible, and error ridden programs likely emerge from a large programming effort, no matter what language is used. This series of columns contain descriptions of techniques that enable program designers and programmers to avoid design errors when writing programs in Java. The idea is to provide designers with sophisticated methods that maximize flexibility, minimize maintenance and debugging efforts, and enable extensions. This first column on Design with Java covers design aspects of the Input/Output (I/O) package java.io included in the Java standard library; the structure and design philosophy of the package are described, and techniques for extending processing and for handling new data types are demonstrated. Package Structure The notion of a stream characterizes I/O in Java. A stream is an ordered sequence of data items either read from some source or written to some destination possibly with processing along the way. The Java I/O package abstracts the various and normally encountered sources, destinations, and processing algorithms: large portions of Java programs can

3 operate on InputStream and OutputStream objects independently of whether the ultimate data source or destination is, for example, a disk file, an in-core array, another thread, or a file across the network and independently of whether the data is buffered, translated, or otherwise processed. The means of this abstraction is based on the patterns of design formed by the classes in the java.io package. Figure 1 shows the pattern of input classes; this configuration of classes is sometimes called decorator or wrapper [1], and includes classes representing the ultimate data source and classes that perform processing of stream data items. The crucial feature of the decorator pattern is the reference source from subclass FilterInputStream to root class InputStream. The arrangement of output classes is similar. The figure uses Object Modeling Technique (OMT) notation [2] as enhanced for description of Design Patterns [1] 1. Figure 1: Java I/O input classes pattern. This design is highly run-time configurable; the decorator pattern generates constellations of objects that look like singly-linked lists and that mix and match ultimate data sources and processing. Figure 2 contains three sample object constellations 2 : figure 2a contains an object constellation that represents an ultimate data source of an in-core array without any additional processing; figure 2b represents a separate thread as ultimate data source via a PipedInputStream object with additional single byte pushback buffer processing; figure 2c adds buffering and typed data interpretation to an unbuffered byte stream from a disk file.

4 Other example processing might uppercase a byte stream from across the network, or might count the number of lines in a stream originating from a disk file. Figures 2a-c: Sample input class object constellations. In each case, an object of a class representing an ultimate data source terminates the list. The constructor for each subclass of FilterInputStream (i.e., the processors or decorators) requires an InputStream as argument to initialize reference source: either an ultimate data source object or another processing class object. An arbitrary number of processing class objects can decorate (i.e., can appear in front of) the ultimate data source. Java code for generating the three sample streams in figure 2 appears below.

5 The program passes streama, streamb, and streamc to methods that read directly from the head decorator. Filter Operation An abstract class, InputStream declares the basic operations that all input stream classes provide: three versions of read() read single bytes and byte arrays, blocking until input is available; skip() skips over bytes in the stream; available() returns the number of bytes available without blocking; and close() closes the stream and releases resources held by the stream. A simplified class declaration appears below. The single byte read() provides the single byte in the first 8 bits of its 32 bit return value. All three versions of read() indicate the end of the data stream with a return value of -1. FilterInputStream implements all of the above operations; these implementations simply forward any request to the object referenced by source, so a direct FilterInputStream object would be transparent 3. For example, FilterInputStream's implementation of the single byte read() operation along with its constructor implementation appear below.

6 A processing class inherits and normally overrides some of FilterInputStream's methods. The normal structure of an overriding processing class method implementation includes the following: * A call to the overridden version of the method (which forwards the request to source), and * Additional processing that corresponds to the semantics of the processing class. Consider class PushbackInputStream's implementation of the single byte read() method along with its constructor and push back method unread() 4.

7 The single byte read() above first checks the push back buffer, and returns the buffer contents if it contains a valid byte; otherwise, the method simply returns the byte read() from the InputStream object referenced by source. Other methods of class PushbackInputStream also manipulate the push back buffer: the array versions of read() likewise check the push back buffer, and possibly place buffer in the first position in the byte array; skip() may ask source to skip one less byte than originally requested; and available() may add one to the number of bytes that source has available. Other java.io processing classes add their own processing. BufferedInputStream, for example, provides transparent data buffering. This class contains a multiple byte array buffer so that nearly all read() requests can be filled directly from this buffer; it makes requests to source for more bytes only when the buffer is empty. This is most useful when

8 the ultimate data source is a disk file, and a single read of a large block of bytes is significantly more efficient than multiple reads of small blocks. Extending Processing By mimicking the java.io processing classes, programmers can extend stream processing in a straightforward way. Consider class UpperCaseInputStream below that subclasses FilterInputStream: This class operates on data streams assumed to comprise text, and insures that all alphabetic characters are upper case when they reach the code manipulaing the stream. UpperCaseInputStream is particulary simple, however more complex processing classes are possible: class GrepInputStream could perform a grep-like search for patterns in text streams, forwarding only those lines that match the pattern and consuming all others; StatsInputStream could could accumulate statistics on, for example, the numbers of words, lines, and punctuation, whitespace, and other characters in a text stream; stream compression and decompression or stream encryption and unencryption processing classes could be written in pairs, subclassing FilterOutputStream as well as FilterInputStream.

9 mark() and reset() Base class InputStream defines three functions for marking a position in a stream so that after some reading has taken place, the stream can be reset, and the just read bytes reread another time. When marksupported() returns true, then the stream implements mark() and reset(); reset() will return the stream to the marked postion so long as no more than readlimit bytes have been read() since the mark(). Methods mark() and reset() are useful in a context where the type of the data in the stream is unknown when the stream is opened (for example a stream might contain simple text vs. HTML text), and some amount of the stream must be consumed in order to determine its type. Once the type of the data in the stream is determined, the stream can be reset() and processed appropriately. The idea of mark() and reset() is valuable, but the problem with the standard library solution is that all input stream classes inherit this capability whether it is sensible or not. A more modular and sensible solution removes the three methods above from class InputStream (or disregards them) and implements the idea as a processing class.

10 Indeed, class MarkAndResetInputStream is semantically like java.io class PushbackInputStream with a larger push back buffer capacity. Handling New Data Types For the most part, this article has presented streams whose data items were limited to type byte (or bytes interpreted as characters). However, a stream is an ordered sequence of data items that can have arbitrary type; a data item read from or written to a stream is not restricted to byte, but can have, in principle, any built-in, library, or user-defined type. This section describes how to accommodate different types of data items in Java streams. One approach represents all values, no matter their type, in text; the java.io processing class PrintStream realizes this approach for output streams.

11 Each method in class PrintStream translates its argument into a sequence of bytes (i.e., characters), and passes those bytes towards the ultimate data destination. The methods that take an Object call tostring() on their argument to perform the translation to text. A second approach to accommodating different types in Java streams passes the binary representation of the value (its raw bytes) towards the ultimate data destination or from the ultimate data source. For example, consider java.io processing class DataInputStream. The methods do no translation of the representation beyond collecting and packaging individual bytes from the source into higher level type values. As it stands, only a fixed set of fundamental types can be handled directly by this approach - only those types with corresponding methods in DataInputStream (and DataOutputStream

12 for output). An indirect approach that builds input and output methods on top of the DataInputStream and DataOutputStream methods accommodates other, non-fundamental types. For example, class DateIO below contains static methods read() and write() for the I/O of java.util class Date 5. A class X that includes a Date object would implement its static read(datainputstream,x) and static write(dataoutputstream,x) methods in part via calls to DateIO.read() and DateIO.write(). More generally, composite types would invariably implement their I/O methods in terms of their components' I/O methods 6. References To Decorated Objects Typically, stream creating code keeps a reference only to the head decorator, and passes this reference to other methods that read from or write to the head. However, in some cases the stream creating code may hold onto and manipulate a reference to an internal object along the decorator list other than the head. This manipulation should almost never include actual reads or writes, but instead should be limited to higher level, control operations. Consider the highly decorated input stream below.

13 The program might mark() the beginning of the stream via the internal object mris, and then consume some data from the DataInputStream dis in the process of determining the type of data in the stream. Once the type of data in the stream is known, the stream must be reset(), and then processed appropriately from its beginning. As a matter of good style, all read() operations are performed only to the head decorator in the composite stream object; reading from an internal object like mris breaks the uncomplicated illusion of a single object accessed via a single reference, and makes the code more difficult to understand. Summary The java.io stream package is highly modular. It uses the decorator design pattern of classes to permit run-time configuration of singly linked lists that mix and match ultimate

14 data source and destination stream objects and processing stream objects. By mimicking the java.io processing classes, programmers can extend stream processing in a straightforward and elegant way; nearly any stream processing can be embedded in a modular processing class. A stream can be adapted to read() or write() data items of arbitrary type; a data item read from or written to a stream is not restricted to type byte, but can have, in principle, any built-in, library, or user-defined type. Footnotes 1 In this notation, a rectangle represents a class, the class name appearing inside the rectangle. The notation for inheritance is a triangle; the superclass connects by a line to the triangle apex, and each subclass connects by individual lines to a line attached to the triangle base. The notation for reference containment is a diamond adjacent the containing class anchoring an arrow pointing at the referenced class. 2 A rounded corner rectangle represents an object; the object's class appears in parentheses. An arrow anchored by a solid circle represents a reference instance. 3 PushbackInputStream implements a single-byte push back buffer useful for implementing lexical analyzers [3]. Having read a byte terminating but not included in the current token, the lexical analyzer can push this byte back onto the stream with unread () so that it is the first byte read when processing the next token. 5 The new class DateIO is created to contain these methods rather than modifying the standard library class Date, because standard library classes should never be modified except by the vendor. 6 Though syntactically distinct, this approach is semantically similar to the approach taken by C++ programmers when overloading operator>>() for input and operator<<() for output. Acknowledgments The authors thank Ron LaBonte of SunU Training for his support. References

15 [1] Gamma, E., R. Helm, R. Johnson, and J. Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, Reading, MA, [2] Rumbaugh, J., M. Blaha, W. Premerlani, F. Eddy, and W. Lorensen, Object-Oriented Modeling and Design, Prentice-Hall, Englewood Cliffs, NJ, [3] Aho, A. V., R. Sethi, and J. D. Ullman, Compilers: Principles, Techniques, and Tools, Addison-Wesley, Reading, MA, Biographies David Papurt is founder of David Papurt Associates, Cambridge, MA, a firm specializing in Java, C++, and object-oriented analysis and design, and is Director of Technology at Terasoft Technology Corp., Milford, MA. He is also author of the highly acclaimed text Inside the Object Model: The Sensible Use of C++ (SIGS Books, 1995). He may be contacted at @compuserve.com. Jean Pierre LeJacq is a founder of Quoin Inc., Cambridge, MA, a company that provides consulting and training services for distributed computing. He may be contacted at jplejacq@quoininc.com article presented with permission of David Papurt Associates Copyright QUOIN, 1997

I/O streams. Byte Streams Character Streams InputStream ByteArrayInputStream FileInputStream FilterInputStream

I/O streams. Byte Streams Character Streams InputStream ByteArrayInputStream FileInputStream FilterInputStream Course Name: Advanced Java Lecture 9 Topics to be covered I/O streams Byte Streams Character Streams InputStream ByteArrayInputStream FileInputStream FilterInputStream Introduction A Stream is a sequence

More information

The Decorator Pattern. Design Patterns In Java Bob Tarr

The Decorator Pattern. Design Patterns In Java Bob Tarr The Decorator Pattern Intent Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. Also Known As Wrapper Motivation

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

Module 10 Inheritance, Virtual Functions, and Polymorphism

Module 10 Inheritance, Virtual Functions, and Polymorphism Module 10 Inheritance, Virtual Functions, and Polymorphism Table of Contents CRITICAL SKILL 10.1: Inheritance Fundamentals... 2 CRITICAL SKILL 10.2: Base Class Access Control... 7 CRITICAL SKILL 10.3:

More information

REVIEW OF THE BASIC CHARACTERISTICS OF OBJECT ORIENTATION

REVIEW OF THE BASIC CHARACTERISTICS OF OBJECT ORIENTATION c08classandmethoddesign.indd Page 282 13/12/14 2:57 PM user 282 Chapter 8 Class and Method Design acceptance of UML as a standard object notation, standardized approaches based on work of many object methodologists

More information

OBJECT-ORIENTED SOFTWARE DEVELOPMENT Using OBJECT MODELING TECHNIQUE (OMT)

OBJECT-ORIENTED SOFTWARE DEVELOPMENT Using OBJECT MODELING TECHNIQUE (OMT) OBJECT-ORIENTED SOFTWARE DEVELOPMENT Using OBJECT MODELING TECHNIQUE () Ahmed Hayajneh, May 2003 1 1 Introduction One of the most popular object-oriented development techniques today is the Object Modeling

More information

COMP 213. Advanced Object-oriented Programming. Lecture 19. Input/Output

COMP 213. Advanced Object-oriented Programming. Lecture 19. Input/Output COMP 213 Advanced Object-oriented Programming Lecture 19 Input/Output Input and Output A program that read no input and produced no output would be a very uninteresting and useless thing. Forms of input/output

More information

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 9/e Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Data stored in variables and arrays is temporary It s lost when a local variable goes out of scope or when

More information

Lecture 11.1 I/O Streams

Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 1 OBJECT ORIENTED PROGRAMMING Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 2 Outline I/O Basics Streams Reading characters and string 21/04/2014 Ebtsam AbdelHakam

More information

Files and Streams

Files and Streams Files and Streams 4-18-2006 1 Opening Discussion Do you have any questions about the quiz? What did we talk about last class? Do you have any questions about the assignment? What are files and why are

More information

Special error return Constructors do not have a return value What if method uses the full range of the return type?

Special error return Constructors do not have a return value What if method uses the full range of the return type? 23 Error Handling Exit program (System.exit()) usually a bad idea Output an error message does not help to recover from the error Special error return Constructors do not have a return value What if method

More information

CS 251 Intermediate Programming Java I/O Streams

CS 251 Intermediate Programming Java I/O Streams CS 251 Intermediate Programming Java I/O Streams Brooke Chenoweth University of New Mexico Spring 2018 Basic Input/Output I/O Streams mostly in java.io package File I/O mostly in java.nio.file package

More information

Chapter 10. IO Streams

Chapter 10. IO Streams Chapter 10 IO Streams Java I/O The Basics Java I/O is based around the concept of a stream Ordered sequence of information (bytes) coming from a source, or going to a sink Simplest stream reads/writes

More information

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept F1 A Java program Ch 1 in PPIJ Introduction to the course The computer and its workings The algorithm concept The structure of a Java program Classes and methods Variables Program statements Comments Naming

More information

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance CS257 Computer Science I Kevin Sahr, PhD Lecture 10: Inheritance 1 Object Oriented Features For a programming language to be called object oriented it should support the following features: 1. objects:

More information

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide Module 10 I/O Fundamentals Objectives Upon completion of this module, you should be able to: Write a program that uses command-line arguments and system properties Examine the Properties class Construct

More information

Software 1 with Java. Recitation No. 9 (Java IO) December 10,

Software 1 with Java. Recitation No. 9 (Java IO) December 10, Software 1 with Java Recitation No. 9 (Java IO) December 10, 2006 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files

More information

BBM 102 Introduction to Programming II Spring Inheritance

BBM 102 Introduction to Programming II Spring Inheritance BBM 102 Introduction to Programming II Spring 2018 Inheritance 1 Today Inheritance Notion of subclasses and superclasses protected members UML Class Diagrams for inheritance 2 Inheritance A form of software

More information

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries 1 CONTENTS 1. Introduction to Java 2. Holding Data 3. Controllin g the f l o w 4. Object Oriented Programming Concepts 5. Inheritance & Packaging 6. Handling Error/Exceptions 7. Handling Strings 8. Threads

More information

The Java I/O System. Binary I/O streams (ASCII, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)

The Java I/O System. Binary I/O streams (ASCII, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits) The Java I/O System Binary I/O streams (ASCII, 8 bits) InputStream OutputStream The decorator design pattern Character I/O streams (Unicode, 16 bits) Reader Writer Comparing binary I/O to character I/O

More information

1/16/2013. Program Structure. Language Basics. Selection/Iteration Statements. Useful Java Classes. Text/File Input and Output.

1/16/2013. Program Structure. Language Basics. Selection/Iteration Statements. Useful Java Classes. Text/File Input and Output. Program Structure Language Basics Selection/Iteration Statements Useful Java Classes Text/File Input and Output Java Exceptions Program Structure 1 Packages Provide a mechanism for grouping related classes

More information

https://asd-pa.perfplusk12.com/admin/admin_curric_maps_display.aspx?m=5507&c=618&mo=18917&t=191&sy=2012&bl...

https://asd-pa.perfplusk12.com/admin/admin_curric_maps_display.aspx?m=5507&c=618&mo=18917&t=191&sy=2012&bl... Page 1 of 13 Units: - All - Teacher: ProgIIIJavaI, CORE Course: ProgIIIJavaI Year: 2012-13 Intro to Java How is data stored by a computer system? What does a compiler do? What are the advantages of using

More information

APICES - Rapid Application Development with Graph Pattern

APICES - Rapid Application Development with Graph Pattern APICES - Rapid Application Development with Graph Pattern Ansgar Bredenfeld GMD Institute for System Design Technology D-53754 Sankt Augustin, Germany bredenfeld@gmd.de Abstract In this paper, we present

More information

Java How to Program, 8/e

Java How to Program, 8/e Java How to Program, 8/e Polymorphism Enables you to program in the general rather than program in the specific. Polymorphism enables you to write programs that process objects that share the same superclass

More information

CSB541 Network Programming 網路程式設計. Ch.2 Streams 吳俊興國立高雄大學資訊工程學系

CSB541 Network Programming 網路程式設計. Ch.2 Streams 吳俊興國立高雄大學資訊工程學系 CSB541 Network Programming 網路程式設計 Ch.2 Streams 吳俊興國立高雄大學資訊工程學系 Outline 2.1 Output Streams 2.2 Input Streams 2.3 Filter Streams 2.4 Readers and Writers 2 Java I/O Built on streams I/O in Java is organized

More information

Inheritance (Chapter 7)

Inheritance (Chapter 7) Inheritance (Chapter 7) Prof. Dr. Wolfgang Pree Department of Computer Science University of Salzburg cs.uni-salzburg.at Inheritance the soup of the day?! Inheritance combines three aspects: inheritance

More information

Compilers and Code Optimization EDOARDO FUSELLA

Compilers and Code Optimization EDOARDO FUSELLA Compilers and Code Optimization EDOARDO FUSELLA The course covers Compiler architecture Pre-requisite Front-end Strong programming background in C, C++ Back-end LLVM Code optimization A case study: nu+

More information

Software 1 with Java. Recitation No. 7 (Java IO) May 29,

Software 1 with Java. Recitation No. 7 (Java IO) May 29, Software 1 with Java Recitation No. 7 (Java IO) May 29, 2007 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes

More information

Object Oriented Design with UML and Java. PART VIII: Java IO

Object Oriented Design with UML and Java. PART VIII: Java IO Object Oriented Design with UML and Java PART VIII: Java IO Copyright David Leberknight and Ron LeMaster. Version 2011 java.io.* & java.net.* Java provides numerous classes for input/output: java.io.inputstream

More information

Software 1. Java I/O

Software 1. Java I/O Software 1 Java I/O 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes for serializing objects 2 Streams A stream

More information

John Cowell. Essential Java Fast. How to write object oriented software for the Internet. with 64 figures. Jp Springer

John Cowell. Essential Java Fast. How to write object oriented software for the Internet. with 64 figures. Jp Springer John Cowell Essential Java Fast How to write object oriented software for the Internet with 64 figures Jp Springer Contents 1 WHY USE JAVA? 1 Introduction 1 What is Java? 2 Is this book for you? 2 What

More information

Inheritance, Polymorphism, and Interfaces

Inheritance, Polymorphism, and Interfaces Inheritance, Polymorphism, and Interfaces Chapter 8 Inheritance Basics (ch.8 idea) Inheritance allows programmer to define a general superclass with certain properties (methods, fields/member variables)

More information

Relationships. Association Aggregation/Composition Multiplicity Dependencies

Relationships. Association Aggregation/Composition Multiplicity Dependencies 1/13/2004 1 Association Aggregation/Composition Dependencies 1/13/2004 2 Relationships Very few classes stand alone in an OO system Three kinds of class/object relationships are defined to help model abstractions

More information

Product line annotations with UML-F

Product line annotations with UML-F Product line annotations with UML-F Wolfgang Pree 1), Marcus Fontoura 2), Bernhard Rumpe 3) 1) Department of Computer Sciences, University of California, Berkeley 2) IBM Almaden Research Center, San Jose,

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

JOURNAL OF OBJECT TECHNOLOGY

JOURNAL OF OBJECT TECHNOLOGY JOURNAL OF OBJECT TECHNOLOGY Online at http://www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2010 Vol. 9, No. 1, January-February 2010 A Modern, Compact Implementation of the Parameterized

More information

Frameworks Representations & Perspectives Position Paper Workshop on Language Support for Design Patterns and Frameworks, ECOOP 97

Frameworks Representations & Perspectives Position Paper Workshop on Language Support for Design Patterns and Frameworks, ECOOP 97 Frameworks Representations & Perspectives Position Paper Workshop on Language Support for Design Patterns and Frameworks, ECOOP 97 Palle Nowack Department of Computer Science, Aalborg University Fredrik

More information

CA Compiler Construction

CA Compiler Construction CA4003 - Compiler Construction David Sinclair Overview This module will cover the compilation process, reading and parsing a structured language, storing it in an appropriate data structure, analysing

More information

Patterns for polymorphic operations

Patterns for polymorphic operations Patterns for polymorphic operations Three small object structural patterns for dealing with polymorphism Alexander A. Horoshilov hor@epsylontech.com Abstract Polymorphism is one of the main elements of

More information

1.0 Libraries Technical Overview

1.0 Libraries Technical Overview 1.0 Libraries Technical Overview Jonni Kanerva Frank Yellin JavaSoft Outline Introduction Functionality in the 1.0 Libraries Distributed design of the Java platform Instructive oddities Design patterns

More information

Java Input / Output. CSE 413, Autumn 2002 Programming Languages.

Java Input / Output. CSE 413, Autumn 2002 Programming Languages. Java Input / Output CSE 413, Autumn 2002 Programming Languages http://www.cs.washington.edu/education/courses/413/02au/ 18-November-2002 cse413-18-javaio 2002 University of Washington 1 Reading Readings

More information

Exceptions and Working with Files

Exceptions and Working with Files Exceptions and Working with Files Creating your own Exceptions. You have a Party class that creates parties. It contains two fields, the name of the host and the number of guests. But you don t want to

More information

Lecture 22. Java Input/Output (I/O) Streams. Dr. Martin O Connor CA166

Lecture 22. Java Input/Output (I/O) Streams. Dr. Martin O Connor CA166 Lecture 22 Java Input/Output (I/O) Streams Dr. Martin O Connor CA166 www.computing.dcu.ie/~moconnor Topics I/O Streams Writing to a Stream Byte Streams Character Streams Line-Oriented I/O Buffered I/O

More information

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All Inheritance A form of software reuse in which a new class is created by absorbing an existing class s members and enriching them with

More information

Design Patterns IV. Alexei Khorev. 1 Structural Patterns. Structural Patterns. 2 Adapter Design Patterns IV. Alexei Khorev. Structural Patterns

Design Patterns IV. Alexei Khorev. 1 Structural Patterns. Structural Patterns. 2 Adapter Design Patterns IV. Alexei Khorev. Structural Patterns Structural Design Patterns, 1 1 COMP2110/2510 Software Design Software Design for SE September 17, 2008 2 3 Department of Computer Science The Australian National University 4 18.1 18.2 GoF Structural

More information

CSE P 501 Compilers. Implementing ASTs (in Java) Hal Perkins Winter /22/ Hal Perkins & UW CSE H-1

CSE P 501 Compilers. Implementing ASTs (in Java) Hal Perkins Winter /22/ Hal Perkins & UW CSE H-1 CSE P 501 Compilers Implementing ASTs (in Java) Hal Perkins Winter 2008 1/22/2008 2002-08 Hal Perkins & UW CSE H-1 Agenda Representing ASTs as Java objects Parser actions Operations on ASTs Modularity

More information

Java SE 8 Programmer I and II Syballus( Paper codes : 1z0-808 & 1z0-809)

Java SE 8 Programmer I and II Syballus( Paper codes : 1z0-808 & 1z0-809) Page1 Java SE 8 Programmer 1, also called OCJA 8.0 Exam Number: 1Z0-808 Associated Certifications: Oracle Certified Associate, Java SE 8 Programmer Java Basics Highlights of the Certifications Define the

More information

Design Patterns IV Structural Design Patterns, 1

Design Patterns IV Structural Design Patterns, 1 Structural Design Patterns, 1 COMP2110/2510 Software Design Software Design for SE September 17, 2008 Class Object Department of Computer Science The Australian National University 18.1 1 2 Class Object

More information

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive

More information

The Object Recursion Pattern

The Object Recursion Pattern SilverMark, Inc. woolf@acm.org OBJECT RECURSION Object Behavioral Intent Distribute processing of a request over a structure by delegating polymorphically. Object Recursion transparently enables a request

More information

Contents. iii Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1998, Revision B

Contents. iii Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1998, Revision B Contents About the Course...xv Course Overview... xvi Course Map... xvii Module-by-Module Overview... xviii Course Objectives... xxii Skills Gained by Module... xxiii Guidelines for Module Pacing... xxiv

More information

Objec&ves. Review. Standard Error Streams

Objec&ves. Review. Standard Error Streams Objec&ves Standard Error Streams Ø Byte Streams Ø Text Streams Oct 5, 2016 Sprenkle - CSCI209 1 Review What are benefits of excep&ons What principle of Java do files break if we re not careful? What class

More information

ощ 'ршорвшэш! цвн-эориэу ощ 'sajbpossv # PIPG DUJ 'ssjmoossv ^ PIPG pipa w н OX ЛЮН VAV

ощ 'ршорвшэш! цвн-эориэу ощ 'sajbpossv # PIPG DUJ 'ssjmoossv ^ PIPG pipa w н OX ЛЮН VAV ощ 'ршорвшэш! цвн-эориэу ощ 'sajbpossv # PIPG DUJ 'ssjmoossv ^ PIPG pipa w н OX ЛЮН VAV Contents Preface Chapter 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19

More information

Topic 7: Algebraic Data Types

Topic 7: Algebraic Data Types Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,

More information

WA1278 Introduction to Java Using Eclipse

WA1278 Introduction to Java Using Eclipse Lincoln Land Community College Capital City Training Center 130 West Mason Springfield, IL 62702 217-782-7436 www.llcc.edu/cctc WA1278 Introduction to Java Using Eclipse This course introduces the Java

More information

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN NOTES ON OBJECT-ORIENTED MODELING AND DESIGN Stephen W. Clyde Brigham Young University Provo, UT 86402 Abstract: A review of the Object Modeling Technique (OMT) is presented. OMT is an object-oriented

More information

Object Oriented Programming. Java-Lecture 11 Polymorphism

Object Oriented Programming. Java-Lecture 11 Polymorphism Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class

More information

CSE P 501 Compilers. Implementing ASTs (in Java) Hal Perkins Autumn /20/ Hal Perkins & UW CSE H-1

CSE P 501 Compilers. Implementing ASTs (in Java) Hal Perkins Autumn /20/ Hal Perkins & UW CSE H-1 CSE P 501 Compilers Implementing ASTs (in Java) Hal Perkins Autumn 2009 10/20/2009 2002-09 Hal Perkins & UW CSE H-1 Agenda Representing ASTs as Java objects Parser actions Operations on ASTs Modularity

More information

Product Line Annotations with UML-F

Product Line Annotations with UML-F Product Line Annotations with UML-F Wolfgang Pree 1, Marcus Fontoura 2, and Bernhard Rumpe 3 1 Department of Computer Sciences (guest), Univ. of California, Berkeley, pree@eecs.berkeley.edu 2 IBM Almaden

More information

Object Oriented Programming with Java. Unit-1

Object Oriented Programming with Java. Unit-1 CEB430 Object Oriented Programming with Java Unit-1 PART A 1. Define Object Oriented Programming. 2. Define Objects. 3. What are the features of Object oriented programming. 4. Define Encapsulation and

More information

Core Java Syllabus. Overview

Core Java Syllabus. Overview Core Java Syllabus Overview Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java

More information

UML Class Diagrams Revisited

UML Class Diagrams Revisited 9/25/2003 1 UML Class diagrams Organizing attributes and operations Class relationships Association Aggregation/Composition Multiplicity Dependencies 9/25/2003 2 UML Class Diagrams Revisited In the analysis

More information

Training topic: OCPJP (Oracle certified professional Java programmer) or SCJP (Sun certified Java programmer) Content and Objectives

Training topic: OCPJP (Oracle certified professional Java programmer) or SCJP (Sun certified Java programmer) Content and Objectives Training topic: OCPJP (Oracle certified professional Java programmer) or SCJP (Sun certified Java programmer) Content and Objectives 1 Table of content TABLE OF CONTENT... 2 1. ABOUT OCPJP SCJP... 4 2.

More information

Mobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE

Mobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE Mobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE COURSE TITLE JAVA2 FOR PROGRAMMERS COURSE DURATION 14 Hour(s) of Interactive Training COURSE OVERVIEW With the Java2 for Programmers course, anyone

More information

NEW YORK CITY COLLEGE OF TECHNOLOGY/CUNY Computer Systems Technology Department

NEW YORK CITY COLLEGE OF TECHNOLOGY/CUNY Computer Systems Technology Department NEW YORK CITY COLLEGE OF TECHNOLOGY/CUNY Computer Systems Technology Department COURSE: CST1201 Programming Fundamentals (2 class hours, 2 lab hours, 3 credits) Course Description: This course is an intensive

More information

Character Stream : It provides a convenient means for handling input and output of characters.

Character Stream : It provides a convenient means for handling input and output of characters. Be Perfect, Do Perfect, Live Perfect 1 1. What is the meaning of public static void main(string args[])? public keyword is an access modifier which represents visibility, it means it is visible to all.

More information

The following topics will be covered in this course (not necessarily in this order).

The following topics will be covered in this course (not necessarily in this order). The following topics will be covered in this course (not necessarily in this order). Introduction The course focuses on systematic design of larger object-oriented programs. We will introduce the appropriate

More information

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O Week 12 Streams and File I/O Overview of Streams and File I/O Text File I/O 1 I/O Overview I/O = Input/Output In this context it is input to and output from programs Input can be from keyboard or a file

More information

Chapter 17 Binary I/O. Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.

Chapter 17 Binary I/O. Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved. Chapter 17 Binary I/O 1 Motivations Data stored in a text file is represented in human-readable form. Data stored in a binary file is represented in binary form. You cannot read binary files. They are

More information

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming Goals of Lecture Lecture 27: OO Design Patterns Cover OO Design Patterns Background Examples Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2001 April 24, 2001 Kenneth

More information

A Simple Syntax-Directed Translator

A Simple Syntax-Directed Translator Chapter 2 A Simple Syntax-Directed Translator 1-1 Introduction The analysis phase of a compiler breaks up a source program into constituent pieces and produces an internal representation for it, called

More information

Unified Modeling Language (UML) Class Diagram

Unified Modeling Language (UML) Class Diagram 1 / 10 Unified Modeling Language (UML) Class Diagram Miaoqing Huang University of Arkansas Spring 2010 2 / 10 Outline 1 2 3 / 10 Class Diagram Class diagrams show the static structure of the classes that

More information

Pattern-Oriented Development with Rational Rose

Pattern-Oriented Development with Rational Rose Pattern-Oriented Development with Rational Rose Professor Peter Forbrig, Department of Computer Science, University of Rostock, Germany; Dr. Ralf Laemmel, Department of Information Management and Software

More information

Objec&ves STANDARD ERROR. Standard Error Streams. Ø Byte Streams Ø Text Streams 10/5/16. Oct 5, 2016 Sprenkle - CSCI209 1

Objec&ves STANDARD ERROR. Standard Error Streams. Ø Byte Streams Ø Text Streams 10/5/16. Oct 5, 2016 Sprenkle - CSCI209 1 Objec&ves Standard Error Streams Ø Byte Streams Ø Text Streams Oct 5, 2016 Sprenkle - CSCI209 1 STANDARD ERROR Oct 5, 2016 Sprenkle - CSCI209 2 1 Standard Streams Preconnected streams Ø Standard Out: stdout

More information

Sustainable software design with design patterns

Sustainable software design with design patterns 18 Sustainable software design with design patterns Adelino R. F. da Silva Departamento de Engenharia Electrotecnica Universidade Nova de Lisboa 2825 Monte de Caparica, Portugal T: +351.1.2948338; Fax:

More information

Model-View-Controller

Model-View-Controller CNM STEMulus Center Web Development with PHP November 11, 2015 1/8 Outline 1 2 2/8 Definition A design pattern is a reusable and accepted solution to a particular software engineering problem. Design patterns

More information

Core Java Contents. Duration: 25 Hours (1 Month)

Core Java Contents. Duration: 25 Hours (1 Month) Duration: 25 Hours (1 Month) Core Java Contents Java Introduction Java Versions Java Features Downloading and Installing Java Setup Java Environment Developing a Java Application at command prompt Java

More information

Wrapping a complex C++ library for Eiffel. FINAL REPORT July 1 st, 2005

Wrapping a complex C++ library for Eiffel. FINAL REPORT July 1 st, 2005 Wrapping a complex C++ library for Eiffel FINAL REPORT July 1 st, 2005 Semester project Student: Supervising Assistant: Supervising Professor: Simon Reinhard simonrei@student.ethz.ch Bernd Schoeller Bertrand

More information

CS558 Programming Languages Winter 2013 Lecture 8

CS558 Programming Languages Winter 2013 Lecture 8 OBJECT-ORIENTED PROGRAMMING CS558 Programming Languages Winter 2013 Lecture 8 Object-oriented programs are structured in terms of objects: collections of variables ( fields ) and functions ( methods ).

More information

CSCE3193: Programming Paradigms

CSCE3193: Programming Paradigms CSCE3193: Programming Paradigms Nilanjan Banerjee University of Arkansas Fayetteville, AR nilanb@uark.edu http://www.csce.uark.edu/~nilanb/3193/s10/ Programming Paradigms 1 Java Packages Application programmer

More information

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance? CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses

More information

Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.

Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. Preface p. xix Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. 5 Java Applets and Applications p. 5

More information

Late-bound Pragmatical Class Methods

Late-bound Pragmatical Class Methods Late-bound Pragmatical Class Methods AXEL SCHMOLITZKY, MARK EVERED, J. LESLIE KEEDY, GISELA MENGER Department of Computer Structures University of Ulm 89069 Ulm, Germany {axel, markev, keedy, gisela@informatik.uni-ulm.de

More information

James Newkirk

James Newkirk Private Interface Class Structural James Newkirk newkirk@oma.com Intent Provide a mechanism that allows specific classes to use a non-public subset of a class interface without inadvertently increasing

More information

16.1 Introduction... 2

16.1 Introduction... 2 Department of Computer Science Tackling Design Patterns Chapter 16: UML Activity Diagrams Copyright c 2016 by Linda Marshall and Vreda Pieterse. All rights reserved. Contents 16.1 Introduction.................................

More information

Object. OutputStream write(int) write(byte[]) write(byte[], int, int) FilterOutputStream write(int) write(byte[]) write(byte[], int, int)

Object. OutputStream write(int) write(byte[]) write(byte[], int, int) FilterOutputStream write(int) write(byte[]) write(byte[], int, int) Inheritance Object OutputStream write(int) write(byte[]) write(byte[], int, int) FilterOutputStream write(int) write(byte[]) write(byte[], int, int) PrintStream write(int) write(byte[]) Early binding Consider

More information

Problem with Scanning an Infix Expression

Problem with Scanning an Infix Expression Operator Notation Consider the infix expression (X Y) + (W U), with parentheses added to make the evaluation order perfectly obvious. This is an arithmetic expression written in standard form, called infix

More information

Java Programming Course Overview. Duration: 35 hours. Price: $900

Java Programming Course Overview. Duration: 35 hours. Price: $900 978.256.9077 admissions@brightstarinstitute.com Java Programming Duration: 35 hours Price: $900 Prerequisites: Basic programming skills in a structured language. Knowledge and experience with Object- Oriented

More information

Design Patterns in C++

Design Patterns in C++ Design Patterns in C++ Structural Patterns Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa March 23, 2011 G. Lipari (Scuola Superiore Sant Anna) Structural patterns March

More information

This page intentionally left blank

This page intentionally left blank This page intentionally left blank arting Out with Java: From Control Structures through Objects International Edition - PDF - PDF - PDF Cover Contents Preface Chapter 1 Introduction to Computers and Java

More information

Inheritance Chapter 8. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Inheritance Chapter 8. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Inheritance Chapter 8 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Scope Class Inheritance: Deriving classes Method overriding Class hierarchies Abstract classes Visibility and inheritance

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 4&5: Inheritance Lecture Contents What is Inheritance? Super-class & sub class The object class Using extends keyword @override keyword

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

Architectural Patterns

Architectural Patterns Architectural Patterns Dr. James A. Bednar jbednar@inf.ed.ac.uk http://homepages.inf.ed.ac.uk/jbednar Dr. David Robertson dr@inf.ed.ac.uk http://www.inf.ed.ac.uk/ssp/members/dave.htm SEOC2 Spring 2005:

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses

More information

Formal Languages and Compilers Lecture I: Introduction to Compilers

Formal Languages and Compilers Lecture I: Introduction to Compilers Formal Languages and Compilers Lecture I: Introduction to Compilers Free University of Bozen-Bolzano Faculty of Computer Science POS Building, Room: 2.03 artale@inf.unibz.it http://www.inf.unibz.it/ artale/

More information

INFORMS 4th Conference on Information Systems and Technology. Generalizations as Data and Behavior Abstractions

INFORMS 4th Conference on Information Systems and Technology. Generalizations as Data and Behavior Abstractions INFORMS 4th Conference on Information Systems and Technology Generalizations as Data and Behavior Abstractions,..- Dale L. Lunsford The University of Southern Mississippi, College of Business Administration,

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg

More information

CS211 Lecture: Design Quality; Cohesion and Coupling; Packages

CS211 Lecture: Design Quality; Cohesion and Coupling; Packages CS211 Lecture: Design Quality; Cohesion and Coupling; Packages Objectives: Last revised October 4, 2004 1. To introduce the notion of design quality, tradeoffs, and some principles of quality design 2.

More information