<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>.Met de punt naar voren</title><link>http://metdepuntnaarvoren.nl:80/</link><description>.Met de punt naar voren</description><item><title>Create EML file from System.Net.Mail.MailMessage</title><link>http://metdepuntnaarvoren.nl:80/create-eml-file-from-system.netmail.mailmessage</link><description>&lt;summary&gt;For a project I was working on, I needed to create an EML file from the standard MailMessage class which exists in the System.Net.Mail namespace. I came across an &lt;a href="http://www.codeproject.com/Articles/32434/Adding-Save-functionality-to-Microsoft-Net-Mail-Ma"&gt;article &lt;/a&gt; which describes how to extend the save functionality on the MailMessage class. Using the same technique I created an extension method which is able to save the MailMessage class as EML.&lt;/summary&gt;

With this extension method in your solution you can create an EML file like this:

&lt;pre class="brush:csharp; toolbar:false;"&gt;var mailMessage = new MailMessage();
string eml = mailMessage.ToEml();&lt;/pre&gt;

The extension method is implemented like this:

&lt;pre class="brush:csharp; toolbar:false;"&gt;using System.IO;
using System.Net.Mail;
using System.Reflection;
using System.Text;

namespace Infrastructure.MailMessageExtensions
{
    public static class MailMessageExtensions
    {
        public static string ToEml(this MailMessage message)
        {
            var assembly = typeof(SmtpClient).Assembly;
            var mailWriterType = assembly.GetType("System.Net.Mail.MailWriter");

            using (var memoryStream = new MemoryStream())
            {
                // Get reflection info for MailWriter contructor
                var mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null);

                // Construct MailWriter object with our FileStream
                var mailWriter = mailWriterContructor.Invoke(new object[] { memoryStream });

                // Get reflection info for Send() method on MailMessage
                var sendMethod = typeof(MailMessage).GetMethod("Send", BindingFlags.Instance | BindingFlags.NonPublic);

                // Call method passing in MailWriter
                sendMethod.Invoke(message, BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { mailWriter, true, true }, null);

                // Finally get reflection info for Close() method on our MailWriter
                var closeMethod = mailWriter.GetType().GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic);

                // Call close method
                closeMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { }, null);

                return Encoding.ASCII.GetString(memoryStream.ToArray());
            }
        }
    }
}&lt;/pre&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;EML files are perfect for storing the email message on your file system or in the database. The EML file contains all the data from the email, including attachments. You can open the EML in most mail clients and view the email.&lt;/p&gt;
</description><pubDate>Sat, 23 Nov 2013 15:03:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/create-eml-file-from-system.netmail.mailmessage</guid></item><item><title>Bookreview Instant jqGrid by Gabriel Manricks</title><link>http://metdepuntnaarvoren.nl:80/bookreview-instant-jqgrid-by-gabriel-manricks</link><description>&lt;summary&gt;&lt;a href="http://www.trirand.com/jqgridwiki/doku.php"&gt;JqGrid&lt;/a&gt; is an ajax enabled jQuery plugin for showing and editing data in a grid. I've been using jqGrid extensively throughout my projects, and created an &lt;a href="https://github.com/robinvanderknaap/MvcJqGrid"&gt;Html Helper&lt;/a&gt; to ease the implementation in ASP.NET MVC. Because of my experience with jqGrid, Packt publishing asked me to review one of their latest books, &lt;a href="http://bit.ly/1an91tS"&gt;Instant jqGrid by Gabriel Manricks.&lt;/a&gt;&lt;/summary&gt; 

&lt;p&gt;The book is mainly focused on people starting with jqGrid, experienced users will probably know most of the stuff that is written in the book and is of no added value to them.&lt;/p&gt;

&lt;p&gt;The book can be divided in two parts. The first part teaches the jqGrid basic concepts, installation and walks you through the steps of creating your first grid. The second and biggest part is called 'Top 7 features you need to know about' and takes a deep dive in the most important features of jqGrid.&lt;/p&gt;

&lt;p&gt;Covered in the second part are formatters, adding controls, editing data, connecting to a backend server and a description of some common methods and events of the jqGrid API. I especially liked the the example of connecting jqGrid to the backend. The backend code is written in PHP, but should easily be understood by developers of other platforms. The example shows how to retrieve data from the server, and page, search and edit data on the server, which are the core features of jqGrid. The author describes every step thoroughly and in a clear and simple form.&lt;/p&gt;

&lt;p&gt;What I missed in the book is how to deal with custom styling. It is mentioned you can use jQuery UI themeroler, but doesn't give any information or example how to further customize the styling of the grid. Also I thought it was too bad the author did not mention the option of virtual scrolling when describing the pager, which I like very much and is easy to implement.&lt;/p&gt;

&lt;p&gt;The book is very easy to read and to follow. After going through the book, and the examples, a developer should have a sound knowledge of jqGrid, and be able to customize the grid to their needs. I remember the pain going through the online documentation and examples when I first started with jqGrid, this book is a real time-saver for people who want to start working with jqGrid. Not every feature or option is covered in the book, it only counts 58 pages, but I think gives you enough baggage to get started and explore more features, like subgrids, treegrids and data grouping, on your own using the online documentation and examples.&lt;/p&gt;</description><pubDate>Sun, 29 Sep 2013 19:40:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/bookreview-instant-jqgrid-by-gabriel-manricks</guid></item><item><title>Presenting iDeal.NET</title><link>http://metdepuntnaarvoren.nl:80/presenting-ideal.net</link><description>&lt;summary&gt;iDeal is the leading online payment platform in the Netherlands. Last year when working on &lt;a href="http://bidfortickets.nl"&gt;bidfortickets.nl&lt;/a&gt; I had to create an API to interact with our iDeal provider (Rabobank) to handle all online payments. I noticed that a lot of examples existed out there especially for PHP, but nothing really usable for the .NET ecosystem. So I decided to open source the API on GitHub and call it &lt;a href="https://github.com/robinvanderknaap/iDeal.NET"&gt;iDeal.NET&lt;/a&gt;. The API takes care of all communications with the iDeal provider and is easily integrated into a .NET (web)application.&lt;/summary&gt;
&lt;h2&gt;Supported iDeal versions&lt;/h2&gt;
&lt;p&gt;iDeal.NET is aimed at iDeal Professional (Rabobank), iDeal Zelfbouw (ABN Amro), iDeal Integrated and iDeal Advanced (ING Bank). These versions allow for real-time feedback on transactions.&lt;/p&gt;
&lt;p&gt;iDeal.NET does not yet support iDeal Basic (ING Bank), iDeal Hosted , iDeal Lite (Rabobank) and iDeal Zakelijk which are easily implemented in applications but do not allow for real-time feedback on transactions.&lt;/p&gt;
&lt;h2&gt;Source, samples and documentation&lt;/h2&gt;
&lt;p&gt;The source code is hosted on GitHub, this is where you also find the documentation. The solution includes a sample ASP.NET MVC application which shows the basis usage of iDeal.NET. The sample application uses &lt;a href="http://www.ideal-simulator.nl"&gt;www.ideal-simulator.nl&lt;/a&gt; to simulate the entire process of paying and retrieving status of payments. A live version of the example can be found &lt;a href="http://ideal.skaele.it/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
&lt;p&gt;Implementation of iDeal is basically about three types of requests: directory requests, transaction requests and status requests. iDeal.NET provides an easy to use API to send the requests and handle the responses.&lt;/p&gt;
&lt;p&gt;A directory request for example, which retrieves a list of bank (issuers), is as easy as:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;var iDealService = new iDealService();
var directoryResponse = iDealService.SendDirectoryRequest();
var issuers = directoryResponse.Issuers;
&lt;/pre&gt;
&lt;p&gt;You can find detailed information about the usage of the API on &lt;a href="https://github.com/robinvanderknaap/iDeal.NET"&gt;GitHub&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;</description><pubDate>Wed, 24 Oct 2012 18:06:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/presenting-ideal.net</guid></item><item><title>Using P4Merge with TortoiseGit</title><link>http://metdepuntnaarvoren.nl:80/using-p4merge-with-tortoisegit</link><description>&lt;summary&gt;The team I’m currently working with uses &lt;a href="http://www.perforce.com/products/perforce"&gt;Perforce&lt;/a&gt; as their versioning system. Personally I prefer Git over Perforce, but Perforce has a great merging/diff tool called &lt;a href="http://www.perforce.com/product/components/perforce_visual_merge_and_diff_tools"&gt;P4Merge&lt;/a&gt;. Fortunately you can install P4Merge separately without the rest of the system. I mainly use the Bash and TortoiseGit when working with GIT , this article demonstrates how to integrate P4Merge with TortoiseGit.&lt;/summary&gt;
&lt;h2&gt;Install P4Merge&lt;/h2&gt;
&lt;p&gt;P4Merge is included in the P4 Installer, when executing the installer you’re are able to install P4Merge only, you have to download the entire installer however. Follow these steps to install P4Merge:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Go to &lt;a href="http://www.perforce.com/downloads/complete_list"&gt;http://www.perforce.com/downloads/complete_list&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;Click ‘Browse by Platform’ tab&lt;/li&gt;
    &lt;li&gt;Chose a platform&lt;/li&gt;
    &lt;li&gt;Chose a operating system&lt;/li&gt;
    &lt;li&gt;Download P4Merge&lt;/li&gt;
    &lt;li&gt;Run the installer and only select P4Merge to install&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Setup Diff Viewer with TortoiseGit&lt;/h2&gt;
&lt;p&gt;Follow these steps to setup P4Merge as the default diff viewer for TortoiseGit:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Open TortoiseGit-&amp;gt;Settings from the Windows start menu&lt;/li&gt;
    &lt;li&gt;Choose ‘Diff Viewer’ from the settings tree&lt;/li&gt;
    &lt;li&gt;Choose to use an external tool instead of TortoiseMerge&lt;/li&gt;
    &lt;li&gt;Specify the following path and parameters: C:\Program Files\Perforce\P4Merge.exe %base %mine&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;img src="/Media/Default/Images/DiffViewer.png"  /&gt;&lt;/div&gt;
&lt;h2&gt;Setup Merge Tool with TortoiseGit&lt;/h2&gt;
&lt;p&gt;Follow these steps to set P4Merge as the default merge tool for TortoiseGit:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Open TortoiseGit-&amp;gt;Settings from the Windows start menu&lt;/li&gt;
    &lt;li&gt;Choose ‘Merge Tool’ under ‘Diff Viewer’ from the settings tree&lt;/li&gt;
    &lt;li&gt;Choose to use an external tool instead of TortoiseMerge&lt;/li&gt;
    &lt;li&gt;Specify the following path and parameters: C:\Program Files\Perforce\P4Merge.exe %base %theirs %mine %merged&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;img src="/Media/Default/Images/MergeTool.png"  /&gt;&lt;/div&gt;
&lt;h2&gt;Setup Bash&lt;/h2&gt;
&lt;p&gt;Integrating P4Merge with GIT from the Bash is explained in &lt;a href="http://stackoverflow.com/a/2235841/426840"&gt;this&lt;/a&gt; answer on StackOverflow.&lt;/p&gt;</description><pubDate>Wed, 24 Oct 2012 18:04:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/using-p4merge-with-tortoisegit</guid></item><item><title>Starting IIS Express from the command line</title><link>http://metdepuntnaarvoren.nl:80/starting-iis-express-from-the-command-line</link><description>&lt;summary&gt;I've been working with IIS express for some time now, but only as an integrated webserver in Visual Studio. Today I stumbled upon a feature of IIS Express I didn't know existed. You can start IIS express from the commandline and host a webapplication on the fly. No Visual Studio needed.&lt;/summary&gt;
&lt;p&gt;To start IIS Express from the command line, first navigate to the IIS Express installation folder:&lt;/p&gt;
&lt;p&gt;c:\Program Files\IIS Express&lt;/p&gt;
&lt;p&gt;or for 64-bit:&lt;/p&gt;
&lt;p&gt;c:\Program Files (x86)\IIS Express&lt;/p&gt;
&lt;p&gt;With the following command you can host an application in the specified path on port 9090:&lt;/p&gt;
&lt;p&gt;iisexpress /path:c:\myapp\ /port:9090&lt;/p&gt;
&lt;p&gt;Very handy when you quickly want to test an application downloaded from the internet. In my case a beta of Umbraco CMS 5.0, I got it up and running in seconds.&lt;/p&gt;
&lt;p&gt;For a more complete overview of all command line options of IIS Express read &lt;a href="http://learn.iis.net/page.aspx/870/running-iis-express-from-the-command-line/" target="_blank"&gt;this&lt;/a&gt; article.&lt;/p&gt;
&lt;p&gt;When you don't want to fire up the command prompt each time you want to launch IIS Express, Chris McLeod created a &lt;a href="http://chrismcleod.net/iis-express-website-here-shell-extension" target="_blank"&gt;shell extension&lt;/a&gt; using some registry edits to add "IIS Express Website Here" to your context menu. It starts IIS Express in the selected directory, making things even more easy.&lt;/p&gt;</description><pubDate>Wed, 24 Oct 2012 18:02:02 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/starting-iis-express-from-the-command-line</guid></item><item><title>Update jqGrid Html helper for ASP.NET MVC</title><link>http://metdepuntnaarvoren.nl:80/update-jqgrid-html-helper-for-asp.net-mvc</link><description>&lt;summary&gt;We released a new version of MvcJqGrid, a fluent html helper which eases the the implementation of jqGrid in ASP.NET MVC applications. I'll give a short description of the most notable changes in this article. Source code and documentation are hosted on &lt;a href="https://github.com/robinvanderknaap/MvcJqGrid"&gt;github&lt;/a&gt;. We included a sample application in the source code, a live example can be found &lt;a href="http://mvcjqgrid.skaele.it"&gt;here&lt;/a&gt;.&lt;/summary&gt;
&lt;h2&gt;Razor engine support&lt;/h2&gt;
&lt;p&gt;Although it was possible to use the previous version with the razor engine, it wasn't quite obvious how. The following gives you a basic example how to use the new version of MvcJqGrid with the razor view engine:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;@(Html.Grid("basic")
    .SetCaption("Basic Grid")
    .AddColumn(new Column("CustomerId")
        .SetLabel("Id"))
    .AddColumn(new Column("Name"))
    .AddColumn(new Column("Company"))
    .AddColumn(new Column("EmailAddress"))
    .AddColumn(new Column("Last Modified"))
    .AddColumn(new Column("Telephone"))
    .SetUrl("/Home/GridData/")
    .SetAutoWidth(true)
    .SetRowNum(10)
    .SetRowList(new int[]{10,15,20,50})
    .SetViewRecords(true)
    .SetPager("pager"))
&lt;/pre&gt;
&lt;h2&gt;NuGet&lt;/h2&gt;
&lt;p&gt;MvcJqGrid is now available as a NuGet package which makes installing the helper a trivial task:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;install-package MvcJqGrid
&lt;/pre&gt;
&lt;p&gt;You have to install jqGrid and jQuery yourself, we decided not to include these as dependencies.&lt;/p&gt;
&lt;h2&gt;Modelbinder&lt;/h2&gt;
&lt;p&gt;We included the jqGrid modelbinder created by &lt;a href="http://www.codeproject.com/KB/aspnet/AspNetMVCandJqGrid.aspx"&gt;Ilya Builuk&lt;/a&gt;. The modelbinder makes it easy to handle data requests from the grid in your controllers:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;public JsonResult GridData(GridSettings gridSettings)
{
    ...
}&lt;/pre&gt;
&lt;h2&gt;Sample Application&lt;/h2&gt;
&lt;p&gt;The sample application was also updated. The sample is included in the source code, you can find a live example &lt;a href="http://mvcjqgrid.skaele.it/"&gt;here&lt;/a&gt;. The sample application is a nice way to get started with the helper, because for every sample grid the source code is displayed below the grid.&lt;/p&gt;
&lt;p&gt;One word about the sample data being used. The sample data is contained in a Sql Express Database in the App_Data folder. Make sure you have installed Sql Server Express 2008 R2. The Web Platform Installer sometimes indicates you have installed R2 when actually you only have SP2 installed. More info on &lt;a href="http://stackoverflow.com/questions/4257684/sql-server-attach-incorrent-version-661"&gt;StackOverflow&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Unit tests&lt;/h2&gt;
&lt;p&gt;Daan le Duc went out of his way and added 129 unit tests to the project, which improved the overall quality of the Html Helper.&lt;/p&gt;
&lt;p&gt;Hopefully, you'll like this new release. Suggestions, questions and comments are always welcome.&lt;/p&gt;</description><pubDate>Wed, 24 Oct 2012 18:00:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/update-jqgrid-html-helper-for-asp.net-mvc</guid></item><item><title>Setting up FluentValidation for ASP.NET MVC using Ninject</title><link>http://metdepuntnaarvoren.nl:80/setting-up-fluentvalidation-for-asp.net-mvc-using-ninject</link><description>&lt;summary&gt;&lt;a href="http://fluentvalidation.codeplex.com/"&gt;FluentValidation&lt;/a&gt; is a powerful library to validate your model objects fluently. Setting up FluentValidation is easy, import the NugGet package to your project and you're ready to go. It's possible to setup FluentValidation using an IoC container, which is very useful when your validators contain some dependencies which you would like to remove using dependency injection. In this article I'll show you how to use Ninject to setup FluentValidation.&lt;/summary&gt;
&lt;h2&gt;There's a NuGet package for that!&lt;/h2&gt;
&lt;p&gt;I'm assuming you already have FluentValidation and Ninject set up for your project. There's just one little package you need, &lt;a href="https://github.com/ninject/ninject.web.mvc.fluentvalidation"&gt;ninject.web.mvc.fluentvalidation&lt;/a&gt;, which you also can grab from NuGet. This package contains a custom validatorfactory which puts Ninject in charge of creating instances of your validators.&lt;/p&gt;
&lt;p&gt;First you have to create the ninject factory and configure FluentValidation to use this factory instead of the default one. Add the following lines of code to the Application_Start method in Global.asax or if you're using webactivator in the start method of the fluentvalidation startup class in App_Start:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;NinjectValidatorFactory ninjectValidatorFactory = new NinjectValidatorFactory(Kernel); 
FluentValidationModelValidatorProvider
  .Configure(x =&amp;gt; x.ValidatorFactory = ninjectValidatorFactory);
DataAnnotationsModelValidatorProvider
  .AddImplicitRequiredAttributeForValueTypes = false;
&lt;/pre&gt;
&lt;p&gt;FluentValidation is now using the ninject factory for creating instances of validators. The last step is to bind all validators to their implementation. You can do this with one line of code:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;AssemblyScanner.FindValidatorsInAssembly( Assembly.GetExecutingAssembly())
    .ForEach(match =&amp;gt; kernel.Bind(match.InterfaceType).To(match.ValidatorType));&lt;/pre&gt;
&lt;p&gt;This method scans the specified assembly (in this case the current assembly) for validators and binds their interfaces to their implementations. You have to add this method to your Ninject startup script.&lt;/p&gt;
&lt;p&gt;By now, all validators can take dependencies which are resolved by Ninject.&lt;/p&gt;
&lt;p&gt;Happy programming!&lt;/p&gt;</description><pubDate>Wed, 24 Oct 2012 17:59:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/setting-up-fluentvalidation-for-asp.net-mvc-using-ninject</guid></item><item><title>AutoPoco, create meaningful test data based on your domain objects. (.NET)</title><link>http://metdepuntnaarvoren.nl:80/autopoco-create-meaningful-test-data-based-on-your-domain-objects.-.net</link><description>&lt;summary&gt;Creating test data for your applications is usually a cumbersome and not too inspiring exercise, to say the least. Lately I discovered a nice tool called &lt;a target="_blank" href="http://autopoco.codeplex.com/"&gt;AutoPoco&lt;/a&gt; which is created by &lt;a target="_blank" href="http://codeofrob.com/"&gt;Rob Ashton&lt;/a&gt;. AutoPoco enables you to generate meaningful test data based on your domain objects (poco's). AutoPoco is able to generate data for individual unit tests, or you can use AutoPoco to generate large amounts of test data to populate your database.&lt;/summary&gt;
&lt;p&gt;In this article I'll give a short introduction to AutoPoco and explain how to customize AutoPoco to enable the generation of test data which is meaningful to your project and not just some randomly generated values.&lt;/p&gt;
&lt;p&gt;I also created a &lt;a target="_blank" href="https://github.com/robinvanderknaap/AutoPoco.Datasources"&gt;sample app&lt;/a&gt; hosted on github, which contains some basic usage stuff and some custom datasources I wrote. A live version of the sample app is located &lt;a target="_blank" href="http://autopocodatasources.skaele.nl"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Notice:&lt;/b&gt;Source code in this article is based on the latest version of AutoPoco residing in the trunk. The trunk contains some breaking changes with the official v1.0 release and because of that the source code used in this article will not work with the v1 release. The trunk is located &lt;a target="_blank" href="http://autopoco.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;. You can also use the autopoco.dll which is included in the sample app, if you don't feel like compiling the dll yourself. I will update this article and the sample app when Rob decides to release the next version of AutoPoco.&lt;/p&gt;
&lt;h2&gt;How does it work?&lt;/h2&gt;
&lt;p&gt;Basically AutoPoco examines your domain objects using reflection and assigns datasources to each property/field of your domain object. The assignment can be done automagically (convention over configuration), or you can assign datasources yourself. When generating test data each datasource creates meaningful test data to populate the assigned property.&amp;nbsp;Here's a quick example:&lt;/p&gt;
&lt;p&gt;First, create a domain object for which test data will be generated:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;public class User
{
    public int Id { get; set; }
    public string Firstname { get; set; }
    public string Lastname { get; set; }
    public string Email { get; set; }
    public DateTime DateOfBirth { get; set; }
}
&lt;/pre&gt;
&lt;p&gt;Setup an AutoPoco factory and assign datasources to the properties of the domain object:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;// Create factory for poco's and setup datasources
var pocoFactory = AutoPocoContainer.Configure(x =&amp;gt;
{
    x.Conventions(c =&amp;gt; c.UseDefaultConventions());
    x.AddFromAssemblyContainingType&amp;lt;User&amp;gt;();
    x.Include&amp;lt;User&amp;gt;()
    .Setup(u =&amp;gt; u.Email).Use&amp;lt;EmailAddressSource&amp;gt;()
    .Setup(u =&amp;gt; u.Firstname).Use&amp;lt;FirstNameSource&amp;gt;()
    .Setup(u =&amp;gt; u.Lastname).Use&amp;lt;LastNameSource&amp;gt;()
    .Setup(u =&amp;gt; u.DateOfBirth).Use&amp;lt;DateOfBirthSource&amp;gt;();
});&lt;/pre&gt;
&lt;p&gt;Create an AutoPoco session:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;var pocoSession = pocoFactory.CreateSession();&lt;/pre&gt;
&lt;p&gt;Tell AutoPoco to generate 10 users:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;var users = pocoSession.List&amp;lt;User&amp;gt;(10).Get();&lt;/pre&gt;
&lt;p&gt;And here's the result:&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/Images/autopoco_resultset_basic.png"  /&gt;&lt;/p&gt;
&lt;p&gt;AutoPoco is also able to set fixed values for certain properties and allows for invocation of methods on the domain objects. More information on installing and configuring AutoPoco can be found at &lt;a target="_blank" href="http://autopoco.codeplex.com/documentation"&gt;http://autopoco.codeplex.com/documentation&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Roll your own datasources&lt;/h2&gt;
&lt;p&gt;AutoPoco has some built-in datasources, like Email, Firstname, Lastname etc. In a real world scenario the built-in datasources won't get you far. Luckily it's easy to create your own datasources for AutoPoco.&lt;br /&gt;The easiest way to create a custom datasource is to create a class that inherits from the DatasourceBase class:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;public class ExampleSource : DatasourceBase&amp;lt;string&amp;gt;
{
    public override string Next(IGenerationContext context)
    {
        throw new NotImplementedException();
    }
}&lt;/pre&gt;
&lt;p&gt;As you can see, there's only one method you have to implement, the Next method. The DatasourceBase class uses generics to determine the returntype, in this case a string, but this can just as easy be any other object. As an example I will create a datasource which provides company names:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;public class CompanySource : DatasourceBase&amp;lt;String&amp;gt;
{
    private readonly Random _random = new Random(1337);
 
    public override string Next(IGenerationContext context)
    {
        return Companies[_random.Next(0, Companies.Length)];
    }
 
    private static readonly string[] Companies = new[]{
        "Acme, inc.",
        "Widget Corp",
        "123 Warehousing",
        "Demo Company",
        "Smith and Co.",
        "Foo Bars",
        "ABC Telecom",
        "Fake Brothers",
        "QWERTY Logistics",
        "Demo, inc.",
        "Sample Company",
        "Sample, inc",
        "Acme Corp",
        "Allied Biscuit",
        "Ankh-Sto Associates",
        "Extensive Enterprise",
        "Galaxy Corp",
        "Globo-Chem",
        "Mr. Sparkle",
        "Moes Tavern",
        "Central Perk",
        "Chasers"
    };
}&lt;/pre&gt;
&lt;p&gt;Once created this datasource can be used in the same way as the built-in datasources. Extending our previous example, the configuration of AutoPoco would look like this using the company datasource:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;var pocoFactory = AutoPocoContainer.Configure(x =&amp;gt;
{
    x.Conventions(c =&amp;gt; c.UseDefaultConventions());
    x.AddFromAssemblyContainingType&amp;amp;ltUser&amp;gt;();
    x.Include&amp;lt;User&amp;gt;()
    .Setup(u =&amp;gt; u.Email).Use&amp;lt;EmailAddressSource&amp;gt;()
    .Setup(u =&amp;gt; u.Firstname).Use&amp;lt;FirstNameSource&amp;gt;()
    .Setup(u =&amp;gt; u.Lastname).Use&amp;lt;LastNameSource&amp;gt;()
    .Setup(u =&amp;gt; u.DateOfBirth).Use&amp;lt;DateOfBirthSource&amp;gt;()
    .Setup(u =&amp;gt; u.Company).Use&amp;lt;CompanySource&amp;gt;();
});&lt;/pre&gt;
&lt;p&gt;Which results in:&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/Images/autopoco_resultset_extended.png"  /&gt;&lt;/p&gt;
&lt;h2&gt;Concluding&lt;/h2&gt;
&lt;p&gt;It's very easy to generate test data with AutoPoco, and what I like most, you can give meaning to your test data by creating your own datasources.&lt;/p&gt;
&lt;p&gt;I created a &lt;a target="_blank" href="https://github.com/robinvanderknaap/AutoPoco.Datasources"&gt;little project&lt;/a&gt; on github to host some of the custom datasources I wrote. The project includes an asp.net mvc example using some of the built-in and all of the custom datasources I use to generate data. The output of the example project can be found &lt;a target="_blank" href="http://autopocodatasources.skaele.nl"&gt;here&lt;/a&gt;. Feel free to use the datasources anyway you like. Included datasources are:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;EnumSource&lt;/li&gt;
    &lt;li&gt;BooleanSource&lt;/li&gt;
    &lt;li&gt;CitySource&lt;/li&gt;
    &lt;li&gt;CompanySource&lt;/li&gt;
    &lt;li&gt;DateTimeSource&lt;/li&gt;
    &lt;li&gt;DecimalSource&lt;/li&gt;
    &lt;li&gt;DoubleSource&lt;/li&gt;
    &lt;li&gt;DutchCitySource&lt;/li&gt;
    &lt;li&gt;DutchMiddlenameSource&lt;/li&gt;
    &lt;li&gt;DutchMobileSource&lt;/li&gt;
    &lt;li&gt;DutchPostalSource&lt;/li&gt;
    &lt;li&gt;DutchTelephoneSource&lt;/li&gt;
    &lt;li&gt;ExtendedEmailAddressSource&lt;/li&gt;
    &lt;li&gt;FloatSource&lt;/li&gt;
    &lt;li&gt;IntegerSource&lt;/li&gt;
    &lt;li&gt;PostalSource&lt;/li&gt;
    &lt;li&gt;StreetSource&lt;/li&gt;
    &lt;li&gt;TimeSpanSource&lt;/li&gt;
    &lt;li&gt;UrlSource&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Copyright (c) 2010 Webpirates. All source code used in this article is licensed under the Lesser General Public License.&lt;/p&gt;</description><pubDate>Tue, 23 Oct 2012 22:45:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/autopoco-create-meaningful-test-data-based-on-your-domain-objects.-.net</guid></item><item><title>Fluent jqGrid Html Helper for ASP.NET MVC</title><link>http://metdepuntnaarvoren.nl:80/fluent-jqgrid-html-helper-for-asp.net-mvc</link><description>&lt;p style="background: yellow; padding: 10px;"&gt;&lt;span style="color: red; font-weight: bold;"&gt;Update:&amp;nbsp;&lt;/span&gt;A newer version of the jqGrid helper was released, read more about it &lt;a href="http://metdepuntnaarvoren.nl/update-jqgrid-html-helper-for-asp.net-mvc"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;summary&gt;&lt;a target="_blank" href="http://www.trirand.com/blog/"&gt;JqGrid&lt;/a&gt; is a widely adopted grid plugin for jQuery, notorious for its flexibility and tons of available features, and last but not least it's free! Creating the appropriate JavaScript to create a jqGrid and effectively use the available options can be a little verbose, and usually requires a lot of visits to the &lt;a target="_blank" href="http://www.trirand.com/jqgridwiki/doku.php"&gt;documentation wiki&lt;/a&gt;. I decided to create a html helper for ASP.NET MVC, which eases the implementation of jqGrid inside the view.&lt;/summary&gt;
&lt;p&gt;The helper contains a fluent interface providing for a clean and readable view. Most of the properties, events and methods from the base classes of jqGrid are implemented in the helper, including paging, sorting and toolbar searching. At this point, editing, treegrids and subgrids are not yet supported.&lt;/p&gt;
&lt;h2&gt;Sample Application&lt;/h2&gt;
&lt;p&gt;To showcase the helper I created a sample application which demonstrates various grids with different configurations. The source code from the view is displayed below every grid, which should make it easy for you to get started. You can find the sample application &lt;a target="_blank" href="http://mvcjqgrid.skaele.it"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The source code of the entire sample application including the helper is available at &lt;a target="_blank" href="http://github.com/robinvanderknaap/Mvcjqgrid"&gt;github&lt;/a&gt;. For non-git users, locate the 'Download Source' button on the github page to grab the code.&lt;/p&gt;
&lt;h2&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
    &lt;li&gt;jQuery 1.3 or later, included by default when you create a MVC project in Visual Studio or you can grab the latest release at &lt;a target="_blank" href="http://jquery.com"&gt;http://jquery.com&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;jqGrid 3.6.5 or later, you can create your own custom jqGrid package using the &lt;a target="_blank" href="http://www.trirand.com/blog/?page_id=6"&gt;Download Builder&lt;/a&gt;. Make sure you select all three base modules (Grid base, Formatter and Custom), these are used by the helper, other modules are not supported by the helper.&lt;/li&gt;
    &lt;li&gt;jQuery theme, create your own or pick one from the gallery at &lt;a target="_blank" href="http://jqueryui.com/themeroller"&gt;http://jqueryui.com/themeroller&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;The helper, available at &lt;a target="_blank" href="http://github.com/robinvanderknaap/Mvcjqgrid"&gt;github&lt;/a&gt; (You only need the file Grid.cs, located in the HtmlHelpers folder.)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Getting Started&lt;/h2&gt;
&lt;p&gt;After installing jqGrid and adding the helper to your application, you can start using the helper in your views. Make sure to include an import statement to the top of the viewpage that will use the helper:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;&amp;lt;%@ Import Namespace=" MvcJqGrid.HtmlHelpers" %&amp;gt;&lt;/pre&gt;
&lt;p&gt;or if you're planning on using the grid on multiple pages in your project, it's possible to add the reference to your web.config in the system.web/pages/namespaces node, which enables the helper in all your views:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;&amp;lt;add namespace="MvcJqGrid.HtmlHelpers"/%&amp;gt;&lt;/pre&gt;
&lt;p&gt;Creating a basic grid could look something like this:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;&amp;lt;%= Html.Grid("basic")
    .setCaption("Basic Grid")
    .addColumn(new Column("CustomerId")
        .setLabel("Id"))
    .addColumn(new Column("Name"))
    .addColumn(new Column("Company"))
    .addColumn(new Column("EmailAddress"))
    .addColumn(new Column("Last Modified"))
    .addColumn(new Column("Telephone"))
    .setUrl("/Home/GridDataBasic/")
    .setAutoWidth(true)
    .setRowNum(10)
    .setRowList(new int[]{10,15,20,50})
    .setViewRecords(true)
    .setPager("pager")
    %&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Which results in:&lt;/p&gt;
&lt;p&gt;&lt;img src="/Media/Default/Images/500-0-basicgrid.jpeg"  /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the grid is available in the Html class as a regular Html helper. The grid's constructor takes one parameter, which is used to set the id of the grid. All additional properties, methods and events are available through method chaining. The order in which you call the methods doesn't influence the behavior of the grid.&lt;/p&gt;
&lt;p&gt;After the grid is rendered in the client, the grid issues an AJAX callback to request the data. The setUrl method points to an action on your controller, which should either return a json or an xml response containing the requested data (responsetype is set using the setDataType property, default is json). The exact format of the response can be found &lt;a target="_blank" href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:how_to_install"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The helper's only responsibility is to create the appropriate clientside Html and JavaScript to generate the grid. It's the responsibility of the controller to generate the correct response to the request for data send by the grid.&lt;/p&gt;
&lt;p&gt;The &lt;a target="_blank" href="http://mvcjqgrid.skaele.it"&gt;sample application&lt;/a&gt; uses a custom modelbinder (created by &lt;a target="_blank" href="http://www.codeproject.com/KB/aspnet/AspNetMVCandJqGrid.aspx"&gt;Ilya Builuk&lt;/a&gt;) to catch all the request parameters jqGrid sends to the controller. This modelbinder parses all arguments send by jqGrid into a strongly typed object called GridSettings. The definition of the action inside your controller when using this modelbinder would look something like this.&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar:false;"&gt;public JsonResult GetData(GridSettings gridSettings)&lt;/pre&gt;
&lt;p&gt;I won't go into the details of setting up the controller and the model to create the correct response. Lots of information about that subject can be found on the internet. Also, you can examine the sample application. The sample uses a basic model, including sorting, filtering and paging, and shows how to format the data from the model to a json response. It's easy, I promise.&lt;/p&gt;
&lt;p&gt;Hope you like it!&lt;/p&gt;
&lt;p&gt;&lt;strong style="font-weight: bold;"&gt;Noted&lt;/strong&gt;: &lt;a href="daan-le-duc"&gt;Daan le Duc&lt;/a&gt; created a php version of the jqGrid viewhelper, which inspired me to write this ASP.NET MVC variant. Thanx Daan for all the input and hard work!&lt;/p&gt;
&lt;p&gt;Copyright (c) 2010 Webpirates. All source code used in this article is licensed under the &lt;a target="_blank" href="http://www.gnu.org/licenses/lgpl.html"&gt;Lesser General Public License.&lt;/a&gt;&lt;/p&gt;</description><pubDate>Tue, 23 Oct 2012 22:40:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/fluent-jqgrid-html-helper-for-asp.net-mvc</guid></item><item><title>Fluent Interfaces in Views en Templates</title><link>http://metdepuntnaarvoren.nl:80/fluent-interfaces-in-views-en-templates</link><description>&lt;summary&gt;De afgelopen tijd zijn wij binnen Webpirates fan geworden van het gebruik van fluent interfaces om onze code beter leesbaar te maken. In dit artikel wil ik laten zien hoe wij fluent interfaces inzetten om views en templates een stuk leesbaarder, schoner en eenvoudiger in gebruik te maken.&lt;/summary&gt;
&lt;h2&gt;Wat is een fluent interface?&lt;/h2&gt;
&lt;p&gt;Kort gezegd maakt een fluent interface het mogelijk om de publieke API van een object op een efficiente en heldere wijze aan te spreken. De aanroepende code wordt hierdoor doorgaans sterk verkort, beter leesbaar en eenvoudiger in gebruik.&lt;/p&gt;
&lt;p&gt;Het volgende voorbeeld laat zien hoe een class met een fluent interface in C# aangeroepen wordt:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar: false;"&gt;var customer = new Customer()
    .setFirstname("Ad")
    .setLastname("van de Kaart")
    .addOrder(new Order()
        .setProductId(3)
        .setQuantity(10))
    .addOrder(new Order()
        .setProductId(7)
        .setQuantity(5))
    .save();
&lt;/pre&gt;
&lt;p&gt;De customer class bevat naast een aantal properties ook een functie om orders toe te voegen. De order class heeft ook een fluent interface geïmplementeerd waardoor het order object ook eenvoudig te configureren is.&lt;/p&gt;
&lt;p&gt;Dezelfde aanroep, maar dan zonder fluent interface zou er als volgt uit zien:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar: false;"&gt;var customer = new Customer();
customer.Firstname = "Ad";
customer.Lastname = "van der Kaart";
var order1 = new Order();
order1.ProductId = 3;
order1.Quantity = 10;
customer.Orders.Add(order1);
var order2 = new Order();
order2.ProductId = 7;
order2.Quantity = 5;
customer.Orders.Add(order2);
customer.save();&lt;/pre&gt;
&lt;p&gt;Hoewel een fluent interface qua functionaliteit niets toevoegt ziet de code er een stuk overzichtelijker uit. Op &amp;lt;a target="_blank" href="http://en.wikipedia.org/wiki/Fluent_interface"&amp;gt;wikipediavind je heldere voorbeelden hoe je in verschillende talen een fluent interface kan maken. Ik zal hier dan ook niet verder op ingaan.&lt;/p&gt;
&lt;h2&gt;Fluent interfaces in views&lt;/h2&gt;
&lt;p&gt;Binnen Webpirates gebruiken we fluent interfaces met name in views en templates. Views bevatten voornamelijk html en verschillende helperobjecten om eenvoudig html te genereren op basis van data die aan de view toegewezen is. De helpers lenen zich dan ook uitstekend voor fluent interfaces. In php templates gebruiken wij bijvoorbeeld een helper voor het opbouwen van een dropdown list:&lt;/p&gt;
&lt;pre class="brush:php; toolbar: false;"&gt;echo SysViewHelperDropdown::create('balls')
  -&amp;gt;setDropdownItems( 
    array(    
      '1' =&amp;gt; 'Voetbal', 
      '2' =&amp;gt; 'Basketbal', 
      '3' =&amp;gt; 'Tennisbal'))
  -&amp;gt;setSelected(2)
  -&amp;gt;setClass('timebox');&lt;/pre&gt;
&lt;p&gt;Voor ASP.NET MVC hebben we een HtmlHelper ontwikkeld waarmee eenvoudig en snel een grid (jqGrid) gegenereerd kan worden. De interface ziet er dan bijvoorbeeld zo uit:&lt;/p&gt;
&lt;pre class="brush:csharp; toolbar: false;"&gt;&amp;lt;%= Html.Grid("basic")
            .addColumn(new Column("CustomerId")
              .setLabel("Customer ID"))
            .addColumn(new Column("FirstName")
              .setWidth(500))
            .setUrl("/Home/GridData/")
            .setPager("pager")
            .setAutoWidth(true)
            .setViewRecords(true)
            %&amp;gt;&lt;/pre&gt;
&lt;p&gt;Fluent interfaces maken object interfaces beter leesbaar en makkelijk hanteerbaar. De meerwaarde van fluent interfaces komt vooral tot z'n recht als binnen het object nieuwe objecten aangemaakt kunnen worden, zoals nieuwe kolommen in het grid voorbeeld. De code wordt dan aanzienlijker korter en overzichtelijker.&lt;/p&gt;</description><pubDate>Tue, 23 Oct 2012 22:36:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/fluent-interfaces-in-views-en-templates</guid></item><item><title>Sitefinity CMS</title><link>http://metdepuntnaarvoren.nl:80/sitefinity-cms</link><description>&lt;summary&gt;Om opdrachtgevers in staat te stellen hun eigen website te beheren, zet Webpirates op dit moment Joomla of intern ontwikkelde content management systemen in. Deze systemen zijn momenteel allemaal ontwikkeld in PHP. Om onze dienstverlening uit te breiden ben ik de afgelopen periode op zoek gegaan naar een CMS dat gebaseerd is op ASP.NET.&lt;/summary&gt;
&lt;p&gt;Het CMS moet aan een aantal vereisten voldoen. In de eerste plaats moet het CMS gebruiksvriendelijk zijn en een breed scala aan functionaliteiten bevatten. Tevens moet het CMS makkelijk uit te breiden en aan te passen zijn door een ontwikkelaar, zodat we dienstverlening op maat kunnen bieden en toch kostenefficiënt blijven.&lt;/p&gt;
&lt;p&gt;Na een aantal systemen uitgeprobeerd te hebben, ben ik uitgekomen op &lt;a href="http://www.sitefinity.com"&gt;Sitefinity&lt;/a&gt; van Telerik. Dit CMS is voor gebruikers uitermate gemakkelijk te bedienen, de standaard installatie bevat legio functionaliteiten en is voor ontwikkelaars makkelijk uit te breiden zonder hiervoor nieuwe technieken te leren.&lt;/p&gt;
&lt;p&gt;Het CMS bevat alle gebruikelijke CMS onderdelen, zoals blogs, news, artikelen, polls en forums maar ook de mogelijkheid om wiki pagina's aan te maken, nieuwsbrieven te versturen en gebruikersgroepen te beheren. De meeste functionaliteiten zijn eenvoudig te gebruiken en in te stellen door de gebruiker. Een korte training of uitleg is voldoende om snel aan de slag te kunnen met Sitefinity. Op de &lt;a href="http://www.sitefinity.com"&gt;website&lt;/a&gt; van Sitefinity is een uitgebreid overzicht van alle features van het systeem te vinden.&lt;/p&gt;
&lt;p&gt;Een aantal punten waarmee Sitefinity zich onderscheid van andere content management systemen wil ik in dit artikel uitlichten. Ten eerste bevat Sitefinity ondersteuning voor meerdere talen. Gebruikers kunnen zelf teksten in verschillende talen opslaan, zonder dat voor elke taal een nieuwe pagina aangemaakt hoeft te worden.&lt;/p&gt;
&lt;p&gt;Sitefinity heeft een uitgebreid versiebeheersysteem ingebouwd. Hiermee kunnen meerdere versies van content opgeslagen en bekeken worden. Grootste voordeel hiervan is dat gemaakte aanpassingen met één klik weer teruggedraaid kunnen worden en inzichtelijk is wie welke aanpassingen heeft doorgevoerd.&lt;/p&gt;
&lt;p&gt;Naast versiebeheer bevat Sitefinity een systeem waarmee alle nieuwe en aangepaste content eerst goedgekeurd moet worden door de daartoe bevoegde personen om gepubliceerd te worden. Vooral in ondernemingen waar meerdere mensen bijdragen leveren aan de inhoud van de website is dit een veel gevraagde optie.&lt;/p&gt;
&lt;p&gt;Telerik stelt dat Sitefinity eenvoudig uit te breiden is door ontwikkelaars. Om dit te testen heb ik een kleine Twitter module geschreven waarmee de laatste tweets van een in te stellen gebruiker op de site worden weergegeven. En inderdaad, binnen enkele minuten had ik al een eerste werkende versie. Sitefinity gebruikt technieken die voor elke ASP.NET ontwikkelaar bekend zijn zoals masterpages en user controls. Nieuwe technieken hoeven dus niet te worden aangeleerd om nieuwe functionaliteiten toe te voegen aan Sitefinity.&lt;/p&gt;
&lt;p&gt;Sitefinity was tot voor kort beschikbaar als community edition die gratis te downloaden was. Helaas is dit project stop gezet en is alleen de professionele editie nog beschikbaar. De kosten van het CMS bedragen $900,- per domein, dit is relatief goedkoop in vergelijking tot andere commerciële pakketten.&lt;/p&gt;
&lt;p&gt;Grootste minpunt tot nu toe is de installatieprocedure. Het heeft mij zeker een halve dag gekost om Sitefinity aan de praat te krijgen. Belangrijkste les was om vooral niet de meegeleverde installer te gebruiken, maar de installatie handmatig uit te voeren.&lt;/p&gt;
&lt;p&gt;Al met al ben ik erg enthousiast over de mogelijheden die Sitefinity biedt, het gebruiksgemak en de eenvoudige wijze waarop ontwikkelaars functionaliteit toe kunnen voegen. Wilt u meer weten over Sitefinity of de diensten die wij op dit product bieden? Of wilt u een demonstratie van de mogelijkheden? Neem dan gerust contact met ons op, wij helpen u graag verder!&lt;/p&gt;</description><pubDate>Tue, 23 Oct 2012 22:31:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/sitefinity-cms</guid></item><item><title>Software design principles</title><link>http://metdepuntnaarvoren.nl:80/software-design-principles</link><description>&lt;blockquote&gt;“It is one thing to write code that works. It is quite another to write &lt;span style="text-decoration: underline;"&gt;good&lt;/span&gt; code that works” &lt;small&gt;&lt;cite title="Source Title"&gt;Dino Esposito (2009)&lt;/cite&gt;&lt;/small&gt;&lt;/blockquote&gt;
&lt;summary&gt;Eén van mijn persoonlijke doelen met betrekking tot Webpirates is om de bestaande technische kennis en vaardigheden binnen Webpirates vast te leggen, te delen en te vergroten. In dit kader zal ik regelmatig een artikel schrijven die één of meerdere aspecten belicht van het software-ontwikkelproces. Dit artikel geeft een overzicht van software design principes die in de loop der jaren industriestandaarden zijn geworden en door elke programmeur gekend en toegepast zouden moeten worden.&lt;/summary&gt;

&lt;p style="text-align: center;"&gt;&lt;img src="/Media/Default/Images/softwaredesign.jpeg"  /&gt;&lt;/p&gt;
&lt;h2&gt;Het draait allemaal om aanpasbaarheid&lt;/h2&gt;
&lt;p&gt;Goed geschreven software voldoet niet alleen aan de eisen die vandaag gesteld zijn, maar houdt ook rekening met de gevraagde aanpassingen en toevoegingen van morgen. Het is dus van belang dat de ontwikkelaar zijn of haar code zo ontwerpt dat deze in een later stadium relatief eenvoudig aan te passen is.&lt;br /&gt; Tijdens het ontwerp van de applicatie zijn de aanpasbaarheid en onderhoudbaarheid van de applicatie dan ook de belangrijkste kwaliteitskenmerken voor een ontwikkelaar. Al het andere kan later ingepast worden, als de applicatie maar eenvoudig aan te passen is. Vaak wordt gesteld dat wisselende requirements de oorzaak zijn van slecht geschreven software, dat door alle veranderingen de code onbeheersbaar wordt. Dit is pertinent onjuist. Het is aan de ontwikkelaar om ervoor te zorgen dat zijn software bestand is tegen aanpassingen en uitbreidingen. Wisselende requirements ontmaskeren dus eigenlijk alleen slecht geschreven software en hun auteur.&lt;/p&gt;
&lt;h2&gt;Symptomen van slecht design&lt;/h2&gt;
&lt;p&gt;Slecht geschreven software is slecht bestand tegen veranderingen. Robert C. Martin (2000) formuleert slecht design als volgt: Software die voldoet aan de opgegeven requirements maar aan één of meer van de volgende symptomen lijdt is slecht ontworpen:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;Rigiditeit:&lt;/span&gt; Elke verandering zorgt voor teveel aanpassingen in andere delen van het systeem.&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;Fragiliteit:&lt;/span&gt; Wanneer een aanpassing doorgevoerd wordt, gaan andere delen van het systeem onverwacht kapot.&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;Immobiliteit:&lt;/span&gt; Lastig om code te hergebruiken in een andere applicatie omdat teveel afhankelijkheden met de huidige applicatie bestaan.&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;Viscositeit:&lt;/span&gt; Makkelijker om omwegen in de software te bouwen dan daadwerkelijk problemen in de software op te lossen.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;High Cohesion, Low Coupling&lt;/h2&gt;
&lt;p&gt;De beste strategie om software makkelijk aanpasbaar te maken is door het systeem op te delen in losse componenten, high cohesion en loose coupling zijn hierbij de uitgangspunten.&lt;br /&gt; Cohesion geeft de mate aan waarin de verschillende functionaliteiten van een component met elkaar gerelateerd zijn. Hoe meer cohesie hoe beter. In de praktijk betekent dit het gebruik van sterk gespecialiseerde classes met meestal weinig methodes. Met de groei van het aantal functionaliteiten van een class groeit ook het aantal afhankelijkheden van andere classes, dit staat aanpassingen in de software in de weg. Coupling geeft de mate van afhankelijkheid tussen de verschillende componenten aan. Hoe minder afhankelijkheden hoe beter. Dit maakt de code makkelijker te onderhouden, leesbaarder, eenvoudiger om te testen en verkleint tevens de mate van fragiliteit en rigiditeit van het systeem.&lt;/p&gt;
&lt;h2&gt;Separation of Concerns&lt;/h2&gt;
&lt;p&gt;Separation of Concerns (SoC) ( geïntroduceerd door Edsger W. Dijkstra, 1974) is een principe dat helpt loose coupling en high cohesion te bereiken. Het toepassen van SoC betekent het opdelen van een systeem in delen die elkaar zo min mogelijk overlappen, elk deel heeft zijn eigen verantwoordelijkheid.&lt;br /&gt; SoC wordt concreet bereikt door code modulair op te stellen, de interne werking van de modules af te schermen (encapsulation), en alleen te communiceren via publieke interfaces. Op deze manier kunnen veranderingen in de interne werking van modules plaats vinden, zonder dat andere modules hiervoor aangepast dienen te worden aangezien de interface gelijk blijft.&lt;br /&gt; In de praktijk zie je toepassingen van SoC overal, in procedurele talen worden procedures en functies gebruikt voor het scheiden van de verschillende aspecten van een systeem, in object georiënteerde talen worden classes gebruikt. Architecturen zoals MVC bereiken SoC door het opdelen van systemen in meerdere logische lagen elk met hun eigen vooraf gedefinieerde verantwoordelijkheden.&lt;/p&gt;
&lt;h2&gt;Object Oriented Programming (OOP)&lt;/h2&gt;
&lt;p&gt;Object georiënteerde programmeertalen voorzien de ontwikkelaar van de benodigde gereedschappen en technieken om een systeem op te delen in een groot aantal losse onderdelen (objecten). Door de jaren heen zijn een aantal industrie standaarden ontstaan op het gebied van OOP die algemeen toepasbaar zijn op elke object georiënteerde programmeertaal.&lt;br /&gt; Ik bespreek eerst de basis principes van OOP en vervolgens een aantal meer geavanceerde principes die vallen onder de noemer S.O.L.I.D. principles gebundeld door Robert C. Martin.&lt;/p&gt;
&lt;h2&gt;Basis OOP principes&lt;/h2&gt;
&lt;p&gt;Hét standaardwerk op het gebied van OOP is het boek van the Gang of Four (GoF) ‘Design Patterns: Elements of Reusable Object-Oriented Software’. GoF vat object georiënteerd design als volgt samen:&lt;/p&gt;
&lt;p style="font-style: italic;"&gt;'You must find pertinent objects, factor them into classes at the right granularity, define class interfaces and inheritance hierarchies, and establish key relationships among them. Your design should be specific to the problem at hand, but also general enough to address future problems and requirements.'&lt;/p&gt;
&lt;p&gt;Het identificeren van pertinente objecten gebeurt meestal door de requirements en/of use-cases af te speuren naar zelfstandige naamwoorden en werkwoorden. Zelfstandige naamwoorden representeren vaak objecten of eigenschappen van objecten, werkwoorden zijn vaak methoden van objecten. Voorbeeld:&lt;/p&gt;
&lt;p&gt;“De &lt;span style="font-weight: bold;"&gt;gebruiker&lt;/span&gt; moet een nieuwe &lt;span style="font-weight: bold;"&gt;recipient&lt;/span&gt; &lt;span style="font-style: italic;"&gt;toe kunnen voegen&lt;/span&gt; aan de &lt;span style="font-weight: bold;"&gt;mailinglist&lt;/span&gt;.”&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight: bold;"&gt;Objecten&lt;/span&gt;: Gebruiker, Recipient, Mailinglist&lt;br /&gt; &lt;span style="font-style: italic;"&gt;Methode&lt;/span&gt;: AddRecipient&lt;/p&gt;
&lt;p&gt;Belangrijk om te realiseren bij het identificeren van objecten is het feit dat objecten ‘dingen’ representeren géén processen. Processen zijn de interacties tussen de verschillende objecten. Hierin verschilt OOP dus fundamenteel met procedurele programmeertalen.&lt;/p&gt;
&lt;p&gt;Twee basisprincipes worden door GoF naar voren gebracht:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Program to an interface, not an implementation&lt;/li&gt;
    &lt;li&gt;Favor object composition over class inheritance&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Het eerste principe wijst op het gebruik van interfaces om de verschillende objecten met elkaar te laten communiceren. Zoals eerder uitgelegd zorgt het gebruik van interfaces voor een minder sterke koppeling tussen de verschillenden objecten en biedt hierdoor een verhoogde weerbaarheid tegen toekomstige aanpassingen.&lt;/p&gt;
&lt;p&gt;De volgende code laat een class zien die sterk gekoppeld is met de class Logger:&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;class CoupledObject
{
  public void DoSomething()
  {
    Logger logger = new Logger();
   
    // Do something...
    logger.log("Log this!");
  }
}&lt;/pre&gt;
&lt;p&gt;De volgende code laat zien dat het gebruik van een interface zorgt voor loose coupling:&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;class DeCoupledObject
{
  public void DoSomething()
  {
    ILogger logger = LogHelper.getLogger();
    
    // Do something...
     
    logger.log("Log this!");
  }
}&lt;/pre&gt;
&lt;p&gt;De LogHelper class stelt een class beschikbaar die de interface ILogger implementeert. De helper class kan nu dus elke class ter beschikking stellen zolang deze class maar de ILogger interface implementeert. Welke class wordt aangeboden kan bijvoorbeeld worden bepaald door een configuratiebestand uit te lezen. De helper class wordt in dit geval ook wel een factory object genoemd, een producent van classes.&lt;/p&gt;
&lt;p&gt;Het tweede principe, 'favor object composition over class inheritance', geeft aan dat overerving van classes niet altijd de beste methode is om code te hergebruiken. Dit wordt echter wel vaak aangedragen als een voordeel van object georiënteerd programmeren. Afgeleide classes kunnen kapot gaan door toekomstige veranderingen in het basis type dat overerft wordt. Tevens dienen afgeleide classes zo gebouwd te worden dat elke plaats waar het basis type ingezet kan worden, ook het afgeleide type kan worden gebruikt. Dit is in de praktijk lang niet altijd het geval, omdat bestaande functionaliteiten van het basis type overschreven of aangepast worden, en niet meer bruikbaar zijn in de context van het basis type. (zie ook Liskov’s Substitution Principle)&lt;br /&gt; Overerving dient eigenlijk alleen gebruikt te worden als er alleen nieuwe methoden aan een class worden toegevoegd. Compositie is meestal een veiligere oplossing voor het hergebruiken van code. Met behulp van compositie creëer je een nieuw type (class) die een instantie van het basis type bevat. Het basis type wordt nooit rechtstreeks aangesproken, maar is een private member. Het compositie object heeft nooit toegang tot de interne delen van de basis class en kan het gedrag dus niet veranderen. Het compositie object is in feite een wrapper en delegeert waar nodig alle aanroepen naar het basis type en voegt zelf functionaliteiten toe. Voorbeeld:&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;class CompositeClass
{
  private BaseClass baseClass;
  public CompositeClass()
  {
    baseClass = new BaseClass();
  }
   
  public void DoSomeWork()
  {
    baseClass.DoSomeWork();
   
    // Add extra code here..
  }
}&lt;/pre&gt;
&lt;p&gt;Als we nu beide principes zouden willen combineren moeten we eigenlijk het interne basis object niet rechtstreeks aanspreken, maar vervangen door een interface.&lt;/p&gt;
&lt;h2&gt;SOLID OOP principes&lt;/h2&gt;
&lt;p&gt;Naast de basisprincipes beschreven door de Gang of Four bestaan er nog een aantal geavanceerde principes, de belangrijkste zijn gebundeld door Robert C. Martin, genaamd de SOLID principles:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;S&lt;/span&gt;ingle Responsibility Principle: There should never be more than one reason for a class to change. (Robert C. Martin, 1996) Wanneer een class meerdere verantwoordelijkheden heeft, bestaan er meerdere redenen om een class aan te passen (lage cohesie). Dit geeft een koppeling tussen de verschillende verantwoordelijkheden, wat leidt tot rigiditeit en fragiliteit van een applicatie.&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;O&lt;/span&gt;pen Closed Principle: A module should be open for extension but closed for modification (Bertrand Meyer, 1988). Dit betekent dat de source code van een module nooit aangepast wordt, maar altijd d.m.v. overerving of compositie wordt aangepast. In de praktijk is het meestal de interface die niet aangepast wordt.&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;L&lt;/span&gt;iskov’s Subtitution Principle: Subclasses should be substitutable for their base classes. (Barbara Liskov, 1994). Een afgeleide class zou altijd ingezet moet kunnen worden waar hun basis class ook kan worden ingezet. Eerder is al gezegd dat dit niet altijd het geval is, compositie is dan op zijn plaats.&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;I&lt;/span&gt;nterface Segregation Principle: Clients should not be forced to depend on methods that they do not use. (Robert C. Martin, 1996). Interfaces van een class zouden cohesive moeten zijn, gegroepeerd naar functionaliteiten. Wanneer dit niet het geval is, deel dan de interfaces op in verschillende delen. In het geval van een ‘fat interface’ zou elke class die deze interface implementeert alle methoden moeten implementeren, inclusief de methoden die hij niet gebruikt.&lt;/li&gt;
    &lt;li&gt;&lt;span style="font-weight: bold;"&gt;D&lt;/span&gt;ependency Inversion Principle: High-level modules should not depend upon low-level modules. Both should depend on abstractions. Abstractions should not depend upon details. Details should depend upon abstractions. (Robert C. Martin, 1996). Kort gezegd zouden high-level modules niet afhankelijk mogelijk zijn van één of meerdere low-level modules. Het volgende voorbeeld geeft een nieuwsbrief module aan die afhankelijk is van een low-level module om de nieuwsbrief te versturen:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="brush:csharp"&gt;class NewsLetter
{
  public void SendNewsLetter(string Email)
  {
    IMailer mailer = Helper.getMailer();
    mailer.send(this, Email);
  }
}&lt;/pre&gt;
&lt;p&gt;Om de afhankelijkheid op te heffen, kunnen de low-level modules worden geïnjecteerd in de constructor van de high-level module:&lt;/p&gt;
&lt;pre class="brush:csharp"&gt;class NewsLetter
{
  private IMailer mailer = null;
   
  public NewsLetter(IMailer mailer)
  {
    this.mailer = mailer;
  }
   
  public void SendNewsLetter(string Email)
  {
    this.mailer.send(this, Email);
  }
}&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Conclusie&lt;/h2&gt;
&lt;p&gt;De belangrijkste les die getrokken moet worden is het feit dat software ontworpen moet worden met het oog op toekomstige aanpassingen en toevoegingen. Alle principes beschreven in dit artikel bevorderen de flexibiliteit van een applicatie en verhogen hiermee de weerbaarheid tegen veranderingen.&lt;br /&gt; Naast design principles bestaan er ook talloze design patterns die helpen bij het oplossen van bekende design problemen en zorg dragen voor een minimaal aantal afhankelijkheden in de code. Patterns zijn bewust niet genoemd in dit artikel aangezien patterns meestal toegepast worden op specifieke probleemgebieden, terwijl de design principes genoemd in dit artikel algemeen toepasbaar zijn.&lt;/p&gt;
&lt;h2&gt;Gebruikte literatuur:&lt;/h2&gt;
&lt;p&gt;Microsoft .NET: Architecting Applications for the Enterprise, Dino Esposito et al, 2009.&lt;br /&gt; Design Principles and Design Patterns, Robert C. Martin, www.objectmentor.com, 2000.&lt;br /&gt; The Single Responsibility Principle, Robert C. Martin, www.objectmentor.com, 1996.&lt;br /&gt; The Open-Closed Principle, Robert C. Martin, www.objectmentor.com, 1996.&lt;br /&gt; The Liskov Substitution Principle, Robert C. Martin, www.objectmentor.com, 1996.&lt;br /&gt; The Interface Segregation Principle Principle, Robert C. Martin, www.objectmentor.com, 1996.&lt;br /&gt; The Dependency Inversion Principle, Robert C. Martin, www.objectmentor.com, 1996.&lt;br /&gt; Patterns of Enterprise Application Architecture, Martin Fowler, 2003.&lt;br /&gt; ASP.NET MVC Framework Unleashed, Stephen Walter, 2009.&lt;/p&gt;</description><pubDate>Tue, 23 Oct 2012 22:22:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/software-design-principles</guid></item><item><title>Mindmapping met Bubbl.us</title><link>http://metdepuntnaarvoren.nl:80/mindmapping-met-bubbl.us</link><description>&lt;summary&gt;&lt;p&gt;Op &lt;a href="http://www.lifehacking.nl"&gt;lifehacking.nl&lt;/a&gt; kwam ik de term mindmapping een aantal weken geleden voor het eerst tegen. Mindmapping is een methode om je gedachten en/of ideeën over een bepaald onderwerp in kaart te brengen&lt;/p&gt;&lt;/summary&gt;

&lt;blockquote&gt;&lt;p&gt;A mind map is a diagram used to represent words, ideas, tasks, or other items linked to and arranged around a central key word or idea. Mind maps are used to generate, visualize, structure, and classify ideas, and as an aid in study, organization, problem solving, decision making, and writing.&lt;/p&gt;&lt;small class="pull-right"&gt;&lt;a href="http://en.wikipedia.org/wiki/Mindmapping"&gt;Wikipedia &lt;cite title="Source Title"&gt;Mindmapping&lt;/cite&gt;&lt;/a&gt;&lt;/small&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;De methode intrigeerde mij direct aangezien ik al langere tijd op zoek ben naar een manier om gedachten over bepaalde onderwerpen snel vast te kunnen leggen, te kunnen ordenen en makkelijk terug te kunnen vinden. De onderwerpen waar je een mindmap van kan maken zijn zeer uiteenlopend: Het ontwerp van een nieuw software product, het opstellen van een offerte, de inrichting van een huis of gedachten over een blog artikel zoals deze. Kortom alles wat je maar kan bedenken.&lt;/p&gt;
&lt;p&gt;Na wat zoeken vond ik een aantal tools die je helpen om deze mindmaps te maken. Belangrijk criterium is dat de mindmaps snel en eenvoudig te creëren zijn, je bent aan het brainstormen en je wil niet dat je tijd en focus verspeelt aan een applicatie. Eén tool heeft mijn hart gestolen:Bubbl.us&lt;/p&gt;
&lt;p&gt;Bubbl.us is een webapplicatie die gebruik maakt van de mogelijkheden van Adobe Flash en is kinderlijk eenvoudig in gebruik, je kan direct beginnen met het maken van een mindmap. Je begint met één ballonnetje, en met behulp van de enter en tab toets maak je respectievelijk childs en siblings aan. Voor het opslaan van je hersenspinsels dien je een account aan te maken. Totale kosten: noppes.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;img src="/Media/Default/Images/bubblus-mindmap-blog-post.jpg"  /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Het feit dat Bubbl.us een webapplicatie is heeft als voordeel dat je de applicatie altijd en overal kan gebruiken, mits je een internetverbinding hebt natuurlijk. Ook staan al je eerdere zielenroerselen altijd ‘in the cloud’ op je te wachten. Tevens is het mogelijk bepaalde mindmaps te delen met anderen, dit maakt het mogelijk om online te brainstormen!&lt;/p&gt;
&lt;p&gt;Ik heb Bubbl.us de afgelopen weken gebruikt voor een aantal projecten, puur om mijn gedachten op een rijtje te zetten. Tot nu toe is het voor mij een efficiënte manier om mijn gedachten snel vast te leggen en te ordenen. Het leuke is dat je snel al je gedachten neer kan plempen en in een later stadium orde in de chaos kan aanbrengen. Het geeft een goed houvast gedurende het project en nieuwe ideeën en inzichten zijn snel ingepast en vastgelegd.&lt;/p&gt;
&lt;p&gt;Bubbl.us is geheel gratis, vergeet daarom niet een klein bedrag te doneren als teken van dankbaarheid als je de tool echt gaat gebruiken. Dit kan eenvoudig met behulp van Paypal.&lt;/p&gt;
&lt;p&gt;Overigens: Pen en papier zijn ook geweldige gereedschappen voor een mindmap ;)&lt;/p&gt;</description><pubDate>Sun, 21 Oct 2012 15:03:00 GMT</pubDate><guid isPermaLink="true">http://metdepuntnaarvoren.nl:80/mindmapping-met-bubbl.us</guid></item></channel></rss>