Thoughts on bit fields.

In C there is a long tradition of using bit fields to store a collection of boolean values:       enum     {         TF_KEYWORD          = 0x0001,         TF_MEMBER           = 0x0002,         TF_IDENTIFIER       = 0x0004,         TF_STRINGLITERAL    = 0x0008,         TF_CHARACTERLITERAL = 0x0010,     } TOKENFLAGS;       DWORD dwTokenFlags = TF_KEYWORD | TF_MEMBER;  …

6

Refactoring the C# Express Starter Kit – Part 2: Organizing fields

Looking in RssView, I see a big mess.  There are lots of fields.  Some are related to each other & different from others, which suggest an Extract Class.    Some are set at initialization time, while others change over time.  Clearly there’s a difference there, but it’s not called out in the code.   All…

8

Some good feedback on the Range post.

Dithermaster says “it’s *much* easier to find out of they DON’T overlap” and proposes:    ! ( (end2 < start1) || (start2 > end1) ); If we apply DeMorgan’s Law, we get:    (! (end2 < start1) && !(start2 > end1) ); And    (end2 >= start1) && (start2 <= end1); Right?  Even simpler.  However, this idea disappears…

15

Refactoring the C# Express Starter Kit

Yesterday I decided to take a look at the code we shipping in the Beta 1 C# Express SKU for a screen saver.  I was pretty disappointed in the quality of the code, so I decided to refactor.    I’ve talked about some ideas about coding styles here on this blog, and I wanted to…

10

Making “Promote Local” make sense.

We’re sitting around watching a video from a usability study.    A subject has been exploring the Refactoring menu, and has just tried Promote Local.  With the help of the very specific error messages I wrote (yay exceptions), he finally gets it work.    On the audio track you hear him thinking out loud, describing…

8

Whidbey Refactorings: Signature Change

Almost 4 months after the first post in the series… not bad!   There are 3 Signature Change Refactorings: Remove Parameter Reorder Parameter Promote Local   I rank these as “Tier 2” – they’re not as important as Extract Method and Rename, but they’re still pretty hard to do by hand.  They also have some…

28

Answer Ron's questions about C# Refactorings.

On the Yahoo! Groups Refactoring DL, Ron Jeffries asked some questions about Visual C# 2005 Refactorings.    “Can you say how you expect the Microsoft refactorings to stack up against the existing ones that are out there?”   I’ve personally spent very little time exploring the C# and Java Refactoring tools out there.  Most of…

7

Refactoring the XMLNotepad

I’ve been reading Extreme Programming Adventures in C#.  Currently reading Chapter 28 (Undo).   Through most of the book, there has been a bit of Refactoring that the code has been crying out for.  At first I thought Ron was waiting to until the duplication got worse, thereby justifying the Refactoring as providing real customer…

9

The hidden costs of a Refactoring

Looking over our oldest C++ code, there is, of course, a lot of potential for Refactoring.  That’s a nice way of saying that it sucks.   We learned about Refactoring because we wanted to build good tools for our customers.  Along the way, we also realized that we wanted to Refactor, too.  One of the…

2

Refactoring Party

In What are my Goals?, Jim asked:   How do you plan to “Develop a culture of energy, productivity, and learning on the team”?   One of the activities I have in mind is a reoccurring Refactoring Party.  It works like this:   Each week we come together for an hour to practice Refactoring.  You…

10