Separating Features in Source Code An Exploratory Study

  • Slides: 19
Download presentation
Separating Features in Source Code: An Exploratory Study Gail Murphy Albert Lai Robert Walker

Separating Features in Source Code: An Exploratory Study Gail Murphy Albert Lai Robert Walker Martin Robillard University of British Columbia

Overview of Study Format • Lightweight SOC (Control) • Hyper/J • Aspect. J •

Overview of Study Format • Lightweight SOC (Control) • Hyper/J • Aspect. J • gnu. regexp • j. FTPd 2

Contributions • Characterize the process of restructuring a codebase to permit separation of concerns

Contributions • Characterize the process of restructuring a codebase to permit separation of concerns (features) • Characterize the effect of separating concerns on structure 3

Lightweight SOC (Control) • Refactor to capture (as much as possible) concerns as classes

Lightweight SOC (Control) • Refactor to capture (as much as possible) concerns as classes • Use a naming convention to refer to concern classes • (Use a lexical tool, like grep, to factor concern out based on naming convention) 4

Hyper/J class Test { void do. It() { println( “do. It” ); } }

Hyper/J class Test { void do. It() { println( “do. It” ); } } class Hello { void do. It() { println( “hello” ); } } Concern Mapping File class Test: Feature. Kernel; class Hello: Feature. Hello; Hypermodule File merge. By. Name; order action Feature. Hello. do. It before Feature. Kernel. do. It 5

Aspect. J class Test { void do. It() { println( “do. It” ); }

Aspect. J class Test { void do. It() { println( “do. It” ); } } aspect Hello { pointcut actions(): receptions( void do. It() ); before(): actions() { println( “Hello” ); } } 6

Study Format • Tangling of concerns in a single method – Conditional structure in

Study Format • Tangling of concerns in a single method – Conditional structure in regular expression matching in gnu. regexp • Tangling of concerns across classes – Part of GUI concern in j. FTPd 7

Tangling in a Single Method class REToken. Start { int[] match( … ) {

Tangling in a Single Method class REToken. Start { int[] match( … ) { // Multiline match if ( newline && … ) return next( … ); } … // Not BOL match if ( ( eflags & … ) ) return null; 8

Tangling in a Single Method: Lightweight SOC class Multiline class REToken. Start class Not.

Tangling in a Single Method: Lightweight SOC class Multiline class REToken. Start class Not. BOL int[] match( … ) class Anchored New Modified Knows About Base Structure Existing 9

Tangling in a Single Method: Hyper/J class REToken. Start int[] match( … ) Tmp.

Tangling in a Single Method: Hyper/J class REToken. Start int[] match( … ) Tmp. Result private. Match(…) Tmp. Result match. Other(…) Tmp. Result match. Multiline(…) … Tmp. Result summarize. Match(…) Concern Mapping File Hypermodule File class Tmp. Result 10

Tangling in a Single Method: Aspect. J class REToken. Start int[] match( … )

Tangling in a Single Method: Aspect. J class REToken. Start int[] match( … ) aspect Multiline aspect Not. BOL aspect Anchored 11

Tangling in a Single Method: Comparison Lightweight SOC Aspect. J Hyper/J 12

Tangling in a Single Method: Comparison Lightweight SOC Aspect. J Hyper/J 12

Tangling across Classes class Handler class Status. Window class About. Box 13

Tangling across Classes class Handler class Status. Window class About. Box 13

Tangling across Classes: Lightweight (SOC) class Status. Window 5 Methods Changed class Status. Window.

Tangling across Classes: Lightweight (SOC) class Status. Window 5 Methods Changed class Status. Window. GUI class Handler show( … ) class About. Box 14

Tangling across Classes: Hyper/J interface IStatus. Window class Status. Window 3 Methods Changed 3

Tangling across Classes: Hyper/J interface IStatus. Window class Status. Window 3 Methods Changed 3 Methods Added class Status. Window_GUI class About. Box interface IHandler class Handler 8 Methods Changed 2 Methods Added class Handler_GUI 15

Tangling across Classes: Aspect. J class Status. Window aspect GUI 5 Methods Changed disconnect…

Tangling across Classes: Aspect. J class Status. Window aspect GUI 5 Methods Changed disconnect… (…) class Status. Window. GUI show( … ) class About. Box class Handler 16

Tangling across Classes: A Comparison Lightweight SOC Aspect. J Hyper/J 17

Tangling across Classes: A Comparison Lightweight SOC Aspect. J Hyper/J 17

Results • Designing appropriate target structures – Structure will affect other development concerns –

Results • Designing appropriate target structures – Structure will affect other development concerns – Consider “knows-about” • Preparing for separating concerns – Restructure for good OO structure first – Reorganize methods to expose suitable joinpoints • Restructuring the code – Non-meaning-preserving restructuring support 18

Summary • Step towards understanding design space of advanced separation of concern mechanisms •

Summary • Step towards understanding design space of advanced separation of concern mechanisms • Analysis of tradeoffs between structures resulting from different mechanisms • More study is required to elaborate design space and develop appropriate style guidelines 19