Far Away Developer

Sebastien Lachance

Archive for the 'Programming' Category


Visual Studio 2008 - WCF Templates

Posted by Sebastien Lachance on May 21, 2008

When you want to create a new WCF project, you are presented with 4 different templates to use :

  • Sequential Workflow Service Library
  • Syndication Service Library
  • State Machine Workflow Service Library
  • WCF Service Library

Each one has it’s own particularities. It’s important to know which one to choose but you should know that the template only generate things you need to get started. You can always start from an empty WCF Service Library and build on top of it. Anyway, here is an explanation for each one.

 

Sequential Workflow Service Library

You basically create a sequential workflow project that made operations available by WCF. I have no experience with Workflow Foundation so I will not go further into details.

 

Syndication Service Library

This template is great. It present you a way to expose an RSS or Atom feed via a WCF Service contract. This is built-in stuff already present in the framework.

To expose a feed, you need an operation that return a  SyndicationFeedFormatter (in the System.ServiceModel.Syndication namespace). Then create a SyndicationFeed and add SyndicationItem to it. Finally, create a Atom10FeedFormatter or Rss20FeedFormatter and return it.

SyndicationFeed feed = new SyndicationFeed("Feed Title", "A WCF Syndication Feed", null);
List<SyndicationItem> items = new List<SyndicationItem>();

// Create a new Syndication Item.
SyndicationItem item = new SyndicationItem("An item", "Item content", null);
items.Add(item);
feed.Items = items;

// Return ATOM or RSS based on query string
// rss -> http://localhost:8731/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/
// atom -> http://localhost:8731/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/?format=atom
string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
SyndicationFeedFormatter formatter = null;
if (query == "atom")
{
   formatter = new Atom10FeedFormatter(feed);
}
else
{
   formatter = new Rss20FeedFormatter(feed);
}

return formatter;

 

State Machine Workflow Service Library

Another template that expose a Windows Workflow as a Service. This time the type of Workflow is a State Machine. A state machine workflow contrary to a sequential workflow is driven by external events. Transition between states are based on certain events until it reach the final state.

 

WCF Service Library

The most basic project to create a WCF service. You can use it to do everything you want with the most control.

 

Technorati Tags:

Posted in .NET, Programming, WCF | No Comments »

My experience as a remote worker

Posted by Sebastien Lachance on March 6, 2008

You may not know, but I am a full time web worker since February 2007 and I am loving it. I followed my girlfriend to his new job in mechanical engineering located in the “Beauce” area in the province of Québec (1 hour from Québec City). But let’s make a point clear. It was not as easy as it sounds. It takes a lot of discipline and you may find that you just can’t do it. I have had many friends who were not able to work from home. For me, it was easy since it’s a childhood dream. I have gone through 3 phases.

The first one is the “That’s easy” phase. During the first 2 months, everything seemed so easy. I was very productive and enjoyed every minutes working from home. This is also the phase were you work more than you are supposed and keep no free time. You have the impression you can achieve anything.

I called the second phase : “I need to check everything around the house to be sure nothing changed.”. In this phase, everything disturbed me. I started to feel lonely and was wondering if I made the right choice. During this 6 months phase I had a hard time concentrating on my job. It’s also the time we were building our new home. During that time, I never took a day off except the day we moved in. I was exhausted, stressed and lost. We had problems with contractors. The price we anticipated was a bit higher due to the angle of the lot we bought. To make things worst, I started working on a new project requiring me to work with Microsoft Dynamics (until you used the supplied API you can’t imagine how frustrating of an experience it is). But I have gone through it.

Now, I am in the third phase. I called it the “Rebirth phase”. I restarted my old habit of learning as much as I can. I have solved my concentration problem. I feel a lot more happier and a lot more in health. I started to really enjoy working remotely and I am sure I am as productive as I was before. I am now fully happy with it. And I have new projects for my region…

Posted in Blogging, General, Programming | 2 Comments »

I am now available to hire !

Posted by Sebastien Lachance on March 3, 2008

I am now available to work on small contracts for now. I also want to work remotely. If you are interested, just let me know via the contact form.

HIRE ME !

Posted in Blogging, General, Programming, Project | No Comments »

WHILSOF : What Have I Learn SO Far

Posted by Sebastien Lachance on February 22, 2008

I have been pretty busy lately. I have so much fun working on my project, that I have neglected my blog a little. As part of my “Building a New Application Series“, I will introduce another series under it, the “What Have I Learn SO Far”. As you may know, I started this project as a challenge (The “What I can do in the next 6 months to become a better developer ) to learn more. This series will consist of various knowledge I acquired during the course of the project. I have already learn a lot and I have multiple items on my list to blog about. Various stuff about application architecture, xUnit, NHibernate, Domain Modeling, etc. I’ll try to deliver great content. 

Posted in Blogging, Programming, Project | No Comments »

Mind shift

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 »

Nightmare platform

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 »

Building a new application - Introduction

Posted by Sebastien Lachance on November 27, 2007

(Index of the whole series)

I want to build an application and release it to the community. This is an application I had in mind for a long time. Basically, it’s a logging application. Not the one you would use to track requirements and time spent on a project. I’m talking about a logging application to log your weight, track your goals, what you’ve eat, do reports , etc. I know it’s something people want. I’m not doing it for money. I want to learn as much as possible and I think that writing code and solving new problems is a great way to learn. I have to take some basic decision at the beginning of the project and I must admit it will be a good excuse to make a list of all the new things (for me) that I want to use in the project and blog about them. This is an opportunity for me to take the time of using object-oriented techniques and becoming more agile. I will also blog a lot about that, because I find that blogging an interesting tool to learn and explaining to others help reinforce knowledge and being more confident. Also, posting about your goals, makes it a little harder to abandon too early.

My requirements are the the following :

  • Test-Driven development. I want a coverage of 95% at least.
  • Building an continuous integration server.
  • Applying at the best of my knowledge Object-Oriented principle.
  • User stories.
  • Identify mistakes as soon as possible and learn from them.
  • Use a source control software and learn some of the best practices of source control management.

Technologies I want to use :

So I want It to be Agile as most as possible. First step, print the Agile Manifesto!

Posted in .NET, Agile, Programming, Tools | No Comments »

Becoming a better developer : Where am I? Third update

Posted by Sebastien Lachance on November 12, 2007

Things are finally getting smoothly. I have been really busy with the construction of the new house and haven’t been able to get up to speed with my goals. I am a the second book of 12, and the challenge end in two months. There is some good news at least, I am now able to concentrate fully on my objectives. But I have reduced the number of books to 4…

This is the new list :

I am also on the way of regaining my health back. At least 15 minutes a day of workout.

And finally, for the small project, I am working really hard on this. I am planning something real soon.

Posted in Fun, Learning, Programming | No Comments »

Becoming a better developer : Where Am I? Second Update

Posted by Sebastien Lachance on September 21, 2007

I’m almost through my first 3 books, Head First Design Patterns, Windows Forms 2.0 and CLR via C#. I am not reading as much as I would want because of the construction of my new house, but starting Monday in 2 weeks I should be back on track with a more normal life (I really hope so).

Posted in Fun, Learning, Programming | No Comments »

Becoming a better developer : Where am I?

Posted by Sebastien Lachance on September 3, 2007

I stopped completely drinking energy drink. Too much harmful effect. I also stopped drinking carbonated beverage a long time ago. For the rest I must admit it’s a lot more difficult than I thought but I’m optimist. Not a single pound lost, but I want to start slowly by modifying my bad habits one by one.

As for my reading, I have 200 pages of Windows Forms 2.0 and 150 pages of CLR via C#. I’m enjoying this last one. I have learn a lot on the content of a DLL. As for the Windows Forms 2.0 book, I must admit that the interest is not there. I am not learning anything new and I feel that I’m studying for an exam. But there is some interesting chapter coming on next.

Posted in Fun, Learning, Programming | No Comments »

SourceSafe on VPN

Posted by Sebastien Lachance on July 20, 2007

First thing : it’s slow. You can’t imagine how it is slow. There is nothing to do, it will stay slow if you access it with the LAN mode. But there is a solution that will help SourceSafe to be a little faster. You need to use Remote Web Access over Http. The time to check-in a single file in my case, has gone from 1 minute to 5 seconds.

Here is some link that will help you setup your environment:

How to: Enable the Internet Service for Remote Access

Alin Constantin : Installing and configuring Microsoft Visual SourceSafe for Internet (Remote) access

Posted in General, Programming | 1 Comment »

Getting rid of intellisense addiction

Posted by Sebastien Lachance on July 16, 2007

For a month now, I trying to learn ruby and the Ruby On Rails framework. The biggest difficulty so far was programming without intellisense. Honestly, I’m loving this difficulty. I reading a lot more the documentation that before and find this really helpful for my learning. But the coding is a lot more slower and by chance, this is a personal project and I have no deadline (and you can get a project done really quick with Rails, believe me !).

Now, if only I can get rid of the mouse …

Posted in Programming | 2 Comments »

SQL Datetime without hour/second/minute part

Posted by Sebastien Lachance on June 26, 2007

Have you ever wondered how you can get a date from SQL without the hour/second/minute part ?

How maybe comparing 2 dates without this part ?

Search no more ! Here is a secret I will share with you :

SELECT CAST(FLOOR(CAST(SentDate AS float)) AS datetime) FROM Message

This will return the date as follow :

2005-10-13 00:00:00.000

I hope this will help you !

Posted in Programming | 1 Comment »

UCOTD - Useful command of the day

Posted by Sebastien Lachance on June 25, 2007

To open Remote Desktop Connection from the command-line :

1. Windows + R (or Start\Run).

2. Type mstsc.

Et voilà!

Posted in Programming | No Comments »

Find a value anywhere in a database (in any columns on any tables)

Posted by Sebastien Lachance on June 25, 2007

Some time ago I encountered a scenario where I needed to find a value that was stored somewhere on a database. I did not know at the time in which table it was stored. I was in need for a way to search in every tables on a specific database,

Fortunately, Vyaskn create a stored procedure that does that. And it does it very well.

Keep this script somewhere near!

Link : http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm

Posted in Programming | No Comments »