Who are your parents? Where is the code, belonging to a - - PowerPoint PPT Presentation

who are your parents
SMART_READER_LITE
LIVE PREVIEW

Who are your parents? Where is the code, belonging to a - - PowerPoint PPT Presentation

Who are your parents? Where is the code, belonging to a feature? Who are the guys you hang out with? How are features related to each


slide-1
SLIDE 1
slide-2
SLIDE 2
slide-3
SLIDE 3

Who ¡are ¡your ¡parents? ¡ Who ¡are ¡the ¡guys ¡you ¡hang ¡out ¡with? ¡ What ¡does ¡you ¡educa4on ¡cost? ¡

Where ¡is ¡the ¡code, ¡belonging ¡to ¡a ¡feature? ¡ How ¡are ¡features ¡related ¡to ¡each ¡other? ¡ How ¡expensive ¡is ¡it ¡to ¡change ¡features? ¡

slide-4
SLIDE 4

static int _rep_queue_filedone(...) DB_ENV *dbenv; REP *rep; __rep_fileinfo_args *rfp; { #ifndef HAVE_QUEUE COMPQUIET(rep, NULL); COMPQUIET(rfp, NULL); return (__db_no_queue_am(dbenv)); #else db_pgno_t first, last; u_int32_t flags; int empty, ret, t_ret; #ifdef DIAGNOSTIC DB_MSGBUF mb; #endif ...

Excerpt from Oracle’s Berkeley DB

Conditional Compilation

slide-5
SLIDE 5

Objec4ons ¡/ ¡Cri4cism ¡

“#ifdef considered harmful”

“#ifdef hell”

Designed in the 70th and hardly evolved since

“preprocessor diagnostics are poor”

“is difficult to determine if the code being viewed is actually compiled into the system” “programming errors are easy to make and difficult to detect”

“incomprehensible source texts”

“maintenance becomes a ‘hit or miss’ process” “CPP makes maintenance difficult” “source code rapidly becomes a maze”

slide-6
SLIDE 6

A ¡CLOSER ¡LOOK ¡AT ¡PREPROCESSORS ¡ ¡

slide-7
SLIDE 7

Separa4on ¡of ¡Concerns ¡

slide-8
SLIDE 8

2000 features 10000

features

slide-9
SLIDE 9

find <ordner> -type f \( -name "*.h" -o -name "*.c" \) -exec egrep '^\s*#if' '{}' \; | sed -e 's/#ifndef//' | sed -e 's/ #ifdef//' | sed -e 's/#if//' | sort | uniq | wc -l

slide-10
SLIDE 10

How ¡is ¡the ¡preprocessor ¡used ¡? ¡(Liebig ¡et ¡al., ¡ICSE ¡'10) ¡

23% of the code is variable Variable code mostly heterogeneous (89%)

At ¡which ¡granularity ¡? ¡(Liebig ¡et ¡al., ¡AOSD ¡'11) ¡

Variability mostly at coarse granularity (84%) What about the remaining 16% ?

slide-11
SLIDE 11
slide-12
SLIDE 12

TransformaAon ¡(Refactoring) ¡ Coarse-­‑grained ¡annota4ons ¡prone ¡to ¡clones ¡(Schulze ¡et ¡al., ¡SCAM ¡'11) ¡ ¡What ¡about ¡Program ¡Comprehension? ¡ ¡Good ¡or ¡Bad? ¡

slide-13
SLIDE 13 push ¡ ... ¡ …. ¡ …. ¡ …. ¡ .. ¡ .. . ¡ ….. ¡ if ¡ …. ¡

Experiment ¡on ¡Program ¡Comprehension ¡of ¡ preprocessor ¡annota4ons ¡ Coarse-­‑grained ¡vs. ¡fine-­‑grained ¡

e.g., ¡Remove ¡all ¡code ¡that ¡belongs ¡to ¡Feature ¡IP_V6 ¡! ¡

slide-14
SLIDE 14
slide-15
SLIDE 15

Views ¡

[Kästner et al., ICSE '08]

slide-16
SLIDE 16
slide-17
SLIDE 17

improved ¡Readability ¡ reduced ¡programmer ¡effort ¡ composi4onality ¡ ¡ lower ¡expressiveness ¡ bloated ¡code ¡→ ¡clones ¡ high ¡expresiveness ¡ language-­‑independent ¡ easy ¡to ¡use ¡ ¡ tangled/sca\ered ¡code ¡

  • bfusca4on ¡→ ¡hard ¡to ¡

understand/modify ¡

slide-18
SLIDE 18

Feature-­‑Oriented ¡ ¡

Product ¡Lines ¡

slide-19
SLIDE 19

Feature ¡Module ¡

slide-20
SLIDE 20
slide-21
SLIDE 21

Where ¡is ¡the ¡code, ¡belonging ¡to ¡a ¡feature ¡? ¡ How ¡are ¡features ¡related ¡to ¡each ¡other ¡? ¡ How ¡expensive ¡is ¡it ¡to ¡change ¡features ¡? ¡

Hard ¡to ¡determine ¡with ¡preprocessors; ¡modularity ¡helps ¡ Alterna4ve ¡representa4ons ¡required, ¡e.g., ¡visualiza4on ¡ Depends ¡on ¡granularity ¡and ¡separa4on ¡of ¡concerns ¡

slide-22
SLIDE 22

What's ¡next... ¡

Iden4fying ¡featues ¡in ¡legacy ¡appica4ons ¡→ ¡variability ¡mining ¡ Reverse ¡Engineering ¡So_ware ¡Product ¡Lines ¡ Evolu4on ¡of ¡So_ware ¡Product ¡Lines ¡

...from ¡a ¡Provenance ¡Perspec4ve ¡

→ ¡commonali4es ¡and ¡variabili4es ¡

slide-23
SLIDE 23

Ques4ons ¡

slide-24
SLIDE 24

Program ¡Comprehension: ¡An ¡Experiment ¡

  • #ifdef ¡vs. ¡colors ¡
  • 43 ¡subjects ¡in ¡2 ¡ ¡

groups ¡

  • S1-­‑2: ¡search ¡tasks ¡

faster ¡with ¡colors ¡ ¡ (43% ¡& ¡23%) ¡

  • M1-­‑3: ¡maintenance ¡

tasks ¡same ¡perform. ¡

  • M4: ¡maintenance ¡ ¡

task ¡with ¡red ¡back-­‑ ¡ ground ¡color ¡-­‑37% ¡

  • No ¡influence ¡on ¡correctness ¡
  • Subjects ¡prefer ¡colors ¡
slide-25
SLIDE 25

Scaling ¡Visual ¡Representa4ons ¡

  • Focus ¡on ¡few ¡features ¡at ¡a ¡4me ¡
  • Repea4ng ¡colors ¡/ ¡manual ¡assignment ¡sufficient ¡
  • Analysis ¡of ¡4 ¡Java ¡ME ¡and ¡40 ¡C ¡programs: ¡
  • 96 ¡% ¡pages ¡of ¡source ¡code ¡with ¡≤ ¡3 ¡colors ¡
  • 99 ¡% ¡pages ¡of ¡source ¡code ¡with ¡≤ ¡7 ¡colors ¡
slide-26
SLIDE 26

Error-­‑Prone ¡

static int _rep_queue_filedone(...) DB_ENV *dbenv; REP *rep; __rep_fileinfo_args *rfp; { #ifndef HAVE_QUEUE COMPQUIET(rep, NULL); COMPQUIET(rfp, NULL); return (__db_no_queue_am(dbenv)); #else db_pgno_t first, last; u_int32_t flags; int empty, ret, t_ret; #ifdef DIAGNOSTIC DB_MSGBUF mb; #endif // over 100 lines of add. code } #endif #ifdef TABLES class Table { void insert(Object data, Txn txn) { storage.set(data, txn.getLock()); } } #endif class Storage { #ifdef WRITE boolean set(…) { ... } #endif }