Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Code refactoring
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Transformations=== Transformations modify the syntactic representation of a program. Some modifications alter the semantics or structure of the program in a way which improves its flexibility or robustness. Such modifications require knowledge of the problem domain and intended logic, and thus are infeasible to automate. Modifications exist which make the program easier to read and modify but which to not alter the underlying logic of the program; these transformations can be automated. * Techniques that allow for more [[Abstraction (computer science)|abstraction]] ** [[Field encapsulation|Encapsulate field]] β force code to access the field with getter and setter methods ** [[Type generalization|Generalize type]] β create more general types to allow for more code sharing ** Replace type-checking code with state/strategy<ref>{{cite web| url = http://refactoring.com/catalog/replaceTypeCodeWithStateStrategy.html| title = Replace type-checking code with State/Strategy}}</ref> ** Replace conditional with [[Polymorphism (computer science)|polymorphism]]<ref>{{cite web| url = http://refactoring.com/catalog/replaceConditionalWithPolymorphism.html| title = Replace conditional with polymorphism}}</ref> * Techniques for breaking code apart into more logical pieces ** Componentization breaks code down into reusable semantic units that present clear, well-defined, simple-to-use interfaces. ** [[Extract class]] moves part of the code from an existing class into a new class. ** Extract method, to turn part of a larger [[method (computer science)|method]] into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to [[Function (programming)|function]]s. * Techniques for improving names and location of code ** Move method or move field β move to a more appropriate [[Class (computer science)|class]] or source file ** Rename method or rename field β changing the name into a new one that better reveals its purpose ** Pull up β in [[object-oriented programming]] (OOP), move to a [[Superclass (computer science)|superclass]] ** Push down β in OOP, move to a [[Subclass (computer science)|subclass]]<ref name="refactoring.com"/> * Automatic [[clone detection]]<ref>{{cite conference |first1=M. |last1=Bruntink |first2=A. |last2=van Deursen |first3=T. |last3=Tourwe |first4=R. |last4=van Engelen |title=An evaluation of clone detection techniques for crosscutting concerns |book-title=Proceedings, 20th IEEE International Conference on Software Maintenance |publisher=IEEE |date=2004 |doi=10.1109/ICSM.2004.1357804}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)