Posts

Showing posts with the label C#

Talking to a Kamstrup 685-382 electricity meter

Image
My utility company provides me with ways to see historic consumption of electricity up to a few days ago. However, by that time I have long forgotten when, what and why I did to consume as I did. In order to save power and money on the utility bill, one needs to have some way of monitoring and discovering usage patterns *immediately* as they take place! When I saw you could buy cheap US$50 used industrial strength electricity meters in the form of the Kamstrup 685-382, I decided to buy a few of those. The idea was to have it installed as a secondary meter in my house and try to hook up some sort of communication interface, connected to a low power computer responsible for data acquisition, analysis and presentation. It has to be said up front, that I am far from the only one looking into this. On a Danish engineering discussion forum , I came by other people experimenting with the Kamstrup 382, except that none of the info I came by there seemed to apply to my version of the meter. ...

C# type inference

While I work mainly in a Java shop, I continue to be impressed by what Anders Hejlsberg, chief architect of C#, brings to the table to a language which in my mind has always represented Java done right. I do wonder however, how come they did not take the concept of type inference just a little bit further. Local variable type inference This feature of C# 3.0 basically allows you to omit the declaration which, especially when generics is involved, causes a lot of repetition and long lines of code: Dictionary<int, IEnumerable<decimal>> myCollection = new Dictionary<int, IEnumerable<decimal>>(); Which can be reduced to this: var myCollection = new Dictionary<int, IEnumerable<decimal>>(); No late binding is taking place, the compiler simply infers the actual type and substitutes var with it. No method return type inference? Some languages operates with the concept of tuples, a way of returning multiple values without having to wrap them in an arr...