slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
File Processing PowerPoint Presentation
Download Presentation
File Processing

Loading in 2 Seconds...

play fullscreen
1 / 16

File Processing - PowerPoint PPT Presentation


  • 67 Views
  • Uploaded on

File Processing. You've achieved success in your field when you don't know whether what you're doing is work or play. Warren Beatty (1937 - ). Classes. Classes entities within a system imported e.g. Turtle of same project write more than one class Instances objects created via new

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'File Processing' - gin


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

File Processing

You've achieved success in your field when you don't know whether what you're doing is work or play.

Warren Beatty (1937 - )

classes
Classes
  • Classes
    • entities within a system
    • imported
      • e.g. Turtle
    • of same project
      • write more than one class
  • Instances
    • objects created via new
  • Instance variables
    • object’s memory
    • state
  • Methods
    • things object can do
    • behaviour
  • System execution via interacting objects
methods
Methods
  • Method calls
    • local
      • methodname ( paramlist )
    • of another object
      • object . methodname ( paramlist )
    • this . methodname ( paramlist )
  • Behaviour depends on state
    • e.g. effect of forward depends on pen state and direction
    • methods refer to instance variables
      • can base actions on values of instance variables
        • loops, decisions
  • Role of constructor
    • well-defined initial state
case study payroll system
Case Study: Payroll System
  • Problem
    • Payroll report based on multiple binary data files
  • Analysis & design
    • entities
      • items (Employees)
        • details about item
      • Payroll report generator
        • process for generating report
      • Merge algorithm
        • Combine 2 binary data files into one.
employee class
Employee Class
  • Class
    • not a main class
      • no method main
  • Execution
    • only when methods (constructor) called
  • Attributes/instance variables
  • Algorithms/methods
    • constructors
      • default
    • methods
      • accessor/updater
      • operations
persistent objects
Persistent Objects
  • Lifetime extends beyond a single program execution
  • Binary I/O
    • Record (object) at-a-time
    • Serializable
    • serialVersionUID
  • BinaryOutputFile
    • writeObject()
      • subtype
      • upcasting to Object
        • always valid
  • BinaryDataFile
    • readObject()
      • must downcast to expected type
        • not a conversion
        • ClassCastException
creating a binary file
Creating a Binary File
  • MakeEmpFile class
    • only used once to bootstrap system
  • Employee records
  • data from a text file (ASCIIDataFile)
  • reads text record using Employee constructor
  • writes Employee object using writeObject
listing contents of a binary file
Listing Contents of a Binary File
  • Working with internal representation
    • cannot view using text editor
    • must use same Employee class
      • or won’t be able to read
      • don’t make copy, use same file
      • programs in same package or import necessary classe(s) (e.g. Employee)
      • can be more than one main class in a package
  • Listing Employee File
    • program to read binary file and display as text
    • in same package (Payroll_System)
  • Creating the Employee File
    • Payroll3 assumes Employee objects are already in existence
    • must be a program to create Employee objects initially
    • in same package (Payroll_System)
payroll3 class
Payroll3 Class
  • Binary input
    • note: no use of Employee constructor – objects already exist
  • Processing algorithm
    • process to EOF
    • update record
class design
Class Design
  • Cohesion
  • Selective disclosure
    • only what client needs to know
    • hide representation and implementation
  • Accessor and updater methods
    • instance variables
      • private
    • if accessible, provide accessor method
      • Java convention: getxxx
    • if updateable, provide updater method
      • Java convention setxxx
    • pseudo attributes
  • Methods/Constructors
    • private vs public
file processing
File Processing
  • large collections of data
  • sequential processing
    • batch
    • sequential devices
    • typically sorted by key
  • random processing
    • real-time/on-line
    • direct access device
    • access by key
  • key
    • primary key
file merge
File Merge
  • combine two like files
    • maintain key order
  • basic algorithm
    • by hand
      • combine sorted piles
      • rationale
    • by computer
      • files & records
      • algorithm
  • improvements
    • sentinel
    • pattern
    • filter method
e g employee file merge
E.g. Employee File Merge
  • HIGH_KEY
    • key for sentinel record
    • greater than all naturally occurring keys
  • termination condition
  • getRec
    • input filter
    • creates sentinel object at EOF
  • Equal keys?
    • unique records?
    • error situation vs duplicate keys vs combine records
file update
File Update
  • master file
  • transaction file
    • transactions
  • updating
    • random processing
      • immediate
    • sequential processing
      • batch transactions
      • batch processing
      • new master file
sequential file update
Sequential File Update
  • sequential processing
  • batched transactions
  • backups
  • report generation
  • key comparison
    • master < trans
      • transaction applies to later master
    • master = trans
      • transaction applies to this master
    • master > trans
      • must apply to earlier master
      • no master for transaction
        • error
        • add new record
  • pattern