Contents

46 Articles
6 Comments

Search

8 years Ago

Building pseudo-DSLs with C# 3.5

Published by Marco on

This article originally appeared on earthli News and has been cross-posted here.


DSL is a buzzword that’s been around for a while and it stands for [D]omain-[S]pecific [L]anguage. That is, some tasks or “domains” are better described with their own language rather than using the same language for everything. This gives a name to what is actually already a standard practice: every time a program assumes a particular format for an input string (e.g. CSV or configuration files), it is using a... [More]

Designing a small API: Bit manipulation in C#

Published by Marco on

This article originally appeared on earthli News and has been cross-posted here.


A usable API doesn’t usually spring forth in its entirety on the first try. A good, usable API generally arises iteratively, improving over time. Naturally, when using words like good and usable, I’m obliged to define what exactly I mean by that. Here are the guidelines I use when designing an API, in decreasing order of importance:

Static typing & Compile-time Errors
Wherever possible, make the compiler stop... [More]

Waiting for C# 4.0: A casting problem in C# 3.5

Published by Marco on

This article originally appeared on earthli News and has been cross-posted here.


C# 3.5 has a limitation where generic classes don’t necessarily conform to each other in the way that one would expect. This problem manifests itself classically in the following way:

class A { }
class B : A { }
class C : A { }

class Program
{
  void ProcessListOfA(IList<A> list) { }
  void ProcessListOfB(IList<B> list) { }
  void ProcessSequenceOfA(IEnumerable<A> sequence) { }
  void... [More]

Creating fluent interfaces with inheritance in C#

Published by Marco on

This article originally appeared on earthli News and has been cross-posted here.


Fluent interfaces—or “method chaining” as it’s also called—provide an elegant API for configuring objects. For example, the Quino query API provides methods to restrict (Where or WhereEquals), order (OrderBy), join (Join) and project (Select) data. The first version of this API was very traditional and applications typically contained code like the following:

var query = new Query(Person.Metadata);... [More]

Pre-generating Entity Framework (EF) Views

Published by Marco on

These instructions apply to the 1.x release of EF and its designer integration into Visual Studio 2008.

Overview

The Entity Framework requires what it calls “views” in order to access a database. EF generates these views automatically if they are not available. In order to avoid generating these views at application startup, they can be pre-generated and stored as C# code.

A post-build step in the compilation process would be the ideal place for this, but there’s a snag: the view generator... [More]

Microsoft Code Contracts: Not with a Ten-foot Pole

Published by Marco on

This article originally appeared on earthli News and has been cross-posted here. In the meantime, a lot has changed and the major complaint—a lack of explicit contracts in C#—will finally be addressed in the next version of C#, 4.0.


After what seems like an eternity, a mainstream programming language will finally dip its toe in the Design-by-contract (DBC) pool. DBC is a domain amply covered in one less well-known language called Eiffel (see ISE Eiffel Goes Open-Source for a good... [More]

An analysis of C# language design

Published by Marco on

This article originally appeared on earthli News in 2004 and has been cross-posted here. In the meantime, a lot has changed and the major complaint—a lack of explicit contracts in C#—will finally be addressed in the next version of C#, 4.0.


A Conversation with Anders Hejlsberg (Artima.com) is a four-part series on the ideas that drove the design of C#. (The link is to the first page of the first section; browse to Artima.com Interviews to see a list of all the sections.)

Virtual vs. Static

I found... [More]

Remote Debugging with [ASP].NET

Published by Marco on

When a .NET application exhibits behavior on a remote server that cannot be reproduced locally, you’ll need to debug application directly on the server. The following article includes specific instructions for debugging ASP.NET applications, but applies just as well to standalone executables.

Prerequisites

There are several prerequisites for remote debugging; don’t even bother trying until you have all of the items on the following list squared away or the Remote Debugger will just chortle at... [More]

The Dark Side of Entity Framework: Mapping Enumerated Associations

Published by Marco on

At Encodo, we’re using the Microsoft Entity Framework (EF) to map objects to the database. EF treats everything—and I mean everything—as an object; the foreign key fields by which objects are related aren’t even exposed in the generated code. But I’m getting ahead of myself a bit. We wanted to figure out the most elegant way of mapping what we are going to call enumerated associations in EF. These are associations from a source table to a target table where the target table is a lookup... [More]

Elegant Code vs.(?) Clean Code

Published by Marco on

A developer on the Microsoft C# compiler team recently made a post asking readers to post their solutions to a programming exercise in Comma Quibbling by Eric Lippert (Fabulous Adventures in Coding). The requirements are as follows:

  1. If the sequence is empty then the resulting string is “{}”.
  2. If the sequence is a single item “ABC” then the resulting string is “{ABC}”.
  3. If the sequence is the two item sequence “ABC”, “DEF” then the resulting string is “{ABC and DEF}”.
  4. If the sequence has more than two items, say, “ABC”, “DEF”, “G”, “H” then... [More]

Encodo’s Development Environment

Published by Marco on

For the software developers in our audience, we’ve put together a list of the most essential .Net-tools that we use daily and without which we wouldn’t want to have to work.

Visual Studio 2008

Many months ago, we moved our entire .Net development to Visual Studio 2008. VS2008 supports .Net 2.0, 3.0 and 3.5 proejcts, which made the transition both quick and easy. Given the choice, we use .Net 3.5.1 as we’ve grown quite attached to the new language features like Linq, lambda-expressions and so... [More]

Encodo Entwicklungsumgebung

Published by Marc on

Für die Software-Entwickler unter den Lesern haben wir in diesem Artikel die wichtigsten .Net-Tools zusammen getragen, mit welchen wir täglich arbeiten und welche uns “ans Herz” gewachsen sind.

Visual Studio 2008

Unsere gesamte .Net-Entwicklung haben wir seit einigen Monaten auf Visual Studio 2008 (VS2008) umgestellt. Mit VS2008 können wir sowohl .Net 2.0, 3.0 und 3.5 Projekte realisieren, was die Umstellung sehr vereinfachte und beschleunigte. Wenn wir wählen können, verwenden wir .Net... [More]

Entity Framework: Be Prepared

Published by Marco on

In August of 2008, Microsoft released the first service pack (SP1) for Visual Studio 2008. It included the first version (1.0) of Microsoft’s generalized ORM, the Entity Framework. We at Encodo were quite interested as we’ve had a lot of experience with ORMs, having worked on several of them over the years. The first was a framework written in Delphi Pascal that included a sophisticated ORM with support for multiple back-ends (Sql Server, SQLAnywhere and others). In between, we used Hibernate... [More]

9 years Ago

ASP.Net DataBinding und Templates

Published by Marc on

Ab ASP.Net 2.0 gibt es in einigen Server-Controls sog. Templates. Mittels Templates können Teile des Inhaltes von Server-Controls definiert werden, welche vom Server-Control nach Bedarf eingesetzten werden. Beispielsweise definiert man in einer DataList den HTML-Code für ein einzelnes Item bzw. Datensatz. Das Server-Control verwendet dieses Template dann zur Laufzeit um die einzelnen Zeilen der Liste als HTML zu rendern.

Die praktische Verwendung von Templates ist nicht immer problemlos oder... [More]

Encodo C# Handbook

Published by root on

 Download

The first publicly available version of the Encodo C# Handbook is ready for download! It covers many aspects of programming with C#, from naming, structural and formatting conventions to best practices for using existing and developing new code.

Here’s the backstory on how and why we decided to write a formal coding handbook.

Here at Encodo, we started working with C# less than a year ago. We decided early on that we would be building a framework on which we would base our projects,... [More]