Friday, September 21, 2012
Friday, August 24, 2012
Friday, August 17, 2012
Yesterday I gave a presentation on the Fluent Interface Pattern for the Capgemini Microsoft User Group. The slides from presentation are available below:
Thursday, August 16, 2012
When you install Windows 8 Enterprise RTM then the installer will never ask you for a product key, instead it will just use a default key from Microsoft which cannot be used to activate Windows. In order to successfully activate Windows then you need to replace this key with your own and the only way to do this is through the command line (it’s not possible to do this through the UI):
1) In the Metro UI, search for command prompt.
2) Right click command prompt and choose Run as Administrator from the menu.
3) Write: slmgr.vbs -ipk "your key goes here" and hit enter.
Windows should now be activated.
Wednesday, August 15, 2012
Tuesday, July 31, 2012
In June I gave a couple of presentations to the students who got the chance to work for Capgemini during the summer. One of the presentations was on layered architecture where I talked about logical layering, physical tiers and the difference between them. I also showed some example code. The slides from the presentation are available below:
Monday, May 28, 2012
Earlier this month I gave a presentation at the Capgemini Microsoft User Group with the title 'Introduction to FluentData'. In the presentation I talked about what FluentData is and why it was created, and I showed some sample code that gives a good overview of how to do common CRUD operations using FluentData.
Here are the slides from the presentation:
Earlier this month I gave a presentation at the Capgemini Microsoft User Group with the title "Dependency Injection vs Service Locator - Best Practice". In the presentation I talked about Inversion of Control (IOC), the various IOC patterns that exists and when you should use them.
Here is the presentation:
Earlier this month I gave a presentation at the Capgemini Microsoft User Group with the title 'Data Access - Best Practice'. In the presentation I went through why the data access blocks in an application are so important, common issues related to data access that you find in many code bases and how to solve these, and at the end a summary that wraps it all up into the following best practice principles:
- Have small, simple classes that do only one thing.
- Use the Criteria Pattern to decide what data to retrieve.
- Use joins to retrieve as much data as needed in one query.
- Avoid lazy loading.
- Use parameters instead of concatenated strings.
- Always check for permissions when retrieving, creating, updating or deleting data.
- Use transactions to rollback when errors occur.
- Use the Gateway Pattern to reduce ORM dependency.
- Have a strict Frontend layer, Business layer, Data Access layer.
- Verify quality through Integration Tests.
Here are the slides from the presentations:
Monday, March 26, 2012
Luckily we have design patterns for the most common problems, and a nice pattern to use in this scenario is the Facade Pattern. By creating a facade class per feature/module we can make all the public operations available through a single class, then this will help us to get a better overview of the codebase and help us to avoid code duplication:
Monday, March 19, 2012
FluentData has now been added to NuGet. This makes it very easy to use FluentData in any new or existing project and also to stay up to date on new versions.
Check it out through the NuGet package explorer in Visual Studio by searching for FluentData or go to http://www.nuget.org/packages/FluentData.
Saturday, March 3, 2012
If you find yourself adding #regions to your code to make it easier to read and understand then this is a sign of a class that have gotten too big. Personally I prefer classes to be around 1 screen in height, and anything above this is less optimal and should be refactored.
How can you refactor away from using regions? There are 2 ways:
1) Split the class into many partial classes. This will make the class easier to read but not necessarily easier to understand or maintain. 2) Split the class into many smaller classes. The Single Responsibility Principle is important here, if the class only does one thing then it will be smaller, easier to read, understand and maintain.
Should you refactor to partial classes or smaller classes?
Try to refactor to smaller classes, and where this is not possible such as in public APIs or facade classes then refactor to partial classes.
Thursday, February 23, 2012
In order to write code that are easy to test then there are a few principles that must be followed:
- Dependencies must be injected, use property- or constructor injection or an injected service locator.
- Avoid static variables.
- Avoid calling static methods unless they are only doing in-memory operations.
- Mark public methods as virtual or use interfaces.
- Classes and methods should be small. Preferably not longer than one screen size. Use the single responsibility principle to achieve this - a class should only be responsible for doing one thing = one public method (except from method overloads and facade classes).
Sunday, February 19, 2012
FluentData version 1.1 is out on CodePlex with support for MySQL. MS SQL Server, MS SQL Server Compact 4.0, MS SQL Azure and Oracle is already supported. Download it from here.
Wednesday, February 15, 2012
FluentData is a new open source Micro ORM framework that makes it easier than ever to query a database.
The existing ORMs frameworks on the market such as Entity Framework and NHibernate are overly complex and difficult to learn. The generated SQL from those frameworks are poor due their own abstracted query language and mapping from the database to .NET objects is difficult.
FluentData takes a different approach by being a lightweight framework with a simple fluent API that is easy to learn. Mapping between the database and .NET objects are simple and by using SQL which is the best database query language around you get fast and efficient queries.
Read more, see some code samples and download FluentData from http://fluentdata.codeplex.com.
Monday, January 30, 2012
Internal types and members are by default not accessible from a separate unit test project. However this can be overcome by using something known as a Friend Assembly.
A Friend Assembly is an assembly that can access internal types and members of another assembly. So if you have a project A and a project B and you want B to access the internal members of A, then all you need do is to add the following line to the AssemblyInfo.cs file in A.