Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Refactoring Process

Posted on 2005-03-01
5
Medium Priority
?
340 Views
Last Modified: 2008-02-26
What is the the refactoring process? I keep hearing about it but im not sure what it is all about. Also I have found that there are a few concepts such as responsibility-driven, coupling, cohesion. Should I be worried about violating them?
0
Comment
Question by:eli290
  • 3
5 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 13432666
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13432683
Refactoring is basically redesigning code in a more rational manner. 'Responsibility' is about what 'duties' a class is intended to perform and it's functional boundaries relative to other classes. 'Coupling' is the notion of how much a class should be dependent on another or others. 'Cohesion' seems quite general but is probably centred around how things 'hang together'. These are all factors to be tken into account in good design or refactoring.
0
 
LVL 37

Accepted Solution

by:
zzynx earned 2000 total points
ID: 13432708
Instead of writing new applications from scratch, much of a developer's job today involves changing existing code.
Simple changes may consist of just adding on to the existing code.
However, as multiple revisions or extensive changes are made, the internal structure of the software may begin to deteriorate.
It can become difficult to understand, and expensive to modify and maintain. That is why it is important to know how to refactor code.
Refactoring is changing the internal structure of software to make that software easier to understand and cheaper to modify
without changing its observable behavior.
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 13434002
Umm, yes. You should be worrying about violating them.

There are numerous design principles and heuristics which we should use as guidance in producing good OO designs. Coupling and cohesion are two measurements (or metrics) we can use to help us evaluate how well (or how poorly) we've applied these principles. And where we have low cohesion and/or high coupling, we have the opportunity to refactor our design to improve cohesion and/or reduce coupling.

Robert Martin of Object Mentor has written extensively about OO design principles. You can read some of his work for free at http://www.objectmentor.com/resources/listArticles?key=topic&topic=Design%20Principles. I'd start with the Principles and Patterns piece and then dive into the others as you might want more depth. He elaborates on these principles as well as patterns and the software development process in his book Agile Software Development. I'd recommend it more heartily but my respnosibilities have prevented me from doing much more than skimming.

Another author that I would advocate is Arthur Riel and his book OO Design Heuristics: http://www.bookpool.com/sm/020163385X. This book categorizes some 60 heuristics or "rules of thumb" that you can use when designing and evaluating a design. Although it is nearly a decade old and the examples are in C++, these heuristics are well respected and worth knowing. You can get a flavor for the book's contents here: http://lcm.csa.iisc.ernet.in/soft_arch/OO_Design_Heuristic.htm.

Refactoring has been defined as improving the design of software without changing its behavior. Or, at least, its externally visible behavior. There are many kinds of refactorings that amount to renaming or moving things. Other refactorings are more "intrusive" in that they call for a more significant shift in the implementation to introduce polymorphism or introduce stronger encapsulation. The most extensive refactorings tend to be about morphing existing code to apply specific design patterns.

This practice of refactoring isn't new. Programmers and designers have been doing it for a long time. What is new is that the practice is better codified and many of the mechanisms used and thought-processes applied are being documented so that they can be disseminated and learned. Foundational in this effort is the book Refactoring: Improving the Design of Existing Code, again by Robert Martin: http://www.bookpool.com/sm/0201485672. I strongly encourage you to acquire it. You can get a flavor for its contents here: http://www.refactoring.com/catalog/.

Another book I intend to buy soon is Joshua Kerievsky's Refactoring to Patterns: http://www.bookpool.com/sm/0321213351. The catalog of refactorings discussed is presented here: http://www.industriallogic.com/xp/refactoring/catalog.html.

Schooling yourself on OO design principles, heuristics, and refactorings will help you become a better designer and developer. There isn't much you can do here that will be a waste of time.

Best regards,
Jim Cakalic
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13447395
Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question