Using Function Generalization to Design a Cosequential Processing Framework PowerPoint PPT Presentation

presentation player overlay
1 / 21
About This Presentation
Transcript and Presenter's Notes

Title: Using Function Generalization to Design a Cosequential Processing Framework


1
Using Function Generalization to Design a
Cosequential Processing Framework
  • H. Conrad Cunningham and Pallavi Tadepalli
  • Software Architecture Research Group
  • Department of Computer and Information ScienceĀ 
  • University of Mississippi

2
Outline
  • Software Framework
  • Motivation
  • Cosequential Processing
  • Function Generalization
  • Future Work

3
Software Framework
  • Generic application allowing creation of members
    of family of related programs
  • Reusable design expressed as set of abstract
    classes and the way they collaborate
  • Common and variable aspects known as frozen spots
    and hot spots

Framework library
Frozen spots
Framework
Hot spots
User-supplied code(application specific)
4
Motivation
  • Nontrivial to identify the needed hot spot
    abstractions
  • Difficult to specify hot spot behaviors
  • Need systematic generalization methodology
  • Explore function generalization
  • incrementally generalize functional structure of
    specification to produce general application
  • executable specification expressed as set of
    functions in Haskell

5
Haskell
  • Purely functional language
  • forces explicit consideration of computational
    effects (no implicit state)
  • Polymorphic, higher-order, first-class functions
    and user-defined algebraic data types
  • enables generic programming
  • Concise, equational notation
  • allows convenient mathematical manipulation

6
Cosequential Processing
Process A1 and B1
Input sequences
Output sequence
Write result C1 to output
Process Ai and Bj
Write C2 to output
  • Coordinates processing of two input sequences
    ordered by same total ordering
  • Create third sequence in incremental steps by
    merging and matching input elements
  • Includes set operations and sequential file
    update applications

7
Function Generalization
  • Create executable specification for a concrete
    application as Haskell program
  • Define scope of family
  • Identify frozen spots and hot spots
  • Analyze and design each hot spot subsystem
  • generalize Haskell program for hot spot
  • transform simple function to generalized function
    (e.g., with higher-order parameters)
  • Transform generalized Haskell program to Java
    framework

8
Executable Specification(Merging two ascending
integer sequences)
  • merge0 Int-gtInt-gtInt
  • merge0 ys ys
  • merge0 xs xs
  • merge0 xs_at_(xxs) ys_at_(yys)
  • x lt y x merge0 xs ys
  • x y x merge0 xs ys
  • x gt y y merge0 xs ys

9
Frozen Spots
  • Input sequences have same total ordering
  • Input sequences are immutable
  • Output sequence has same ordering as input
    sequences
  • Incremental processing
  • current element from each sequence examined
  • at least one input sequence advanced by one
    element
  • Appropriate action taken after examining current
    elements from each sequence
  • Represented by merge function in Haskell

10
Hot Spots
  • Variability in total ordering
  • Variability in record format
  • Variability of input and output sequences
  • Variability of transformations
  • Variability of source/destination
  • Represented as additional functions, types, and
    class definitions to merge function

11
Hot Spot 1(Variability in total ordering)
  • Generalizes element type of sequences and
    associated comparison operators
  • Restricts polymorphic type of elements to class
    Ord (having usual relational operations)
  • Results in generalized comparisons
  • merge1 Ord a gt a -gt a -gt a
  • merge1 ys ys
  • merge1 xs xs
  • merge1 xs_at_(xxs) ys_at_(yys)
  • x lt y xmerge1 xs ys
  • x y xmerge1 xs ys
  • x gt y ymerge1 xs ys

12
Hot Spot 2(Variability in record format)
  • Allows elements of sequences to be records with
    keys
  • Adds key extraction function as higher order
    parameter
  • Results in generalized record format
  • merge2 Ord b gt(a -gt b) -gt a -gt a
  • -gt a
  • merge2 key ys ys
  • merge2 key xs xs
  • merge2 key xs_at_(xxs) ys_at_(yys)
  • key x lt key y xmerge2 key xs ys
  • key x key y xmerge2 key xs ys
  • key x gt key y ymerge2 key xs ys

13
Hot Spot 3(Variability of input and output
sequences)
  • Allows different element format in each sequence
  • Requires separate key extraction functions for
    each
  • Introduces transformation functions
  • Results in independent sequence formats
  • merge3 kx ky tx ty xs ys mg xs ys
  • where
  • mg ys map ty ys
  • mg xs map tx xs
  • mg xs_at_(xxs) ys_at_(yys)
  • kx x lt ky y tx x mg xs ys
  • kx x ky y tx x mg xs ys
  • kx x gt ky y ty y mg xs ys

14
Hot Spot 4(Variability of transformations)
  • Enables use of more general transformations on
    input
  • Introduces explicit state to record ongoing
    computation
  • Adds accumulating parameter to maintain local
    state throughout processing
  • Transforms state to output at end of input
    sequence processing

15
Variable Sequence Transformations
  • merge4b kx ky tl te tg nex ney ttx tty
  • res s xs ys mg s xs ys
  • where
  • mg s ys res (foldl tty s ys)
  • mg s xs res (foldl ttx s xs)
  • mg s xs_at_(xxs) ys_at_(yys)
  • kx x lt ky y mg (tl s x y) xs ys
  • kx x ky y mg (te s x y)
  • (nex s xs) (ney s ys)
  • kx x gt ky y mg (tg s x y) xs ys

16
Hot Spot 5(Variability of source/destination)
  • Allows diverse sources for inputs and destination
    for output
  • No changes to merge4b except its use
  • sequences already represented as pervasive
    polymorphic list data type
  • supply different input sequence arguments
  • use result by different function

17
Transformation to Java Framework
  • Drive using shape of Haskell program
  • Use design patterns (Template, Strategy, etc.)
  • Construct cosequential framework
  • recursive legs become main while loop
  • nonrecursive legs become post-loop code
  • interfaces and classes represent various hot spot
    generalizations
  • java.lang.Comparable for Ord
  • Keyed for key extraction functions

18
Future Work
  • Develop better guidelines for generalizing
    Haskell programs
  • Investigate usage of Haskell features like
    modules, classes, and monads
  • Develop better guidelines for creating Java
    frameworks from Haskell programs

19
Conclusion
  • Framework construction follows function
    generalization
  • Each transformation produced an executable
    specification
  • Appropriate hooks (hot spot abstractions) defined
  • Cosequential processing framework useful for real
    world applications
  • Framework tested by building master-transaction
    file update application

20
Acknowledgments
  • Supported in part by a grant from Acxiom
    Corporation titled The Acxiom Laboratory for
    Software Architecture and Component Engineering
    (ALSACE).
  • Contributions by former students Yi Liu (South
    Dakota State) and Cuihua Zhang (Northwest Vista
    College)

21
Discussion
  • Any questions or comments?
Write a Comment
User Comments (0)
About PowerShow.com