application refactoring with design patterns

15
Application Refactoring ith D i P tt with Design Patterns Mark Tabladillo, Ph.D. March 31, 2003

Upload: mark-tabladillo

Post on 18-Dec-2014

1.965 views

Category:

Technology


1 download

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

Page 1: Application Refactoring With Design Patterns

Application Refactoringith D i P ttwith Design Patterns

Mark Tabladillo, Ph.D.March 31, 2003

Page 2: Application Refactoring With Design Patterns

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

Page 3: Application Refactoring With Design Patterns

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

Page 4: Application Refactoring With Design Patterns

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)

Page 5: Application Refactoring With Design Patterns

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)

Page 6: Application Refactoring With Design Patterns

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

Page 7: Application Refactoring With Design Patterns

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

Page 8: Application Refactoring With Design Patterns

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

Page 9: Application Refactoring With Design Patterns

Region Class

“Region” is the base level of customization for surveysyDrives the assignment of LIBNAMEsDefines output filenamesDefines output filenames

Page 10: Application Refactoring With Design Patterns

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

Page 11: Application Refactoring With Design Patterns

Dataset Attribute Classes

ATTRC/ATTRN informationOpen and Close DatasetsOpen and Close DatasetsChildren have:

Al VARNUMAlways VARNUMSometimes VARLENS ti VARTYPESometimes VARTYPESometimes values

Page 12: Application Refactoring With Design Patterns

Final Classes

Expansion: enumerated structureHierarchyHierarchySurveyYearStateStateRegion

AnnualCode (periodically updated)AnnualCode (periodically updated)SentenceParser (functional)

Page 13: Application Refactoring With Design Patterns

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

Page 14: Application Refactoring With Design Patterns

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

Page 15: Application Refactoring With Design Patterns

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.