Restructuring (EVO 2008)
Upcoming SlideShare
Loading in...5
×
 

Restructuring (EVO 2008)

on

  • 1,085 views

I used this set of slides at a lecture I gave at the University of Bern.

I used this set of slides at a lecture I gave at the University of Bern.

Statistics

Views

Total Views
1,085
Views on SlideShare
1,054
Embed Views
31

Actions

Likes
0
Downloads
22
Comments
0

3 Embeds 31

http://scglectures.unibe.ch 17
http://www.tudorgirba.com 11
http://www.slideshare.net 3

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Restructuring (EVO 2008) Restructuring (EVO 2008) Presentation Transcript

  • Restructuring Tudor Gîrba www.tudorgirba.com
  • fo rw g rin ar ee d gin en gin en ee se rin erv g re { { { { { { } { { } } actual development } } } { } } }
  • fo rw g rin ar ee d gin en gin en ee se rin erv g re { { { { { { } { { } } restructuring } } } { } } }
  • cycle ginee ring life Reen fo rw g rin ar ee d gin en gin en ee se rin erv g re { { { { { { } { { } } restructuring } } } { } } }
  • { { What? { { { { } { { } } restructuring } } } { } } }
  • Restructuring is often taken as a synonym of refactoring
  • Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior
  • Refactoring is behavior-preserving transformation
  • Restructuring is transforming a program to fit current needs
  • Why? { { What? { { { { } { { } } restructuring } } } { } } }
  • Software should be habitable
  • The secret to tidiness is to have a place for every thing Denker Markus
  • The secret to tidiness is to find the right place for every thing Denker Markus
  • If it stinks, change it Be ck Gr andma
  • How? Why? { { What? { { { { } { { } } restructuring } } } { } } }
  • Take a critical look at design
  • A God Class centralizes too much intelligence Class uses directly more than a few attributes of other classes ATFD > FEW Functional complexity of the class is very high AND GodClass WMC ! VERY HIGH Class cohesion is low TCC < ONE THIRD 006 ari nescu 2 L anza, M
  • ModelFacade from ArgoUML
  • p God Class Split u ModelFacade from ArgoUML 2 er etal 200 Demey
  • d than done Easi er sai 2 er etal 200 Demey
  • also w rap it You can 2 er etal 200 Demey
  • you do not Maybe uch it at all need to to God Class in the last version isGodClass(last) AND Harmless God Class Stable throughout the history Stability > 90% 4 Ratiu etal, 200
  • Client Provider service()
  • Client Intermediary Provider getProvider() service()
  • Client Intermediary Provider getProvider() service() this.intermediary.provider.service();
  • Provider2 service2() Client Intermediary Provider getProvider() service() Provider3 service3() this.intermediary.provider.service(); this.intermediary.provider2.service2(); this.intermediary.provider3.service3();
  • Provider2 service2() Client Intermediary Provider getProvider() service() Provider3 service3() this.intermediary.provider.service(); this.intermediary.provider2.service2(); this.intermediary.provider3.service3(); to str angers eter : D on’t talk of Dem T he Law
  • Code te Nav igation E limina Provider2 service2() Client Intermediary Provider fullService() service() Provider3 service3() this.intermediary.fullService(); 2 er etal 200 Demey
  • ge inte rfaces ad to hu t: This can le Provider2 Cavea service2() Client Intermediary Provider fullService() service() Provider3 service3() this.intermediary.fullService(); 2 er etal 200 Demey
  • Middl e Man R emove Provider2 service2() Client Provider service() Provider3 service3() this.provider.service(); this.provider2.service2(); this.provider3.service3(); Fow ler 1999
  • An Envious Method is more interested in data from a handful of other classes Method uses directly more than a few attributes of other classes ATFD > FEW Method uses far more attributes of other classes than its own AND Feature Envy LAA < ONE THIRD The used quot;foreignquot; attributes belong to very few other classes FDP ! FEW 006 ari nescu 2 L anza, M
  • ser to Data Behavi or Clo Move
  • Data Classes are dumb data holders Interface of class reveals data rather than offering services WOC < ONE THIRD AND Data Class Class reveals many attributes and is not complex 006 ari nescu 2 L anza, M
  • ser to Data Behavi or Clo Move
  • Significant Duplication 006 ari nescu 2 L anza, M
  • A A m1 m1' m3 m2 m2' 6 ne scu 200 Lanza, Mari
  • A A m3 B C B C m1 m2 m1 m2 6 ne scu 200 Lanza, Mari
  • Restructuring can also improve performance
  • BusinessObject Client BusinessSessionBean BusinessEntityBean
  • BusinessObject SessionFacade Client BusinessSessionBean BusinessEntityBean java .sun.com
  • ModelFacade from ArgoUML es are good, Not al l Facad od :) some are G
  • Trouble never comes alone Ano nymous
  • Redistribute Transform conditionals responsibilities to Polymorphism Eliminate Split up Transform Client ... Navigation Code God Class Type Checks Move Behavior Introduce Null Object Closer to Data
  • es pro blems ode co rrelat inC
  • When? How? Why? { { What? { { { { } { { } } restructuring } } } { } } }
  • Restructure all the time
  • Restructure all the time his fea sible? … hm m, is t
  • It is feasible
  • Development Maintenance
  • are evolution Softw
  • Tudor Gîrba www.tudorgirba.com creativecommons.org/licenses/by/3.0/