Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Refactoring/BigRefactorings: Difference between revisions

From ZeroWiki
imported>Unknown
No edit summary
 
(Repair MoniWiki formatting after migration)
Line 2: Line 2:
= Chapter 12 Big Refactorings =
= Chapter 12 Big Refactorings =
== Tease Apart Inheritance ==
== Tease Apart Inheritance ==
* You have an inheritance hierarchy that is doing two jobs at once.''Create two hierarchies and use delegation to invoke one from the other.''
* You have an inheritance hierarchy that is doing two jobs at once.<br />''Create two hierarchies and use delegation to invoke one from the other.''
http://zeropage.org/~reset/zb/data/TeaseApartInheritance.gif
http://zeropage.org/~reset/zb/data/TeaseApartInheritance.gif
== Convert Procedural Design to Objects ==
== Convert Procedural Design to Objects ==
* You have code written in a procedural style.''Turn the date records into objects, break up the behavior, and move the behavior to the objects.''
* You have code written in a procedural style.<br />''Turn the date records into objects, break up the behavior, and move the behavior to the objects.''
http://zeropage.org/~reset/zb/data/ConvertProceduralDesignToObjects.gif  
http://zeropage.org/~reset/zb/data/ConvertProceduralDesignToObjects.gif  
== Separate Domain from Presentation ==
== Separate Domain from Presentation ==
* You have GUI classes that contain domain logic.''Separate the domain logic into separate domain classes.''
* You have GUI classes that contain domain logic.<br />''Separate the domain logic into separate domain classes.''
http://zeropage.org/~reset/zb/data/SeparateDomainFromPresentation.gif
http://zeropage.org/~reset/zb/data/SeparateDomainFromPresentation.gif
== Extract Hierarchy ==
== Extract Hierarchy ==
* You have a class that is doing too much work, at least in part through many conditional statements.''Create a hierarchy of classes in which each subclass represents a special case.''
* You have a class that is doing too much work, at least in part through many conditional statements.<br />''Create a hierarchy of classes in which each subclass represents a special case.''
http://zeropage.org/~reset/zb/data/ExtractHierarchy.gif   
http://zeropage.org/~reset/zb/data/ExtractHierarchy.gif   
----
----
[[Refactoring]]
[[Refactoring]]

Revision as of 14:01, 26 March 2026

Chapter 12 Big Refactorings

Tease Apart Inheritance

  • You have an inheritance hierarchy that is doing two jobs at once.
    Create two hierarchies and use delegation to invoke one from the other.

http://zeropage.org/~reset/zb/data/TeaseApartInheritance.gif

Convert Procedural Design to Objects

  • You have code written in a procedural style.
    Turn the date records into objects, break up the behavior, and move the behavior to the objects.

http://zeropage.org/~reset/zb/data/ConvertProceduralDesignToObjects.gif

Separate Domain from Presentation

  • You have GUI classes that contain domain logic.
    Separate the domain logic into separate domain classes.

http://zeropage.org/~reset/zb/data/SeparateDomainFromPresentation.gif

Extract Hierarchy

  • You have a class that is doing too much work, at least in part through many conditional statements.
    Create a hierarchy of classes in which each subclass represents a special case.

http://zeropage.org/~reset/zb/data/ExtractHierarchy.gif


Refactoring