June 2004 - Posts

[Articles] Brad Abrams: The Bum Rap of foreach
30 June 04 01:42 PM | CSharpener | with no comments

Recursively follow all of the links in Brad Abrams article The Bum Rap of foreach and you will get a great education in both iteration and the evils and joys of micro-optimization. Regarding optimization, see "Rule #1" in The Rules of Optimization.

Filed under:
[.NET - CSharp] Nice Little String Rotator
29 June 04 10:24 AM | CSharpener | with no comments

These string rotator methods appeared in a chain of recent posts on the DOTNET-CLR list. I recorded them here because they may prove useful.

A substring approach:

    public static string RotateLeftSubstring
            (string s, int start, int length, int amount)
    {
        // Allow amount to be negative (as far as -length)
        amount = (length+amount) % length;

        return 
            s.Substring(0, start)+ 
            s.Substring(start + amount, length-amount) + 
            s.Substring(start, amount) + 
            s.Substring(start + length, s.Length - (start+length) );
    }

A StringBuilder approach:

    public static string Rotate(string s, int start, int length, int amount) {
       StringBuilder sb = new StringBuilder(s);
       for (int i = 0; i < length; ++i) {
           sb[start + i] = s[start + ((i + amount) % length + length) % length];
       }
       return sb.ToString();
    }

Filed under:
[SoftDev] Bit Rotation
25 June 04 01:55 PM | CSharpener | with no comments
This article on Bit Rotation for Byte, Short and Int Variables in Java could easily be adapted to C#.
[Tools] Free Metrics Tools
24 June 04 10:28 AM | CSharpener | 3 comment(s)

I just tried out two new free tools that provide metrics for .NET projects and recommend both of them to anyone who wants a better picture of their .NET code. The tools are:

* NDepend
* devMetrics

Both tools are relatively easy to use and they quickly produce a wealth of information about your assemblies.

A commentor just reminded me that I should also point to the Code analysis - Standards verifiers category at Madgeek's SharpToolbox site. That category lists quite a number of metrics tools.

Filed under:
[Languages] New home for Lambda the Ultimate
23 June 04 12:08 PM | CSharpener | with no comments
Lambda the Ultimate has a new home.
Filed under:
[.NET - CSharp] DCOM server in C#
21 June 04 03:20 PM | CSharpener | with no comments
Worthy of note is this post on How to write a DCOM server in C#.
Filed under:
[SoftDev] Internationalization Karma
15 June 04 02:03 PM | CSharpener | with no comments
Now I have a karmic obligation to link to Iñtërnâtiônàlizætiøn, Scott Hanselman's recent weblog post containing some good links to internationalization resources. There! My karma feels at least a little bit better!
Filed under:
[.NET - CSharp] C# Bit Reversal
15 June 04 10:09 AM | CSharpener | with no comments
I just posted a new short article on how to Use C# to Reverse the Bits in a System.Byte There are many ways to accomplish bit reversal, and this one is not the most efficient, but my NUnit tests tell me that it works. If you have a better way, please feel free to comment!
Filed under:
[.NET - CSharp] Speaking of Singleton
10 June 04 02:40 PM | CSharpener | with no comments

Speaking of using the Singleton pattern in C#, have a look at Design Patterns potential hazards on Fabrice's weblog and follow the links to the articles he recommends. Also, have a gander at .Net singleton pattern multi-threading issue... by Chris Johnson. An old friend (and ex co-worker) just sent me another great link to an IBM Developer Works article with advice on how to Use your singletons wisely. MSDN has Implementing Singleton in C#, as pointed out by Luciano Evaristo Guerche who was recently cited by Scott Watermasysk. A comment in Luciano's post also points to Implementing the Singleton Pattern in C#.

Gee, I guess that's enough cross-posting about the Singleton for now! These articles contain a lot of information on something that seems so simple on the calm surface but has monsters lurking in the depths.

All in all, design patterns are great but you need to use them intelligently and with attention to your intended purpose. Perhaps you do not need to worry about threading issues; perhaps you do. The main thing is to ask the right questions when you do the design.

Filed under:
[Languages] Twist of Fate: a C-Compiler in Python
10 June 04 10:56 AM | CSharpener | with no comments
Now this is an interesting twist: Atul's Mini-C Compiler is a C-compiler written in Python. I would make the appropriate allusions to Ouroboros, the snake that eats its own tail, but, as every software professional should know, those allusions would be quite inappropriate because Python was named after "Monty Python," not any variety of snake (see "1.16 Why is it called Python?" from the General Python FAQ).
Filed under:
More Posts Next page »

This Blog

.NET Languages

Architecture

Blogs I Read

CSharp

DotNet

General

Graphics

Other Languages

Semantic Web

The Human Factor

Tools

Unology

XML

ZZZ-Subscribe to this Weblog

Syndication