Browse by Tags

All Tags » Wacky Ideas (RSS)

Contract classes and nested types within interfaces

I've just been going through some feedback for the draft copy of the second edition of C# in Depth. In the contracts section, I have an example like this: [ContractClass( typeof (ICaseConverterContracts))] public   interface ICaseConverter {...
Posted by skeet | 9 comment(s)
Filed under: , , ,

Iterating atomically

The IEnumerable<T> and IEnumerator<T> interfaces in .NET are interesting. They crop up an awful lot, but hardly anyone ever calls them directly - you almost always use a foreach loop to iterate over the collection. That hides all the calls...

An object lesson in blogging and accuracy; was: Efficient "vote counting" with LINQ to Objects - and the value of nothing

Well, this is embarrassing. Yesterday evening, I excitedly wrote a blog post about an interesting little idea for making a particular type of LINQ query (basically vote counting) efficient. It was an idea that had occurred to me a few months back, but...
Posted by skeet | 11 comment(s)
Filed under: , ,

Generic constraints for enums and delegates

As most readers probably know, C# prohibits generic type constraints from referring to System.Object, System.Enum, System.Array, System.Delegate and System.ValueType. In other words, this method declaration is illegal: public static T[]GetValues<T>...
Posted by skeet | 54 comment(s)

The "dream book" for C# and .NET

This morning I showed my hand a little on Twitter . I've had a dream for a long time about the ultimate C# book. It's a dream based on Effective Java , which is my favourite Java book, along with my experiences of writing C# in Depth. Effective...
Posted by skeet | 33 comment(s)
Filed under: , ,

Faking COM to fool the C# compiler

C# 4 has some great features to make programming against COM components bearable fun and exciting. In particular: PIA linking allows you to embed just the relevant bits of the Primary Interop Assembly into your own assembly, so the PIA isn't actually...
Posted by skeet | 1 comment(s)

A different approach to inappropriate defaults

I've had a couple of bug reports about my Protocol Buffers port - both nicely detailed, and one including a patch to fix it. (It's only due to my lack of timeliness in actually submitting the change that the second bug report occurred. Oops.)...
Posted by skeet | 9 comment(s)
Filed under: , ,

Go on, ask me anything

This afternoon, I found a comment which had been trapped in the spam bin for this blog. It was from Andrew Rimmer, in reply to my "micro-celebrity" post , pointing me at http://askjonskeet.com The world has officially become extremely silly...
Posted by skeet | 29 comment(s)

Breaking Liskov

Very recently, Barbara Liskov won the Turing award , which makes it a highly appropriate time to ponder when it's reasonable to ignore her most famous piece of work, the Liskov Substitution (or Substitutability) Principle . This is not idle speculation...
Posted by skeet | 32 comment(s)
Filed under: , ,

RFID: What I really want it for

This isn't really coding related, but it's technology related at least. There's been a lot of fuss made about how great or awful RFID is and will be in the future, in terms of usefuless and privacy invasion respectively. There's one use...
Posted by skeet | 9 comment(s)
Filed under: ,

Quick rant: why isn't there an Exception(string, params object[]) constructor?

This Stack Overflow question has reminded me of something I often wish existed in common exception constructors - an overload taking a format string and values. For instance, it would be really nice to be able to write: throw new IOException( "Expected...
Posted by skeet | 26 comment(s)

Horrible grotty hack: returning an anonymous type instance

One of the reasons I don't view anonymous types as being too bad is that they're nicely confined to methods. You can't declare the type that you're returning from a method if it's anonymous (or if one of its type arguments is generic...
Posted by skeet | 21 comment(s)
Filed under: ,

Value types and parameterless constructors

There have been a couple of questions on StackOverflow about value types and parameterless constructors: Structure vs Class in C# Why can’t I define a default constructor for a struct in .NET I learned quite a bit when answering both of these. When a...

Redesigning System.Object/java.lang.Object

I've had quite a few discussions with a colleague about some failures of Java and .NET. The issue we keep coming back to is the root of the inheritance tree. There's no doubt in my mind that having a tree with a single top-level class is a good...

Jaffa bugs

Currently I'm working on a problem found by one of our testers. Unfortunately, it's hard to reproduce. Inspired by the fact that yesterday our micro-kitchen had jaffa cakes in, I propose that if we're going to be frustrated by bugs like this...
Posted by skeet | 4 comment(s)
Filed under: ,

C# 4.0: dynamic<T> ?

I've not played with the VS2010 CTP much yet, and I've only looked briefly at the documentation and blogs about the new C# 4.0 dynamic type, but a thought occurred to me: why not have the option of making it generic as a way of saying "I...

I'm Sorry, I Haven't a Cluestick

Unless you've listened to I'm Sorry, I Haven't a Clue , the BBC Radio 4 "antidote to panel games" which was chaired by the recently departed (and much missed) Humphrey Lyttelton , this post may not make a lot of sense to you. That's...
Posted by skeet | 4 comment(s)
Filed under: ,

Mandelbrot revisited - benchmark edition

I've had fun with the Mandelbrot set in this blog before, using it as an example of an embarrassingly parallelisable problem and demonstrating Parallel LINQ with it. This morning, over breakfast, I described the problem to Christian Brunschen , a...
Posted by skeet | 11 comment(s)

Visualising the Mandelbrot set with LINQ - yet again

I've been thinking about ranges again, particularly after catching a book error just in time, and looking at Marc's generic complex type . It struck me that my previous attempts were all very well, and demonstrated parallelisation quite neatly...
Posted by skeet | 3 comment(s)

Boxing day

Here in the UK (and possibly elsewhere - I'm too lazy to check Wikipedia) December 26th is called Boxing Day. I want to know why only this one aspect of .NET is given its own public holiday. Expanding the opportunities to language features as well...
Posted by skeet | 5 comment(s)
Filed under: ,
More Posts Next page »