Archive for the ‘.NET’ Category

Amusing Bad Programming Tip

Say you have a class with a property that’s a string. Using object initializers you can do this little nugget:

Product p = new Product { ProductName = Console.ReadLine() };

It will work as you’d expect (prompt you for input, then assign it to ProductName). However, that’s pretty easy to miss when you’re quickly scanning code. [...]


ASP.NET MVC and Rendering both HTML and JavaScript

In the project I am currently working on, we are using JavaScript and jQuery in just about everything. One of the frustrations that I have been seeing is that I’ll render a view representing an object, but also want a JSON version of that object to manipulate. I am also quite anal when it comes [...]


Different Action Results with ASP.NET MVC and jQuery

I’m a big fan of the ASP.NET MVC framework. I love the fine grained control it gives you over everything. But what I love most is that you can unleash the fully armed and operational firepower of jQuery.
Recently, I’ve been working on a site that is using both MVC and jQuery to make AJAX calls. [...]


LINQ To SQL and Tight Coupling Part 4

I kind of left my last post on this subject dangling, but now I’m ready to come clean.  I was proceeding merrily along, removing the tightly coupled LINQ to SQL generated code into something nice and loose, but ran into some serious snags when trying to update the database objects that had joins associated with [...]


Delegation Part 2

Back in Part 1, we covered the history of Delegates in the .NET Framework. As stated, in 1.1, they were a little too confined to be exceptionally useful. However, in the 2.0 Framework, Delegates were given the ability to be "Anonymous" and could be created on the fly. This allows for more elegant coding, and [...]


Delegation Part 3

Delegates have come a long way since they were introduced in .NET 1.0. Back then they were only a way to refer to existing methods as variables. 2.0 allowed methods to be inlined, making them "anonymous." The 3.5 Framework does not introduce any new concepts regarding delegates, but it makes writing them much, much quicker [...]


Delegation

Delegates are a big part of the .NET Framework. They were included since the beginning with .NET 1.0 and have matured since then, but in my experience I don’t see them used intentionally too often.
I think the reason for this is because the concept of a delegate is kind of foreign if you have a [...]


LINQ To SQL and Tight Coupling Part 3

Last time, we tweaked our code to make it a little easier to understand and maintain. So that means we get to dirty it up again!  Our current object model has very simple mapping of one table to one class, with no associations between them. In the real world, this doesn’t happen too often (and [...]