0% found this document useful (0 votes)
45 views20 pages

COP 3331 Object Oriented Analysis and Design Chapter 8 - Object-Oriented Application Framework

This document discusses object-oriented application frameworks. It defines a framework as a set of collaborating classes that represent reusable designs for a particular domain. Frameworks have characteristics like extensibility and inversion of control. Common frameworks include collections frameworks, the AWT/Swing GUI frameworks, and input/output frameworks. The document outlines the interfaces and functionality provided by collections like lists, sets, and maps. It also describes common GUI components in AWT and Swing as well as stream-based and random access I/O.

Uploaded by

Alfonso Rivero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views20 pages

COP 3331 Object Oriented Analysis and Design Chapter 8 - Object-Oriented Application Framework

This document discusses object-oriented application frameworks. It defines a framework as a set of collaborating classes that represent reusable designs for a particular domain. Frameworks have characteristics like extensibility and inversion of control. Common frameworks include collections frameworks, the AWT/Swing GUI frameworks, and input/output frameworks. The document outlines the interfaces and functionality provided by collections like lists, sets, and maps. It also describes common GUI components in AWT and Swing as well as stream-based and random access I/O.

Uploaded by

Alfonso Rivero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

COP 3331 Object Oriented Analysis and

Design
Chapter 8 – Object-Oriented Application
Framework

Jean Muhammad
Overview

 Application Frameworks
 Collections Frameworks
 AWT and SWING
 Input/Output Framework
Applications Frameworks

A framework is defined as a set of collaborating


classes that represent usable designs of
software systems that have some application
for a particular domain. The main goal of an
application framework is to support the reuse
of designs.
Applications Frameworks

 Characteristics
– Extensibility: A framework consists of a set of abstract
classes and interfaces to be extended and specialized.
– Inversion Control: Frameworks represent a higher level of
abstraction then we normally think of. Instead of the
application controlling the flow of execution, it will be the
framework.
– Design Patterns as Building Blocks: Design patterns are a
schematic description of reusable components while
frameworks are executable programs.
Applications Frameworks

 Design Requirements
– Completeness: A framework must provide a family of
classes.
– Adaptability: All platform-specific aspects of the framework
must be clearly identified and isolated.
– Efficiency: Components must be easily identified and
documented.
– Safety: Each abstraction must bye type-safe to avoid
behavior problems.
– Simplicity: Must have clear and consistent organization.
– Extensibility: Must be able to add new classes
Applications Frameworks
 The Collections Frameworks: An object that contains other
objects.
– Bags: A collection of unordered elements. May be duplicates.
Least restrictive.
– Sets: An unordered collection of elements. No duplicates are
allowed: {e1, e2, e3, e4,.. en}
– Lists: An ordered collection of elements. Duplicates are allowed.
– Maps: A collection of unordered collection of key-value pairs
denoted by key->. They are also known as functions, dictionaries,
or associated arrays. Keys must be unique
{k1->v1, k 2->v2, k3->v3, k4->v4, .. kn->vn}
– Sort Maps: Elements are sorted by keys.
Applications Frameworks

 Interface Collections
– Common aspects of a class should be handled in
a uniform manner.
Collection Map

Set List Sortedmap

SortedSet
Methods of Interface Collection
 add(o)
 addAll(c)
 clear()
 contains(o)
 containsAll(c)
 isEmpty)
 iterator()
 remove(o)
 removeAll(c)
 retainall(c)
 size()
o – is an object , c – is a type collection
Methods of Interace set

 This extends the Collection interface


– add(o) adds the elements, checks to make sure
there are no duplicates.
– addAll(c) Adds elements if they are not already
present.
Methods of Interface List

 List interface also extends Collection


interface
– add(i,o) - remove(i)
– add(o) - remove(o)
– addAll(c) - set (i,o)
– addAll(i,c) - subList(i,j)
– get(i)
– indexOf(o)
– lastIndexOf(o)
Methods of Interface Map
 Does not extend Collection or Set interface
– clear()
– containsKey(k)
– containsValue(v)
– entrySet()
– get(k)
– isEmpty()
– keySet()
– put(k,v)
– putAll(m)
– remove(k)
– size()
– values()
Concrete Collections - Discussion

 HashSet IdentifyHashMap
 LinkedHashSet LinkedHashMap
 TreeSet TreeMap
 ArrayList HashTable
 LinkedList
 Vector
 HashMap
Methods of Interface Iterator

 hasNext()
 next()
 remove()
Methods of Interface ListIterator

 add(o)
 hasNext()
 hasPrevious()
 next()
 nextIndex()
 previous()
 previousIndex()
 remove()
 set(o)
AWT and SWING
 GUI components: Known as widgets. Examples include button,
label, checkbox, scrollbar, frame, dialog
 Layout Managers: Define strategies for laying out GUI
components. Commonly used layout managers include
FlowLayout and BorderLayout
 Events and event listeners: Represent user input or actions.
KeyEvent, MouseEvent are examples.
 Graphics and Imaging classes: Allows components to be
drawn. Graphics(Color, Font, Graphics, etc). Geomentry
(Point, Rectangle, Dimension, etc), Imaging( Image, Icon, etc).
GUI Component Classes in AWT

Component
*
Button Container

Canvas
Panel Window
CheckBox

Choice
Frame Dialog

Label
FileDialog
List

Scrollbar
Java.applet.Applet
TextComponent

TextArea TextField
Swing Components

Component Container

*
JComponent

JButton

JLabel JPanel Window

JCombBox
JApplet Frame Dialog
JCheckBox

JList
JFrame JDialog
JScrollBar

JWindow
JTextComponent

JTextField JTextArea
Input/Output Framework

 Stream I/O: Sequence of bytes. A stream


may be opened for reading and writing but
not both.
 Random Access I/O: Random access I/O
supports reading and writing data at any
position in the file. A random access file may
be opened for both reading and writing.
Byte Streams

Input Method Output Method Description

read() write(b) Reads/Writes single byte


read(ba) write(ba) Reads/Writes byte array
read(ba,off,leng) write(ba,off,leng) Reads/Writes segment of
byte array
skip(n) Skips over n bytes
close () close() Closes the stream
Random Access Files

 Constructor

RandomAccessFile(filename,mode) Creates a
random-access file that reads from, and optionally writes to, the
file name filename. The mode argument is a strng whose value
must be either “r”, for ready only, or “rw”, for read-write.
seek(L) Move the read/write position to the L-th byte.
skipBytes(i) Moves the read/write position I bytes relative to
the current position. Moves forward or backward.

You might also like