Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Recommending Refactorings to Reverse Software Architecture Erosion (CSMR 2012)

Recommending Refactorings to Reverse Software Architecture Erosion (CSMR 2012)

Architectural erosion is a recurrent problem faced by software architects. Despite this fact, the process is usually tackled in ad hoc way, without adequate tool support at the architecture level. To address this issue, we describe the preliminary design of a recommendation system whose main purpose is to provide refactoring guidelines for developers and maintainers during the task of reversing an architectural erosion process. The paper formally describes first recommendations proposed in our current research and results of their application in a web-based application.

ASERG, DCC, UFMG

March 29, 2012
Tweet

More Decks by ASERG, DCC, UFMG

Other Decks in Research

Transcript

  1. Recommending Refactorings to Reverse Software
    Architecture Erosion
    Ricardo Terra
    Marco Túlio Valente Krzysztof Czarnecki
    Roberto S. Bigonha
    {terra,bigonha,mtov}@dcc.ufmg.br [email protected]
    CSMR ERA, 2012
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 1 / 10

    View Slide

  2. Introduction
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 2 / 10
    Intended

    View Slide

  3. Introduction
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 2 / 10
    Intended Implemented

    View Slide

  4. Introduction
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 2 / 10
    Intended Implemented

    View Slide

  5. Introduction
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 2 / 10
    Intended Implemented

    View Slide

  6. Introduction
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 2 / 10
    Intended Implemented

    View Slide

  7. Motivation
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 3 / 10
    Detecting...

    View Slide

  8. Motivation
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 3 / 10
    Detecting...
    But...
    ?
    expertise
    waste of time
    ad hoc procedures

    View Slide

  9. Architectural Recommendation Engine – Overview
    Architectural Recommendation Engine
    Architectural_Rule
    Code_With_Violation =⇒ Recommendation,
    if Preconditions
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 4 / 10

    View Slide

  10. Architectural Recommendation Engine – Overview
    Architectural Recommendation Engine
    Architectural_Rule
    Code_With_Violation =⇒ Recommendation,
    if Preconditions
    Sounds like?
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 4 / 10

    View Slide

  11. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL

    View Slide

  12. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B

    View Slide

  13. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B

    View Slide

  14. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B

    View Slide

  15. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B

    View Slide

  16. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B

    View Slide

  17. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B
    analyzes the violation

    View Slide

  18. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B
    analyzes the violation
    A /
    ∈ FactoryB
    A cannot-create B

    View Slide

  19. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B
    analyzes the violation
    checks constraints
    A /
    ∈ FactoryB
    A cannot-create B

    View Slide

  20. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B
    analyzes the violation
    checks constraints
    A /
    ∈ FactoryB
    A cannot-create B

    View Slide

  21. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B
    analyzes the violation
    checks constraints
    performs SCA
    A /
    ∈ FactoryB
    A cannot-create B

    View Slide

  22. Architectural Recommendation Engine – Overview
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 5 / 10
    Exactly! However, focus on the architectural level
    DCL
    only FactoryB can-create B
    analyzes the violation
    checks constraints
    performs SCA
    A /
    ∈ FactoryB
    A cannot-create B
    + getB() : B

    View Slide

  23. Architectural Recommendation Engine – Overview
    Bingo!
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 6 / 10

    View Slide

  24. Architectural Recommendation Engine – Overview
    Bingo!
    Triggered Refactoring Recommendation
    A cannot-create B
    new B(exp) =⇒ replace( [new B(exp)], [FB.getB(exp)] ),
    if FB = factory(B, [exp] ) ∧ can(A, access, FB)
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 6 / 10

    View Slide

  25. Refactoring Recommendations – Table
    A cannot-create B, where A ∈ MA ∧ B ∈ MB
    new B(exp) =
    ⇒ replace( [new B(exp)], [FB.getB(exp)] ), if FB = factory(B, [exp] ) ∧
    can(A, access, FB)
    new B(exp) =
    ⇒ replace( [new B(exp)], [FB.getB(exp)] ), if FB = gen_factory(B, [exp] ) ∧
    can(A, access, FB)
    A cannot-declare B
    B b; S =
    ⇒ replace( [B], [B ] ), if B ∈ super(B) ∧ typecheck( [B b ; S] ) ∧ B /
    ∈ MB
    B b = exp; S =
    ⇒ propagate( [exp], b, [S] ), if can(A, access, B)
    A cannot-access B
    b.f =
    ⇒ replace( [b.f], [D; c.g] ), if g = delegate(f) ∧ D = gen_decl(type(c), g) ∧
    type(c) /
    ∈ MB
    b.f =
    ⇒ g = extract( [b.f] ), move(g, C), if C = suitable_class(g) ∧
    can(A, access, C)
    g { T v = exp_b } =
    ⇒ promote(g, v, [exp_b] ), if ∀C ∈ call_sites(g), can(C, access, B)
    A cannot-throw B
    g (p) throws B { S } =
    ⇒ remove( [throws B] ), if typecheck( [g (p) { S }] )
    g (p) throws B { S } =
    ⇒ remove( [throws B] ), replace( [S], [try {S} catch (B b){S }] ),
    if can(A, declare, B) ∧ S = user_code()
    A cannot-derive B
    A extends | implements B =
    ⇒ move(A, M), if M = suitable_module(A) ∧ can(A, extends | implements, B)
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 7 / 10
    We have formalized a set of more than 20 refactoring recommendations!

    View Slide

  26. Preliminary Evaluation
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 8 / 10
    MyWebMarket
    simple web-based e-commerce system

    View Slide

  27. Preliminary Evaluation
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 8 / 10
    MyWebMarket
    simple web-based e-commerce system
    mirrors architecture, constraints,
    and violations from a previously
    evaluated system

    View Slide

  28. Preliminary Evaluation
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 8 / 10
    MyWebMarket
    simple web-based e-commerce system
    mirrors architecture, constraints,
    and violations from a previously
    evaluated system
    #1: only DAOFactory can-create HibernateDAO
    #2: Controller cannot-handle HibernateDAO
    #3: Model can-only-throw DAOException
    #4: only SystemScheduling can-depend QuartzAPI

    View Slide

  29. Preliminary Evaluation
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 8 / 10
    MyWebMarket
    simple web-based e-commerce system
    mirrors architecture, constraints,
    and violations from a previously
    evaluated system
    #1: only DAOFactory can-create HibernateDAO
    #2: Controller cannot-handle HibernateDAO
    #3: Model can-only-throw DAOException
    #4: only SystemScheduling can-depend QuartzAPI
    Constraint # Violations # Recs. # Violations
    before after
    #1 21 21 0
    #2 43 15 12
    #3 44 44 0
    #4 9 9 0

    View Slide

  30. Preliminary Evaluation
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 8 / 10
    MyWebMarket
    simple web-based e-commerce system
    mirrors architecture, constraints,
    and violations from a previously
    evaluated system
    #1: only DAOFactory can-create HibernateDAO
    #2: Controller cannot-handle HibernateDAO
    #3: Model can-only-throw DAOException
    #4: only SystemScheduling can-depend QuartzAPI
    Constraint # Violations # Recs. # Violations
    before after
    #1 21 21 0
    #2 43 15 12
    #3 44 44 0
    #4 9 9 0
    ∼90%!

    View Slide

  31. Ongoing work
    Evaluation in real systems (in progress)
    Medium-size (30KLOC)
    Large-size (750KLOC)
    More refactoring recommendations (in progress)
    Divergences and also absences
    The dclsuite tool (in progress)
    dclcheck + dclfix
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 9 / 10

    View Slide

  32. Thanks!!!
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 10 / 10

    View Slide

  33. CSMR 2012
    Presentation: Thursday, March 29, 2012, at 11am
    Poster Session: On the Afternoon of the same day
    CSMR ERA, 2012 Recommending Refactorings to Reverse Software Architecture Erosion 10 / 10

    View Slide