Title: Using Function Generalization to Design a Cosequential Processing Framework
1Using 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
2Outline
- Software Framework
- Motivation
- Cosequential Processing
- Function Generalization
- Future Work
3Software 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)
4Motivation
- 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
5Haskell
- 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
6Cosequential 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
7Function 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
8Executable 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
9Frozen 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
10Hot 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
11Hot 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
12Hot 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
13Hot 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
14Hot 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
15Variable 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
16Hot 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
17Transformation 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
18Future 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
19Conclusion
- 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
20Acknowledgments
- 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)
21Discussion
- Any questions or comments?