The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,828 other subscribers

Archive for the ‘Software Development’ Category

c# – PRISM + MEF — How to specify which export to use? – Stack Overflow

Posted by jpluimers on 2011/03/10

When you export different implementations of the same interface, importing the right one requires a “named contract“.

Like Danny Thorpe wrote: “Ah, named contracts. I had forgotten about that!”, indeed the first answer is nice!

–jeroen

via c# – PRISM + MEF — How to specify which export to use? – Stack Overflow.

Posted in .NET, Development, MEF, Software Development | Leave a Comment »

C# generics: Constraints on Type Parameters

Posted by jpluimers on 2011/03/10

I usually forget the exact details on C# constraints when using generics.

One of the especially irritating things is that you cannot apply all the constraints you want.

Some built-in language features are covered by special types in the .NET framework class library, for instance enums.

Which means that code like this will not compile:

        // Error	1	Constraint cannot be special class 'System.Enum'
        public static T StringToEnum(string name) where T : System.Enum
        {
            return (T)Enum.Parse(typeof(T), name);
        }

You need to replace it with the code below, which uses the fact that an enum is a ValueType (hence the struct constraint) implementing the interfaces IComparable, IFormattable and IConvertible constraints: Read the rest of this entry »

Posted in .NET, C#, C# 2.0, Development, Software Development | Leave a Comment »

Cool tool: .NET Version Detector

Posted by jpluimers on 2011/03/09

Cool tool from ASoft.NET Version Detector.

.NET Version Detector is a native application, which means it isn’t dependent on any version of .NET to run.

.NET Version Detector is a handy tool for vendors of .NET applications also.

Knowing which versions a user has installed and where they are located on the hard drive.

ASoft allows for a vendor to bundle .NET Version Detector with its application (for free!) so that it is easier to get some generic and exact information on the frameworks.

But before doing so, contact ASoft first!

–jeroen

via: .NET Version Detector.

Posted in .NET, Development, Power User, Software Development | Leave a Comment »

Why is the result of RoundTo(87.285, -2) => 87.28 – Stack Overflow

Posted by jpluimers on 2011/03/08

Programmers on all sorts of platforms get this wrong all the time (I admit having done this in bad ways myself too).

In short: Don’t expect floating point values in a computer to be represented as decimals.

Rob Kennedy wrote a very nice answer on this:

The exact value 87.285 is not representable as a floating-point value in Delphi. A page on my Web site shows what that value really is, as Extended, Double, and Single:

87.285 = + 87.28500 00000 00000 00333 06690 73875 46962 12708 95004 27246 09375

87.285 = + 87.28499 99999 99996 58939 48683 51519 10781 86035 15625

87.285 = + 87.28500 36621 09375

And David Heffernan points to the best link you can get on this topic:

The classic reference on floating point is What Every Computer Scientist Should Know About Floating-Point Arithmetic.

For currency based calculations, if indeed this is, you should use a base 10 number type rather than base 2 floating point. In Delphi that means `Currency`.

–jeroen

via delphi – Why is the result of RoundTo(87.285, -2) => 87.28 – Stack Overflow.

Posted in .NET, Algorithms, C#, Delphi, Development, Floating point handling, Software Development | 14 Comments »

If you use MonoTouch for iOS, be sure to update the iOS SDK (it doens’t auto update)

Posted by jpluimers on 2011/03/08

If you don’t update the Apple iOS SDK (which doesn’t auto update), then the Apple Store will reject your MonoTouch apps.

A big thank you to Peter van Ooijen for figuring this out

–jeroen

via: The appstore, iOs versions and Monotouch (4.0 won’t do) | Visual Studio Feeds.

Posted in .NET, Development, MonoTouch, Software Development | Leave a Comment »

.NET JIT bugs

Posted by jpluimers on 2011/03/03

All software contains bugs, so for my own reference, when I bump into one of those below, it is good they are known .NET JIT bugs:

http://stackoverflow.com/questions/2135509/bug-only-occurring-when-compile-optimization-enabled/2135904

http://stackoverflow.com/questions/2056948/net-jit-potential-error/2057228

–jeroen

Posted in .NET, Development, Software Development | Leave a Comment »

They should have pushed object oriented programming a lot more a lot sooner – PHP: Manual Quick Reference

Posted by jpluimers on 2011/03/02

Boy I wished the PHP guys have pushed object oriented programming a lot more a lot sooner.

–jeroen

Via: PHP: Manual Quick Reference.

Posted in PHP, Scripting | Leave a Comment »

Weird Errors With EF4 CTP5 Code First? Close All Database Connections » Danny Thorpe

Posted by jpluimers on 2011/03/01

Often solutions are simple, but the steps finding that simple solution can take a while.

This time, good friend Danny Thorpe found out the hard way using the joungest Community Technology Preview version of Entity Framework 4, he writes:

I don’t claim to know why, but after a day of permutations and combinations, this is what I found cleared the problem for me.

The solution for his problems – all sorts of stranges errors when using DropCreateDatabaseAlways in the Entity Framework – is simple: make sure you don’t have any other connection to your underlying database open.

–jeroen

via: Weird Errors With EF4 CTP5 Code First? Close All Database Connections » Danny Thorpe.

Posted in .NET, Development, EF Entity Framework, Software Development | Leave a Comment »

Ask yourself: “are you writing a framework now?” – How (not) to write Factorial

Posted by jpluimers on 2011/03/01

On the Development Choas Theory blog, I bumped into a brilliant blog post titled How (not) to write Factorial in Java.

It is not about Java, or any other programming language, platform or library for that matter.

It equally applies to your favourite programming language and framework (be it shell scripts, assembler, .NET, Delphi, haskell, PHP, ruby, Eiffel, Java or any other).

It is about the question that Neal Ford taught me quite a while ago that you should ask yourself several times a day:
“Am I writing a framework now?”

Developing software is about only developing the things you really need to.

Framework development is in a totally different league than developing ‘just’ software.
It requires even more thought, attention, testing, etc.
And after that, you need to support it on a different level too.

Frameworks are far more costly than you would guess at first sight…

So only develop a framework  for something (*) if you observe that it is actually used in a lot of places and requires a framework.

(*) insert what you are currently working on here.

–jeroen

Via:  Development Chaos Theory » Blog Archive » How (not) to write Factorial in Java

Posted in .NET, C#, Delphi, Development, Software Development | 6 Comments »

Delphi friend in NZ seeks work (preferably remotely)

Posted by jpluimers on 2011/02/25

A seasoned Delphi developer friend in NZ (near Christchurch) seeks work, preferably if he can work remotely.

Please drop me an email to get more information.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »