Make Software Soft
-- Learn from A Refactoring Case



赵喜鸿
Who am I?

From Alcatel-Lucent

Software developer

A fervent advocate of Agile methodologies

11 years' experience in software development
   and team management

Now, refactoring a legacy telecom equipment
  system.
Why call it “Software”?
Soft

• yielding readily to touch or pressure; easily
  penetrated, divided, or changed in shape; not hard
  or stiff

• Easily molded, cut, or worked.

• Easy to influence or impose upon



       Easy to change
Is Software Soft?
Is Software Soft?




http://www.codeproject.com/KB/books/SoftwareProjectSecrets1.aspx
Is Software Soft?




http://gtwebmarque.com/wikis/gtwm/index.php/Project_Failure
“Reasons”
and “Solutions”
Contract
Insufficient Upfront Design
More Upfront Design
Design   Reality
A Real Refactoring Case
Understand Problem Domain
Epon Management
Run On NT Board   On LT Board



                  Is it soft?
Make It Softer
Update
                op state


                  Save to
                  database

Configuration
                  Config to
                  hardware
    Changed
Observer Pattern
Listener
                 “state”


                     Listener
                     “persist”

Configuration
                    Listener
                     Listener
                    “HWW”
                     “HWW”


                  New
                Listener
PonData


Data-            State
        Config           Fault   PM   HWW
Base
PonData


Data-               State
          Config            Fault    PM     HWW
Base



        NtPonLine                   LtPonLine
xxxData


Data-                     State
        Config                    Fault           PM   HWW
Base



                             xxxLine

                 Config                State

                            xxxData
                  Data-
                                          Fault
                  Base
Now
New Line Object



                     Fault
         State

                  xxxData    PM


         Config     Data-
                    Base
New Line Object



                     Fault
         State

                  xxxData    PM


         Config     Data-
                    Base




       Open to change?
config a line                 Context
                              Retrieve PM


                   PM
                  Config




                Line Object


                                Role
Fault Handling
                      Context
                                    Retrieve PM
                                      Context

Retrieve State
   Context


RetrieveLine
  Context


               ConfigLine
                Context
DCI Architecture
Data
    What the system is
Context
    The Context is the class (or its instance) whose code
         includes the roles for a given algorithm, scenario, or
         use case, as well as the code to map these roles into
         objects at run time and to enact the use case.
Interaction
    The Interaction is "what the system does." The Interaction is
         implemented as Roles which are played by objects at
         run time



 http://www.artima.com/articles/dci_vision.html
EponMgr

          Pon

                 Ont

                       Llid

                              Uni

   Is It Soft?                      Service
What is the essence of the problem?
EponMgr
                                  Managed Object
            Pon

                     Ont

                           Llid

                                   Uni


                                           Service
          Relation
ManagedObject     ManagedObject

            Relation
Box   Board   Line   Service
Domain Model


Box     Board   Line    Service



ManagedObject    ManagedObject
Soft
Software
What Missed

           Domain Model



              Soft
  Bricks    Software Refactoring

            Framework
道法自然
Tao follows nature
Summary
The only thing constant is


       change
Cope with Changes by


making software soft
Heart of making software soft is


 Discovering the “Tao”
The way to discover “Tao” is


      refactoring
“Tao” is the heart of making
       software SOFT


People are the brain to
    find the heart
Thank You

Contact:
   xihong.zhao@gmail.com
  Weibo: http://weibo.com/zhaoxihong
Questions?

打造真正的软件