COP 3331 Object Oriented Analysis and Design Chapter 8 - Object-Oriented Application Framework
COP 3331 Object Oriented Analysis and Design Chapter 8 - Object-Oriented Application Framework
Design
Chapter 8 – Object-Oriented Application
Framework
Jean Muhammad
Overview
Application Frameworks
Collections Frameworks
AWT and SWING
Input/Output Framework
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
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
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
JCombBox
JApplet Frame Dialog
JCheckBox
JList
JFrame JDialog
JScrollBar
JWindow
JTextComponent
JTextField JTextArea
Input/Output Framework
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.