Browse by Tags

All Tags » C# (RSS)

Comparing CodeRush Refactor! Pro and Resharper 4, part 1 or N -- first glance.

Metadata view of code in referenced assemblies This is a big one for me. For whatever reason, Refactor 4 (and prior) completely disables this and sends you to the Object Browser instead. You get metadata view with CodeRush Refactor! Pro. Keyboard layout...

Entity Framework Petition of Vote of Non Confidence

I had intended to be happy simply being a signatory of ADO .NET Entity Framework Vote of No Confidence. But, there's people suggesting signatories of this petition are wackos or on the fringe. Do yourself a favour and read the petition . Read what...

Fundamentals of OOD Part 3: Method Cohesion

Single Responsibility Principle (SRP) helps us write more cohesive types and methods. Cohesion is the relatedness of the members of a type to each other and the relatedness parts of a method's code to other parts. Method cohesion Often times a method...

Spaces or Tabs?

In this day and age it seems silly to get into a discussion about whether your companies coding guidelines should have a section mandating either spaces or tabs for indents. Tabs are clearly more flexible, but I really don't think it matters at all;...

RFC: Conditionals on false

Just a small request for comments. Oren prefers if (GetTrueOrFalse() == false ) ...instead of if (!GetTrueOrFalse()) Coming from 18+ years of C/C++ based language programming, I find either equally readable; but, I'm not always the one reading my...
Posted by PeterRitchie | 11 comment(s)
Filed under: ,

Fundamentals of OOD, Part 2 - Encapsulation Scope

Let's look at the ubiquitous Person concept. It might seem logical that an application that deals with people should have a Person interface for classes to implement. For example: public interface IPerson { String GivenName { get; set; } String SurName...

Fundamentals of Object-Oriented Design (OOD) Part 1

With increased usage of patterns and situationally specific strategies, people sometimes lose sight of the concepts and principles behind these patterns and strategies and fail to follow them when they're not using patterns or strategies. I feel it's...

Overcoming problems with MethodInfo.Invoke of methods with by-reference value type arguments

I ran into an interesting problem on the Forums recently. Basically, when you use MethodInfo.Invoke to invoke a method with by-reference value type arguments you can't have the invoked method update a variable/argument. The problem is, when you invoke...

Resharper Isn't Always Smart

I was writing some code today, essentially like this: public class MyClass { private int value; public MyClass( int value) { this .value = value; } public static bool operator ==( MyClass left, MyClass right) { return left.value == right.value; } public...
Posted by PeterRitchie | 11 comment(s)
Filed under: , ,

Licences for Microsoft products

Occasionally I get development questions that are governed by one or more product licenses (End-User License Agreement, "EULA"). One question that I see is "I've used Reflector to decompile the .NET Framework and want to use that C#...
Posted by PeterRitchie | 7 comment(s)
Filed under: ,

Single-Entry, Single-Exit, Should It Still Be Applicable In Object-oriented Languages?

Before the modern high-level languages Edsger Dijkstra came up with "Structured Programming". This programming methodology relied on the programmer to form and enforce most of the structure of the program--manually keeping sub-structures and...

My Wishlist for C# 4

[Edit: fixed the not-ready-for-publication problems] There seems to be more than few people blogging about what they hope C# 4 will do for them. I haven't seen one that really synchronizes with my thoughts, so I'd thought I'd post my own list...
Posted by PeterRitchie | 4 comment(s)
Filed under: , ,

A Time and Place for Code Comments

I've dealt with more than one person who believes all code comments are bad. The first person I encountered who said that also asked me to explain why a particular algorithm was used instead of another because there were no comments explaining it...

"Object is currently in use elsewhere" error.

I was debugging what I thought was a strange exception the other day. The exception was an InvalidOperationException and the message was "Object is currently in use elsewhere". Unless you're familiar with this exception, it really doesn't...

Formatting/parsing for a specific culture redux

In recent blog post I detailed how creating a culture via the CultureInfo constructor could actually create a user-overridden culture--which could be completely different than the culture that you've requested by name. Fortunately there's a way...

Visual C# Developer Center Article

My latest Visual C# Developer Center Article Inferred Typing with Factory Methods as Extension Methods is now online.
Posted by PeterRitchie | with no comments

Formatting/parsing for a specific culture

Sometimes you may want to use a specific format for formatting and parsing of textual data. The easiest way to do this is to select a specific culture and use that with formatting and parsing methods. Unfortunately, the CultureInfo constructor that just...

Bridges and Factories

In my previous post , I talked about Dependency Injection (DI). One implementation of DI is using interface-oriented design to abstract a class from an injected dependency via an interface. This is one possible implementation of the Bridge pattern. Depending...

Dependency Injection

Dependency injection (DI) is a form of inversion of control. There seems to be a tendency in some circles to refer to dependency injection as inversion of control (IoC). Dependency injection is a form of abstraction by removing physical dependencies between...

New warning CS0809 in C# 3 (Visual Studio 2008)

There were several breaking changes (fixes) in C# 3 from C# 2. One is the ability to attribute a member override with ObsoleteAttribute without also attributing it the virtual member in the base class. For example, the following will compile without error...
More Posts Next page »