Saturday, October 31, 2009

AutoMapping Library

I watched another great show on DNRYV: Jimmy Bogard on AutoMapper. It is a tool or framework to map from one class to another one, almost automatically. Of course, you have to follow its default conversion to define the new mapped class. If you prefer new names as mapped properties, you can still use methods from its framework to do that.

Although its' usage may only for mapping a class to another class., I am very impressed by this library's design and interface. This is the most import point I learned from the show. The library is available from CodePlex web site. I subscribed to Jimmy Bogard's blog as well.

Read More...

Monday, October 26, 2009

Pex and Code Contrat

Last week I found two new .Net libraries from Microsoft Research: Pex and Code Contract. Both are right now available as review versions for Visual Studio 2008 Professional version and will be part of .Net framework 4.0 and Visual Studio 2010.

Pex is a library with tools for unit test. It looks very handy and easy to use. It reduces a lot of tedious codes to create test with data. The Pex Exploration integrated with VS 2005 will be able to generate tests with all the data to cover up to 100% of codes. Pex is smart enough to search all the possible branches with data and tests. I remember that I had created a lots of tests to cover all the possible cases and it is very tedious to find branches and repeated uncountable times. The biggest issue to maintain unit tests is that when source codes are changed, the coverage will changed again. In order to cover new cases or update tests, re-examinate source codes and tests need a lots effort. Pex looks much better to handle all those cases. That's really awesome.

In additional to auto-generate test codes, Pex also cover mocking data cases. Actually, I found Pex from the resent DNRTV show: White Box Tesing with Pex, where mocking demo is shown there simulate reading file case. I'll be very interested in trying this great library.

Another very interesting library is Code Contract library. This is really cool stuff I have been looking for. Basically, it is used to define contract for class members, method parameters and method return expectations. The contract is used as static class within .Net codes. Within VS, you can enable is static checking and run-time checking. Any violations will generate exceptions as expected by Contract. In addition to that, it will generate code documentation as well. From its syntax, it is not too complicated but makes the coding much easier. This is definitely a great enhancement to .Net 4.0 and VS 2008 and coming VS 2010.

Read More...

Friday, October 23, 2009

MEF Framework for Dependency Injection

Recently I have time to read MEF (Managed Extensibility Framework) on Microsoft's Open Souce web site CodePlex. I knew this one for quite a while. I decided to spend time to read the whole document about the framework because this one appears many times when I search for new stuff and IOC/DI. Many places also mention that MEF will be part of .Net Framework 4.0 and Visual Studio 2010.

The framework seems very simple. Basically it uses attribute classes Import and Export to define dependency relationships. Export is used to export a class and in most cases the class should implement an interface. Then Import is used by MEF to find out matched class to get an instance. MEF also supports a collection of same Imports with same types. In this way, Parts are separated by application and libraries which are linked by MEF only by types specified in Import and Export. One advantage of MEF is that it is based on reflection to get DI relationship by Catalog. As a result, there is no need to define DIs by xml or config files.

I have used StructureMap and I really like its strength in IOC/DI, as in my previous blogs. SM also separates dependent parts between clients and users very well. I think I'll try MEF out in my projects to find out really how MEF works.

Read More...

Tuesday, October 13, 2009

Microsfot Channel 9 Shows on Functional Programming Language

Last night I watched two new lectures on Functional Programming Fundamentals by Eric Mejier. I watched his discussion on Visual Studio 2010 Inversion of Enumerations before. That was very impressive. This series talks explore more fundamentals about Functional Language.

I watched DNRTV on F# before. My impression of this language is that it is back to old style of programming in structured functions. It is far away from objective oriented language such as C# and VB.Net. However, Eric talks demonstrate some unique powers of functional language. I really like its stateless and easy test features.

One question about functional language is how it is integrated with OOP languages such as C# and VB.NET? F# will be part of VS 2010. There must be ways easily to integrate it to C#. When I finish Eric's talks, I think I'll get much clear picture of FP's role.

One interesting point of Eric's talks is that he starts from popular FP language Haskell 98, instead of Microsoft's F#. The first talk is mainly on the history of FP and the second one jumps into Haskell. The tool or FP system shell he used for loading and running Haskell scripts is Hugs.

Read More...