Archive for January, 2008
Posted by Sebastien Lachance on January 24, 2008
I have always been told that TypeMock was too powerful, not strongly typed and for that, It shouldn’t be used. I believed that. The problem is : I should have given it a try before taking that for granted.
I have watched the Roy Osherove screencast and was impressed! I am currently working on an existing code base that was done before we went Agile and even before we were doing object-oriented development. When I need to refactor certain features I usually start writing tests and then using dependency injection to be able to mock some object. The minimum to be testable with Rhino Mocks. But with TypeMock you can mock object and don’t even need to inject them. You can also make expectation on static methods. Isn’t that just great! I believe so.
However, I will stick with Rhino Mocks for now. I like the way It force me to decouple my code and in some sense, it provide me with guidance to make my work testable.
P.S. : This is just my opinion and not the absolute truth.
Posted in Agile, Design, Tests, Tools | No Comments »
Posted by Sebastien Lachance on January 23, 2008
Of course it does something, just make sure you call the Flush method on your session…
I have just started playing around with NHibernate for a personal project (the one I use for the Building a new application series) and I’m liking it. This make all the data access seems so easy. Maybe I will change my point of view after dealing with some collections and relationships.
Posted in .NET, Design, Learning, Project, Tools | No Comments »
Posted by Sebastien Lachance on January 17, 2008
Duh, this isn’t my day! Applying the DataContract and DataMember attributes to my class is a great solution to this problem. Anyway, at least I didn’t loose much time.
Posted in .NET, WCF | No Comments »
Posted by Sebastien Lachance on January 17, 2008
There is thing you know you should do, but with too much confidence, you will forget. This was the case this morning with the Activator.CreateInstance method.
I was getting this error :
Exception has been thrown by the target of an invocation.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOn
ly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& b
NeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCach
e)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisi
bilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder bin
der, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binde
r binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(String assemblyName, String typeName, Bool
ean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureI
nfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMar
k& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at DynamicsGP.GPListener.Program.Main(String[] args)
After double and triple checking with Reflector and outputing everything possible to the console, I wasn’t able to figure out what I did wrong.
The solution was easy, I was not checking the InnerException of the exception. Turn out is was only a missing dll.
Posted in .NET | 1 Comment »
Posted by Sebastien Lachance on January 14, 2008
Sometimes, you come across real treasure! This is one of them, printed and with me for a long time.
I have just finished reading the “Foundations of Programming” series by Karl Seguin. This is a “Must Read”. It’s a really great series that cover all aspect of building an application. I can’t recommend it enough!
Here is a link to the PDF file which has all seven posts.
Posted in Agile, Continuous Integration, Design, Learning, Tests | 1 Comment »
Posted by Sebastien Lachance on January 14, 2008
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="Company" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>GPWebServices.Company, Web References.GPWebServices.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
I have a lots of files with the extension “.datasource”. It seems that Visual Studio generate those files, so that we can use the Web Service as a datasource of some sorts. I haven’t really played with that yet, I’m more inclined to bind my domain models directly.
I wonder if there is a way to deactivate the generation of this kind of files in Visual Studio. Stay tuned!
Posted in .NET | 2 Comments »
Posted by Sebastien Lachance on January 14, 2008
I was wondering when this day would come. When I’d start thinking in term of object. This change in paradigm was not easy. I started programming using the data-centric way and was submerged by it. I was struggling to get rid on this kind of thinking. I’ve read multiple book before : Agile Software Development, Object Thinking, Refactoring, etc. But this was hard to me. However, 6 months ago, I finally landed on an Agile team. I got a hard time changing the way I was thinking because I was sure that I was understanding object-oriented development.
For me, the revelation occurred in this team. There I was introduced to my first test-driven project. One of the team members and a consultant for the company was previously working for Object Mentor. I needed to be up to the task, and immerged myself completely into it. I was reading the code of the project regularly and tried to do the same thing. I made mistakes, lots of mistakes, but I learned from them (even if I was not being directed in the right way after making them, but this is another story). Unfortunately the project was put to an halt and I had to get back to the old project, the one that became so complicated that I had abandoned all hope of doing something right with it. I was wrong, this was a wonderful opportunity and this is where the mind shift occurred. I started doing some unit tests and when I was comfortable with the coverage of a certain part, refactor to reflect a more object-oriented and easier to understand ways. I learned about Inversion Of Control (IoC), Dependency Injection, Mocking, Domain-Driven Design and Design Pattern. I also started to read my books back. I re-read Code Complete, Refactor and Object-Design Heuristics, and I am planning to read a lot more. I also adopted many of the Agile practices. This was not hard, since I had worked on project that had big upfront design, and after every release, we were deploying every week a new versions because of the bugs we had found or enhancements the clients wanted. This was just the natural thing to do and I firmly believe this is a good road to follow.
Now, If I could only get a new challenge to push my limits and learn more!
Posted in Agile, General, Learning, Programming | No Comments »
Posted by Sebastien Lachance on January 8, 2008
I want to thank everybody who has been visiting my blog. I have now reach 6000 hits with an average of 60 hits per day. I will keep raising my bar to deliver you some great content over the next few months. Thank you very much!!!
P.S. I’ll keep working on my writing skills, don’t worry!
Posted in Blogging, General | No Comments »
Posted by Sebastien Lachance on January 8, 2008
For the getter, it’s exactly as you would do with a method :
Expect.Call(mockedConnection.CompanyConnectionString).Return("testconnectionstring");
For the setter, only assign the value you want to the property of the mocked object :
mockedConnection.ConnectionString = "testconnectionstring";</PRE
Posted in Agile, Design, Learning, Tests | No Comments »
Posted by Sebastien Lachance on January 7, 2008
Following the definition of a nightmare platform, I officially declare Microsoft Dynamics GP to be one of them. Sorry Dynamics GP guys, but I need an explanation for why I have spent half a day trying to figure out how this can be possible.
Consider this example :
salesItem.StandardCost = new MoneyAmount();
salesItem.StandardCost.Value = 1;
salesItem.StandardCost.DecimalDigits = 2;
salesItem.UofMScheduleKey = new UofMScheduleKey();
salesItem.UofMScheduleKey.Id = "EACH";
Policy policy = DynamicsWebService.GetPolicyByOperation("CreateSalesItem", DynamicsWebServiceContext);
DynamicsWebService.CreateSalesItem(salesItem, DynamicsWebServiceContext, policy);</PRE
And here is the error message :
A validation exception has occurred.
Validation Errors:
- StandardCost cannot be less than 0.
I’m still trying to figure out what amount should I put when the item has a cost…
Posted in General, Learning, Programming | 2 Comments »