Object Oriented Framework for Filtering Jonathan Wiersma Jarett Hailes MITACS-PINTS
Presentation Overview Overview of Programming Concepts Procedural Programming Object Oriented Design Current State of PINTS Projects Proposed Improvements Filtering project framework Common Interfaces Shared set of utility classes Refactoring Implementation and Challenges Conclusion & Future Directions
Procedural Programming - Overview integer char Variables float pointer Data Structures combinations of previous Functions multiple inputs (parameters) single output (return value) Different than functions in math: May map same input to different outputs behavior can depend on state of global variables variables are mutable
Procedural Programming – Example 1 Global variable (accessible to all functions) int global_var; void main() { int a,b,c; a = 3; b = 4; c = sum(a,b); output(c); } int sum(int x, int y) { return x + y; function variables Variable assignment Function call
Object Oriented Design - Basics Objects Classes Variables/State Methods
Object Oriented Design - Classes Combines a data structure (set of variables) with operations related to that data structure (methods) Describes a class of objects (like a set) An object is an instance of a class and has a state
Object Oriented Programming: Code Structure Procedural Program: Object Oriented Program: Data Structures Global variables Class 1 Data Structure methods Procedures/functions Class 2 Data Structure methods
Object Oriented Design - Concepts Encapsulation Inheritance Polymorphism
State of Code at PINTS Each project is a completely separate entity Interfaces are different between projects Interfaces are not clearly defined (templates) No code reuse – improvements only effect one project Large undertaking to create a new project Not easy to read and understand
Improvements being Developed Create a filtering project framework Shared underlying structure Suite of useful utility classes Abstract output model (M-V-C pattern)
Framework for Filtering Projects Create a set of generic classes and interfaces (via inheritance) Have filters use these generic interfaces so they don’t require customized code Design a framework to ease the development effort of applying a filter to a new application
Shared Filtering Interface SERP Filter DType Signal Observation Observer POD Signal POD 13 Observation POD 13 SERP Observer
CVS – Concurrent Versioning System Allows several users to work on the same files at the same time Stores old versions and changes Also useful for text and latex documents
CVS Layout
Interfaces Filter SERP Filter DType Signal Observation Observer POD Signal POD 13 Observation POD 13 SERP Observer
Interfaces Signal BoundedSignal DType position void evolve() AbsDomain domain AbsDomain domain()
Interfaces Observation ODType position void observe(Signal, double dt)
Interfaces Observer SERP Observer Observation void observe(Observation, double dt) SERP Observer double weightedOffset(Signal, double dt)
CVS Math Package - Algebra Ideally: Matrix Row Matrix Column Matrix Row Vector Column Vector
CVS Math Package - Algebra Row Vector Scalar values[] int dimension math operators (+,-,*,+=,-=,*=,etc) accessors RowVector norm() void normalize()
CVS Math Package - Algebra Column Vector Scalar values[] int dimension math operators (+,-,*,+=,-=,*=,etc) accessors ColumnVector norm() void normalize()
CVS Math Package - Algebra Row Matrix RowVector values[] int nrows, ncols math operators (+,-,*,+=,-=,*=,etc) accessors RowMatrix inverse() void invert()
CVS Math Package - Coordinates Euclidean Coordinate Polar Coordinate
CVS Math Package - Coordinates CType value math operators (+,-,*,+=,-=,*=,etc) accessors
CVS Math Package - Coordinates Polar Coordinate CType max, min math operators (+,-,*,+=,-=,*=,etc) accessors
CVS Math Package - Domain Abstract Domain Abstract Bounded Domain Vector Box Domain
CVS Math Package - Domain Abstract Domain bool contains(DType) Abstract Bounded Domain DType min, max DType min() DType max()
CVS Math Package - Domain Range Type Abstract Function Domain Type Continuous Function Discrete Function
CVS Math Package - Domain Abstract Function int dimension Range operator()(Domain val) int dimension() Range Type Domain Type
CVS Math Package - Domain Abstract Function Range Type int dimension Domain Type Range operator()(Domain val) int dimension() Continuous Function Range operator()(Domain val) DiscreteFunction discretize() DiscreteFunction fft(VBoxDom<DType>, int)
CVS Math Package - Domain Abstract Function Range Type int dimension Domain Type Range operator()(Domain val) int dimension() Discrete Function VectorBoxDomain<DType> domain MultiDArray<RType> data int numDivisions DType delta[] RType index(int idx[]) DiscreteFunction fft(int type) accessors
Graphics - Legacy Packages of raster graphics procedures Outdated Custom code Not supported Very low level
Graphics - povray 3D Ray Tracing program Beautiful output Slow Rendering Separate Application Requires specific input format
Graphics - VTK Object Oriented 3D Visualization Toolkit Uses standard visualization network Fairly fast Easy to incorporate into real-time display Support for several languages
Graphics – Output Classes Text Output PovRay Output VTK Output POD 13 PovRay Output POD 13 VTK Output
Utilities - Simulations Abstract Simulation Classes Rapid Simulation Development Code reuse Standard Code Layout Signal Simulation Observation Simulation Filter Simulation
Utilities - Simulations Controller Simulation View Model Simulation View Simulation Model POD 13 Filter View 1 Filter Simulation Model Filter Output SERP Filter Signal Observation Text Output VTK Output POD Signal POD 13 Observation
Utilities - Structures Data Structures Hash Table / Hash Bin List Multi Dimensional Array Dictionary We’ve made some container data structures for use in all other directories. Are there to facilitate portability of data across classes (much like Vector and matrix classes in math) Most containers are templatable.
Refactoring Splitting large classes into smaller ones Better encapsulation Fewer variables to remember Fewer methods to remember More abstraction Splitting large methods into smaller ones Less code to read through to understand method Easier to reuse code Moving methods (feature envy) Easier to understand Easier to locate
Implementation Signal – evolve() Observation - observe(Signal) Observer – depends on filter(s) used Output – output()
Challenges Multiple Inheritance Return by value Graphics MVC Model Observer Interfaces Return by value multiple copies inheritance Graphics MVC Model templates
Future Directions Single Filtering Application for all Projects Scripting Language Language Change (java?) Talk on using CVS for latex papers Suggestions