Browse by Tags

Thoughts on bit fields.
11 January 05 09:09 AM
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 Read More...
Postedby jaybaz_MS | 6 Comments    
Some good feedback on the Range post.
20 August 04 10:06 AM
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) Read More...
Postedby jaybaz_MS | 15 Comments    
Refactoring the XMLNotepad
20 July 04 03:14 PM
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 Read More...
Postedby jaybaz_MS | 9 Comments    
The hidden costs of a Refactoring
07 July 04 10:49 AM
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 Read More...
Refactoring Party
01 July 04 12:24 PM
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 Read More...
Postedby jaybaz_MS | 10 Comments    
No private methods
11 June 04 05:54 PM
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 Read More...
Postedby jaybaz_MS | 22 Comments    
enum->class Refactoring the OO way
31 May 04 10:18 AM
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 Read More...
Postedby jaybaz_MS | 7 Comments    
Generic Enum helper dud
31 May 04 10:14 AM
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 Read More...
Postedby jaybaz_MS | 0 Comments    
Refactor enum->class: Answer 1
31 May 04 10:07 AM
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 Read More...
Postedby jaybaz_MS | 0 Comments    
The new new lazy loader
07 May 04 04:02 PM
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 Read More...
Postedby jaybaz_MS | 15 Comments    
Cyrus likes Weak & Strong references
07 May 04 12:02 AM
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 Read More...
Postedby jaybaz_MS | 13 Comments    
The new LazyLoader
06 May 04 02:57 PM
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> Read More...
Postedby jaybaz_MS | 8 Comments    
Scott’s lazy loader
30 April 04 03:37 PM
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 Read More...
CCC2: InitializeComponent()
28 April 04 02:14 PM
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 Read More...

This Blog

Syndication

Page view tracker