A Quirk in List.Find()
Earlier today I was having a chat with a friend of mine, who lives in Vancouver, about finding items that are stored in generic Lists. He flicked me a code snippet that looked something like this:
List<foo> list = new List</foo><foo>(); // .. do some stuff Foo f = list.Find(delegate(Foo f) { return foo.Name == "Bar"; }); </foo>
Straight away I fired back with an update to the code which used lambda expressions instead, as I'm a fan of how concise they are
Always Question the Source (aka “Don’t Lock on Type Objects”)
For one reason or another, I recently found myself perusing some code based on the CSLA framework. While nosing around I came upon a snippet of code that I found rather disturbing. An example can be found here in the function called InitializeAuthorizationRules.
For those who are lazy, here is the particular snippet of code that caught my eye:
WPF Shader FX on Codeplex
This is just a quick post to point out a new project that has fired up on Codeplex which may be of interest to a few of you graphics and rich client fans.
Joseph Cooney of LearnWPF.com (and WPF MVP to the stars) has kicked off a Codeplex project targetting funky shaders for use with the new features of WPF that were included in SP1. Specifically, it's intended to be a collection of open source/free shaders that can be easily plugged into your WPF apps to make them look schmick (for more info, check this out).
It's an open source/community thing where everyone is encouraged to contribute. I'll be aiming to add as much as I can given the time constraints of work and family life. JC has already added 5 effects, and I've added my first, which was a simple Radial Blur shader.
This stuff really is fun, so check it out!
.NET-fu: Signing an Unsigned Assembly (without Delay Signing)
This article is also available in: Italian
The code-base that I am currently working with consists of a large set of binaries that are all signed. The savvy .NET devs out there will know that any assembly that's used/referenced by a signed assembly must also be signed.
This is an issue when dealing with third-party libraries that are not signed. Sometimes you'll be lucky enough to be dealing with vendor that is happy to provide a set of signed assemblies, other times you won't. If your scenario fits the latter (as a recent one did for my colleagues and I), you need to sign the assemblies yourself. Here's how.
Screencast – Setting up Unity Builds
It has taken me a bit longer than expected, but I've finally got the screencast up!
That's right folks, my angelic voice is now online for you all to experience. 8 minutes of Unity Build glory!
How do you Interact with your ViewState?
There comes a time in every ASP.NET developer's life when the need arises for information to be persisted into ViewState. For the sake of this post I'm not really interested in the reasons why. What I am interested in is how.
How do you interact with your ViewState?
The Magic of Unity Builds
I realise that as time goes by, people are using my beloved C++ less and less. .NET (C# and VB.NET) and Java seem to be taking over the mainstream coding world. Languages such as Ruby and Python seem to be taking over the scripting world. For the most part, C and C++ seem to exist only in the gaming/entertainment, real-time and driver worlds.
In many colleges and univerties C++ is no longer taught as a core subject (along with Assembly language) which I find quite galling. It's a great language to learn, even if you never use it again. But the purpose of this post is not to preach the virtues and failures of the C++ language, but instead to talk about something that might aid those people who are using C++.
WTF: Random Memory Contents
If any of you out there are able to give me ONE GOOD REASON why anyone would do something like this, then please let me know. Below are "customised" realloc() and malloc() I recently stumbled across (yes, they get called. A LOT):
void *mcRealloc( void *P, int SIZE ) { int oldSize = _msize( P ); P = realloc( P, SIZE ); if ( P ) { for ( int i = oldSize; i < SIZE; i++ ) { ((char *) P)[i] = (char) rand(); } } return P; } void *mcMalloc( int SIZE ) { void *P; P = malloc( SIZE ); if ( P ) { for ( int i = 0; i < SIZE; i++ ) { ((char *) P)[i] = (char) rand(); } } return P; }
Is it just me, or is this a huge WTF?
Safer Code through Object-Orientation
In my current position I spend a lot of time battling against a fairly poorly-written C++ code base. The code, while technically written in C++, is actually more of a C-like "splat" with a few classes thrown in. Since I began working on this project I've seen many cases where proper object-orientation would have made a drastic improvement to the quality of the code.
And it's these cases which are the inspiration for this blog post.
Creating Concrete Objects
Being a fan of OOP, I tend to write a lot of object-oriented code. Coming up with a meaningful object model that behaves in an appropriate way is just as important as having a meaningful interface to your objects. A concrete object is an object that actually behaves in the manner you'd expect without any wierd side-effects, and has the same kind of attributes that you'd expect of a primitive data type.
Creating concrete data objects/classes is a good thing to do, as it reduces the probability of bugs, and crazy side-effects. It's also an important first step in writing intuitive code - which will be the topic of a later blog post.