jaybaz [MS] WebLog

We believe in nothing.

Browse by Tags

Tagged Content List
  • Blog Post: 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; This tradition has been...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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 explore some of those ideas in...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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....
  • Blog Post: Language Readability vs. Writability

    In my previous post , I said: “Unfortunately, language readability is often at odds with writability.” And “Generic method type parameters are inferred from the concrete parameters” Here’s what I’m talking about: T F<T>(T t) { return...
  • Blog Post: Language design for Refactoring

    A question came up on the Yahoo! Groups Refactoring Group about what language design would be best to support Refactoring. We think about this quite a bit, but usually we phrase the question more generally: What language design would make it easiest to write tools that work well? That...
  • Blog Post: No private methods

    I’m heading off into the deep end here. If you want to come with me, make sure you’re wearing your SCUBA gear. One of the first questions that come up in TDD with NUnit is “ How do I test private methods?” Usually the answer looks like “Don’t do that, because...
  • Blog Post: Your expectations of Refactoring.

    Your expectations of Refactoring. Cyrus posts about what you expect from Refactoring. The particular issue he’s dealing with is Extract Method when the result will pass a generic argument to a method. He offers these three choices: Don’t add ‘ref’, potentially changing...
  • Blog Post: enum->class Refactoring the OO way

    This one was pretty much TheoY’s. I coded it up, which probably means I corrupted his idea. So, give him credit for the good parts and I’ll take balme for the bad parts. Pretty much the same approach was taken in C++ by Johny in his comment . abstract class E { private...
  • Blog Post: Generic Enum helper dud

    I hoped I could write a generic helper class that you could use when Refactoring your enum to a class. I wrote this: class EnhancedEnum <T> where T : struct { public readonly T Value; public EnhancedEnum (T value) { this .Value = value; } public static implicit operator...
  • Blog Post: Refactor enum->class: Answer 1

    This is the follow up to the enum->class refactoring post . So, one approach is to try to decode what ‘enum’ does in C#. Thomas Eyre’s answer is pretty much the same, with a couple differences: · Thomas wrote his TDD, and delivered it with tests. Good for you! ·...
  • Blog Post: Refactor enum->class

    Every so often, I see a C# user say they’d like to add a method to an enum. Maybe it’s [Flags] and they want to verify that the combination of flags is legal according to their business rules. Or maybe they’re in the process of moving to something more OO, involving inheritance instead...
  • Blog Post: Cleaning up 'using' directives

    A suggestion arrived in email, and here is my response. (None of this is on the feature list for Whidbey, it’s just ideas.) 1. Fully qualify (all names / all names in namespace X / all instances of type Y / the instance under my cursor), removing a using directive if possible. 1a. Add...
  • Blog Post: The new new lazy loader

    Cyrus then incorporated the Weak/Strong reference stuff into the LazyLoader. He also refactored the factory to give you a reliable, predictable default & be a bit simpler. (You also need Optional<> and the Lock<> code.) First, the delegate definition: delegate A Creator...
  • Blog Post: Cyrus likes Weak & Strong references

    Then Cyrus decided he wanted to support weak references. A weak reference is one that the GC can decide to release if there are no other references to it. For our LazyLoader, that would mean that you create the item when demand appears, and it may go away if it’s not needed, and then it’ll...
  • Blog Post: The new LazyLoader

    Finally, the LazyLoader class. Credit goes to Kevin & Cyrus (who doesn't have a blog). delegate T Creator <T>(); class LazyLoader <T> { IOptional <T> value = new None <T>(); readonly ILock @lock; readonly Creator <T> create; public LazyLoader...
  • Blog Post: Scott’s lazy loader

    Scott Wisniewski posted a lazy loader implementation on his blog. He coded it blind, without the help of a compiler that could do C# generics. I went back through and made it legal C# code. I also did a little refactoring. The ILazyLoader is now nested in the LazyLoad<T> class, which means...
  • Blog Post: CCC2: InitializeComponent()

    Call it a Clearest Code Challenge: What should InitializeComponent() look like? What’s the best code you can imagine, that the WinForms designer should generate? Let’s take a simple, concrete case: a form with an OK button. The button is anchored at the bottom right. Let’s...
  • Blog Post: Whidbey Refactorings: Rename

    Let's start by talking about Rename. I view Rename as being one of the “Tier 1” refactorings – the refactoring we absolutely must provide, and which must be of the highest quality. They must be fast, reliable, and easy to use. You’re going to use them often, and we want you to...
Page 1 of 1 (25 items)