COP 3331 Object Oriented Analysis and Design Chapter 8 - PowerPoint PPT Presentation

About This Presentation
Title:

COP 3331 Object Oriented Analysis and Design Chapter 8

Description:

The main goal of an application framework is to support the reuse of designs. ... Bags: A collection of unordered elements. May be duplicates. Least restrictive. ... – PowerPoint PPT presentation

Number of Views:65
Avg rating:3.0/5.0
Slides: 21
Provided by: DavidAG
Learn more at: http://www.cs.fsu.edu
Category:

less

Transcript and Presenter's Notes

Title: COP 3331 Object Oriented Analysis and Design Chapter 8


1
COP 3331 Object Oriented Analysis and
DesignChapter 8 Object-Oriented Application
Framework
  • Jean Muhammad

2
Overview
  • Application Frameworks
  • Collections Frameworks
  • AWT and SWING
  • Input/Output Framework

3
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.

4
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.

5
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

6
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-gt. They are also
    known as functions, dictionaries, or associated
    arrays. Keys must be unique
  • k1-gtv1, k 2-gtv2, k3-gtv3, k4-gtv4, .. kn-gtvn
  • Sort Maps Elements are sorted by keys.

7
Applications Frameworks
  • Interface Collections
  • Common aspects of a class should be handled in a
    uniform manner.

Collection
Map
Set
List
Sortedmap
SortedSet
8
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

9
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.

10
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)

11
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()

12
Concrete Collections - Discussion
  • HashSet IdentifyHashMap
  • LinkedHashSet LinkedHashMap
  • TreeSet TreeMap
  • ArrayList HashTable
  • LinkedList
  • Vector
  • HashMap

13
Methods of Interface Iterator
  • hasNext()
  • next()
  • remove()

14
Methods of Interface ListIterator
  • add(o)
  • hasNext()
  • hasPrevious()
  • next()
  • nextIndex()
  • previous()
  • previousIndex()
  • remove()
  • set(o)

15
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).

16
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
17
Swing Components
Component
Container

JComponent
JButton
JPanel
Window
JLabel
JCombBox
JApplet
Frame
Dialog
JCheckBox
JList
JDialog
JFrame
JScrollBar
JWindow
JTextComponent
JTextField
JTextArea
18
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.

19
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

20
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.
Write a Comment
User Comments (0)
About PowerShow.com