application refactoring with design patterns
DESCRIPTION
This presentation will describe the object-oriented substructure developed to manage, validate, and process survey data. Experience with classes or objects or design patterns is not necessary for this presentation, but it will help to know how to code a class and instantiate an object with SCL (SAS Component Language).TRANSCRIPT
Application Refactoringith D i P ttwith Design Patterns
Mark Tabladillo, Ph.D.March 31, 2003
Introduction
The YTSS (Youth Tobacco Surveillance System) started in 1998y )YTS = Youth Tobacco SurveyGYTS = Global Youth Tobacco SurveyGYTS = Global Youth Tobacco SurveySince 1998, over 1,000,000 surveys h b d f 35 t t dhave been processed for 35 states and 100 international sites
Design Patterns Inherency
“Design Pattern” = Routine solution to a reoccurring problemg p
Observer Pattern = Model/ViewMediator Pattern = SAS/AF FrameMediator Pattern SAS/AF FrameSingleton Pattern = Frames and SCL standalone code
Point: Patterns are inherently inside SAS and operating systemsSAS and operating systems
How to Start with Design Patterns
Shalloway and Trott (2002), Design Patterns Explainedp
Patterns do not stand alone, but interactPattern relationships improve withPattern relationships improve with refactoring (defined as the intentional restructuring of classes)
When to Create Design Patterns
A previous project has reusable codeCurrent code is largeCurrent code is largeGood for long-term or complex applications (especially to allow forapplications (especially to allow for modifications)
Specific DevelopmentSpecific Development Strategy
Customized nonvisual classesFirst version 6 12 was usedFirst version 6.12 was usedDatasets generate code (see other paper)paper)Conversion to version 8 and
lid ticonsolidation
Output Class
Changing printer orientation (landscape vs. portrait)p )Changing printer font and font sizeIn Windows 2000 margin specificationIn Windows 2000, margin specification needs to drive linesize and pagesize
Win32 Class
Put all Windows functionality in one placepAccesses a table with Windows 32 errorserrorsCalls Win32 API with SASCBTBLI t f i d Vi l B iInterfaces a windows Visual Basic control
Region Class
“Region” is the base level of customization for surveysyDrives the assignment of LIBNAMEsDefines output filenamesDefines output filenames
SurveyAnalyzer
Strategy Design Pattern – have five programs to run, and the class p g ,determines which one to useConsolidation: Later refactored alongConsolidation: Later refactored along with the region class
Dataset Attribute Classes
ATTRC/ATTRN informationOpen and Close DatasetsOpen and Close DatasetsChildren have:
Al VARNUMAlways VARNUMSometimes VARLENS ti VARTYPESometimes VARTYPESometimes values
Final Classes
Expansion: enumerated structureHierarchyHierarchySurveyYearStateStateRegion
AnnualCode (periodically updated)AnnualCode (periodically updated)SentenceParser (functional)
New Changes
Expansion: enumerated structureSurveyYearAnalyzerSurveyYearAnalyzerStateAnalyzerRegionAnalyzerRegionAnalyzer
Analyzer classes form abstract base for processes now in their own classesprocesses, now in their own classesTotal Classes Currently: 44
Applying Refactoring
How organized is organized??Refactoring is choreographedRefactoring is choreographed
Sometimes expansionSometimes consolidationSometimes consolidation
Coding frameworks are increasingly important even for web workimportant, even for web work
Four Lessons
Recognize that all intentionally structured languages have inherent design pattern structure.Consider adding design patterns even if it
dmeans more code.Expect to continuously apply refactoring to l l li tilarge or complex applications.Continuously learn and apply design patterns.