DCSIMG
Refactoring - Uri Lavi

Browse by Tags

All Tags » Refactoring (RSS)

Software Craftsmanship - Meeting 6

Chronicles of the 6th Software Craftsmanship (SCIL) meetup. This time, we discussed and practiced my own very beloved technique - called Refactoring . During the session Itay Maman demonstrated a real life project that he needed to refactor for his company. On the first part of our meeting, Itay refactored a very lengthy method in the CustomAction class, called actionPerformed. Here is the initial code of that method. You can watch the session here , where Itay demonstrated his approach and the refactoring...

Code Smells

If you like practicing in identifying code smells, then you can find below a short class called TimerManager . public class TimerManager { public delegate void TimerCallback ( object data); private static readonly object _sync = new object (); private readonly Dictionary < int , Timer > timers = new Dictionary < int , Timer >(); private readonly Dictionary < int , TimerCallback > callbacks = new Dictionary < int , TimerCallback >(); public void SetTimeout( TimerCallback timerCallback...

Software Craftsmanship - Meeting 4

Boy, I had so much fun during our 4th meeting... There were more than 80 people, deeply concerned about our profession and eager to learn best patterns & practices. In the first part we had 3 lectures: Code Reviews (Tools & Processes) - Ran Tavory , Structure 101 - Eran Harel and Legacy Code & Unit Tests - Uri Lavi. In the second part Aviv Ben-Yosef & Yoni Tsafir demonstrated pair programming (Randori Style) while solving the Bowling Kata exercise. Watching this great audience was...

Short Roman Numeral Kata

For our second Software Craftsmanship Coding Dojo , I have prepared a "Short Roman Numeral" Kata. In essence, a Short Roman Numeral is a number between 0 to 3999 that has a ToString() method which returns its roman presentation. The rules of roman presentation construction can be found here . After the meeting, I took some time in order to record the Code Kata. As you probably know it is extremely difficult to produce a well synchronized recording . Hence, after a few sleepless nights I...

Writing Readable Code - Complex Object Construction

Once upon a time, there was a class called Invoice. Its responsibility was to calculate a final price being presented to the customer. Time went on; The autumn passed, the winter fade out and the spring was already at the door and our class started to rust . Each time a developer found a new set of relevant parameters (that should have been passed to the Invoice class) he added a new constructor, to support them. And so it happened, that after a while, two fellows stumbled on the class: "What's...

Refactoring Tools Review - part II

Oh, my God! I am definitely in love! I finally had the time to play with the latest DevExpress 's Refactor ! Pro and Code Rush . Two distinct main features capture my eyes immediately: The ability to highlight the changes/code smells and refactorings inside the Visual Studio's Editor . It seems that the team invested a lot of effort in order to enable painting on the Visual Studio's editor and canvas. This enables a smooth user experience, without prompting and stalling with unnecessary...
Posted by Uri Lavi | 4 comment(s)
תגים:, ,

Prime Factors Kata

One of the key aspects of a Software Craftsmanship is constant practice. Kata (from Martial Arts) is one form of such practice. The notion of a Code Kata was first introduced by Dave Thomas and can be viewed as: Practice of the same methods, solutions and activities to a perfection. Practice of the same problem, tackling it each time from a different angle or with a different solution. Solving a known problem multiple times utilizing the same methods, enhances the understanding of the specific steps;...

Experts Days - 2009

This week we concluded the Experts Days . The sessions were effectively organized (by Eyal Vardi from E4D ), the audience was amazing and the atmosphere was energizing . Here are the headlines of my sessions: I. What's new in .NET 4.0 and VS 2010: The main focus was to emphasize the most important (in my opinion) upcoming features. Here they are: Task Parallel Library, PLINQ and Coordination Data Structures Code Contracts Reaction (Rx) Framework Managed Extensibility Framework (MEF) Dynamic Language...
Posted by Uri Lavi | with no comments

Refactoring Tools Review - Part I

Don Roberts and John Brant stated in the book Refactoring - Improving the Design of Existing Code : "Refactoring with automated tool support feels different from manual refactoring". Indeed - It is! Having an automated tool that helps you to change the code without the fear of breaking it - is invaluable. That's why, I wanted to summarize several available options for .NET developers. Let's start with the obvious one: Visual Studio Refactoring Tool. As usual Microsoft concentrates...
Posted by Uri Lavi | 4 comment(s)
תגים:, ,

Refactoring & Design Podcast

Here is a short podcast I participated in; the subject is Refactoring & Design. Many thanks to Ran & Ori !!!

Separate Domain from Presentation – part III

This is a third post in the series of posts about “Separate Domain from Presentation” Refactoring. Previous Posts: Separate Domain from Presentation – part I Separate Domain from Presentation – part II Last time we explained how to refactor towards MVP – Supervising Controller pattern. We left our project in the following state: In this post I will complete the required refactoring steps and will suggest more steps to even deepen the separation of UI and BL concerns. Refactoring Steps: " Extract...

Var{i-able;}

Here is a scoop; The good software engineer is lazy! You don’t believe me? Then ask yourself this: If a good software engineer was not lazy why would he: Automate processes? Reuse a function instead of duplicating its code? Explicitly name a function for its behavior instead of naming a function F1 and providing a non descriptive (and possibly long) documentation? Yet, here is another scoop; The bad software engineer is lazy too! While this statement clearly isn’t a shock to you, it immediately pop...

Separate Domain from Presentation – part II

This is a second post in the series of posts about “Separate Domain from Presentation” Refactoring. Previous Posts: Separate Domain from Presentation – part I Last time we discussed the ways to disconnect the Presentation (FrmMain) from the Domain Object (CoursesDS) in the IRefactor.CoursesView project. As a consequence, instead of the bloated all-in-one initial project we ended with the following: IRefactor.CoursesView – represents the View (CoursesView) without the domain object. IRefactor.Common...

Separate Domain from Presentation – Part I

Visual Studio can be a swiss knife in the hands of a Software Developer. You want a fully functional application within several hours; here you go sir: Create Windows Forms Application. Add relevant Data Sources (in Figure 1 below: Courses table). Drag generated entities from the Data Sources onto relevant Forms. Add minimum code to show the Forms in the required order Compile & execute Walla, I present you an “enterprise application”! Though it looks amateur, it allows fully functional CRUD...