Browse by Tags

All Tags » C# (RSS)

Unit testing WCF data contract serialization.

WCF service define "data contracts" for their interfaces. These contracts are often defined in an XML schema document and used to generated WCF data contract code. This process effectively creates a .NET type that will serialize to a chunk of...
Posted by PeterRitchie | 1 comment(s)
Filed under: ,

DataContractSerializer.ReadObject is easily confused.

With WCF services you need to declare contracts and generate contract classes that encapsulate those contracts.  Most of the time you can simply let the framework deal with whatever it needs to do to deal with these objects.  Sometimes, you...
Posted by PeterRitchie | 1 comment(s)
Filed under: , ,

Evolving code over time

Given economics, time constraints, resource limitations, etc.; you can't write all the functionality for a given solution for a single release. Even if you weren't limited by these constraints, you're likely to get changing requirements as...

DevTeach 2009 Vancouver

The schedule for DevTeach 2009 Vancouver has been announced ( http://www.devteach.com/ ). There’s lots of great software development sessions from some of the leaders in our industry. If you’re planning on improving yourself, this is the conference...

Pass-through Constructors

Pass-through constructors is a term I use to describe parameterized constructors that have none of their own logic and simply pass parameters to the base class. For example: public class BaseClass { private String text; public BaseClass( String text)...

Pontificating Virtual Parameterized Constructors in C#

Tom Hollander recently posted about a change he required to the Enterprise Library for date/time validation. He had to create a new class (rather than modify the Enterprise Library) that derived from another, defective class. One of his complaints was...

.NET 4.0, Evolving .NET Development

.NET 4.0 is the first release of .NET since 2.0 that evolves .NET for every programmer. .NET 3.0 was largely LINQ and .NET 3.5 was largely new namespaces (like WCF, WWF, etc.) .NET 4.0 evolves the programming and design for any programmer. It offers framework...

Becoming a Visual Studio Jedi Part 1

Becoming a Visual Studio 2008 (and often Visual Studio 2005) Jedi In much the same grain as James' Resharper Jedi posts, I'm beginning a series of posts on becoming a Visual Studio Jedi. It involves getting the most out of Visual Studio off-the...

Trials and Tribulations of DataGridView, Column Selections, and Sorting

I had to implement some custom sorting in a DataGridView recently. Essentially, the stakeholders wanted full column selection (like Excel) while still having the ability to sort the data based on a particular column. This particular DataGridView is data...

DataGridViewColumn.Frozen

DataGridViewColumn.Frozen is documented as "When a column is frozen, all the columns to its left (or to its right in right-to-left languages) are frozen as well." Which is nice until you think of the consequences. The consequences being that...

ITSWITCH #1: Answer

Last post I detailed some code that may or may not have something wrong in it.  If you thought InitializeOne and IntializeTwo are semantically identical (e.g. they differ only by performance), you'd be wrong. If you simply ran the code, you'd...

ITSWITCH: #1

A short pop quiz on design/coding in C#...

Nested Types

Recently Michael Features blogged about nested types . The title was almost "nested types considered harmful". I don't agree. I don't agree that they're any more harmful than any other C# construct (except goto...). Nested types...

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...
More Posts Next page »