• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Refactoring
 

Refactoring

on

  • 534 views

 

Statistics

Views

Total Views
534
Views on SlideShare
272
Embed Views
262

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 262

http://socialcubebd.com 262

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Refactoring Refactoring Presentation Transcript

    • RefactoringBy Rabeya Bashri
    • RefactoringWhat is RefactoringWhy should we use RefactoringWhen should we use RefactoringWhen should not we use RefactoringWhy Refactoring worksProblem with RefactoringSome ScenarioConclusion
    • What is Refactoring a disciplined technique, used for restructuring an existing body of code altering its internal structure without changing its external behavior Its heart is a series of small behavior preserving transformations. Eachtransformation does little, but a sequence of transformations can produce asignificant restructuring. Refactoring (noun): a change made to the internal structure of software tomake it easier to understand and cheaper to modify without changing itsobservable behavior. Refactor (verb): to restructure software by applying a series of refactoringswithout changing its observable behavior. it provides a technique for cleaning up code in a more efficient andcontrolled manner.
    • Why should we use Refactoring Refactoring Improves the Design of Software It becomes harder to see the design by reading the code. Regular refactoring helps code retain its shape. Poorly designed code usually takes more code to do the same things, oftenbecause the code quite literally does the same thing in several places. Thus animportant aspect of improving design is to eliminate duplicate code. By eliminating the duplicates, you ensure that the code says everything onceand only once, which is the essence of good design. Refactoring Makes Software Easier to Understand It does matter if it takes a programmer a week to make a change that wouldhave taken only an hour if programmer had understood your code. Refactoring Helps You Find Bugs Refactoring helps programmer be much more effective at writing robust code. Refactoring Helps You Program Faster a good design is essential for rapid software development. Without a good design, you can progress quickly for a while, but soon the poordesign starts to slow you down. You spend time finding and fixing bugs insteadof adding new function. Changes take longer as you try to understand thesystem and find the duplicate code.
    • When should we use Refactoring refactoring is not an activity you set aside time to do. Refactoring issomething you do all the time in little bursts. You don’t decide torefactor, you refactor because you want to do something else, andrefactoring helps you do that other thing. The Rule of Three Refactor When You Add Function Refactor When You Need to Fix a Bug Refactor As You Do a Code Review
    • When should not we use Refactoring A clear sign of the need to rewrite is when the current codejust does not work. You may discover this only by trying totest it and discovering that the code is so full of bugs that youcannot stablilize it. Remember, code has to work mostlycorrectly before you refactor. The other time you should avoid refactoring is when you areclose to a deadline. At that point the productivity gain fromrefactoring would appear after the deadline and thus be toolate.
    • Why Refactoring works What is it that makes programs hard to work with? Fourthings I can think of as I am typing this are as follows:Programs that are hard to read are hard to modify.Programs that have duplicated logic are hardto modify.Programs that require additional behavior thatrequires you to change running code are hardto modify.Programs with complex conditional logic are hardto modify. So, we want programs that are easy to read, that haveall logic specified in one and only one place, that do notallow changes to endanger existing behavior, and thatallow conditional logic to be expressed as simplyas possible.
    • Problem with Refactoring Databases One problem area for refactoring is databases. Most businessapplications are tightly coupled to the database schema that supportsthem.That’s one reason that the database is difficult to change. Another reason is data migration. Even if you have carefully layeredyour system to minimize the dependencies between the databaseschema and the object model, changing the database schema forcesyou to migrate the data, which can be a long and fraught task. Changing Interfaces Something that is disturbing about refactoring is that many of therefactorings do change an interface. Design Changes That Are Difficult to Refactor
    • Considerable scenario for refactoring Duplicate Code Long Method Larger Class Long Parameter List
    • ConclusionRefactoring is the process of taking a running program andadding to its value, not by changing its behavior but by givingit more of these qualities that enable us to continuedeveloping at speed.