Skip to content

Commit

Permalink
(GH-27) Remove comment attribute
Browse files Browse the repository at this point in the history
This is no longer required when using Wyam.
  • Loading branch information
gep13 committed Mar 14, 2020
1 parent cba06d7 commit c63ade3
Show file tree
Hide file tree
Showing 113 changed files with 444 additions and 557 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-02-01 18:43:00+00:00
layout: post
slug: adnuguk-january-2011-meeting-completed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-02-02 21:41:00+00:00
layout: post
slug: writing-testable-validation-code-using-dependency-injection
Expand All @@ -17,47 +16,47 @@ tags:

**This article was submitted to the Aberdeen Developers .Net User Group by Norman Noble.**

The idea for writing this came about when I was discussing [ASP.Net MVC](http://www.asp.net/mvc) (Model View Controller) with an old friend Dave about a week ago. I was having a look at Microsofts latest version having briefly looked at MVC when it first came out with version 3.5 of the .Net Framework. Daves company had just successfully released their first commercial application written entirely in MVC and I was keen to hear his thoughts on things that he knew now that he wished hed known at the start of the project. Dave told me that in the start they had followed the [NerdDinner tutorial](http://nerddinnerbook.s3.amazonaws.com/Intro.htm) and had adopted the patterns used by the tutorial. He also told me that he was particularly impressed with the way that the tutorial had handled its validation code and that they saw that as the way forward. I decided that the best way to get back into this stuff was as ever to start cutting some code.
The idea for writing this came about when I was discussing [ASP.Net MVC](http://www.asp.net/mvc) (Model View Controller) with an old friend Dave about a week ago. I was having a look at Microsoft's latest version having briefly looked at MVC when it first came out with version 3.5 of the .Net Framework. Dave's company had just successfully released their first commercial application written entirely in MVC and I was keen to hear his thoughts on things that he knew now that he wished he'd known at the start of the project. Dave told me that in the start they had followed the [NerdDinner tutorial](http://nerddinnerbook.s3.amazonaws.com/Intro.htm) and had adopted the patterns used by the tutorial. He also told me that he was particularly impressed with the way that the tutorial had handled its validation code and that they saw that as the way forward. I decided that the best way to get back into this stuff was as ever to start cutting some code.

The tutorial is easy enough to follow and is very good at explaining the basics of MVC so if MVC is something you are interested in I would thoroughly recommend going through the tutorial. It will give you all you need to get going ([Stack Overflow](http://stackoverflow.com/) can fill in the rest). One of the fundamental advantages MVC provides over standard ASP.Net development is that it makes your code easier to test. By testing I mean proper unit testing using a Framework like [NUnit](http://www.nunit.org/) or Visual Studios inbuilt MSTest. If youre new or have limited experience in writing unit tests I would recommend reading [the art of UNIT TESTING](http://artofunittesting.com/) by Roy Osherove. Its an excellent read with lots of really useful tips based on the experience of both failed and successful projects. When it comes to unit testing and [TDD](http://en.wikipedia.org/wiki/Test-driven_development) Roy really knows what he is talking about.
The tutorial is easy enough to follow and is very good at explaining the basics of MVC so if MVC is something you are interested in I would thoroughly recommend going through the tutorial. It will give you all you need to get going ([Stack Overflow](http://stackoverflow.com/) can fill in the rest). One of the fundamental advantages MVC provides over standard ASP.Net development is that it makes your code easier to test. By testing I mean proper unit testing using a Framework like [NUnit](http://www.nunit.org/) or Visual Studios inbuilt MSTest. If you're new or have limited experience in writing unit tests I would recommend reading [the art of UNIT TESTING](http://artofunittesting.com/) by Roy Osherove. It's an excellent read with lots of really useful tips based on the experience of both failed and successful projects. When it comes to unit testing and [TDD](http://en.wikipedia.org/wiki/Test-driven_development) Roy really knows what he is talking about.

Getting back to the MVC tutorial, I followed it through section by section and eventually arrived at the section on validation. I was quite keen to see what was suggested as Dave had been particularly enthusiastic about how this example handled it. I was slightly disappointed to find that the validation was some simple schema based validation using partial classes on the existing LINQ to SQL classes. To give the article some credit it does explain quite thoroughly that schema based validation is not the greatest and should only be used in the simplest of cases where there are little or no business rules to be applied. You can see a full example of Schema based validation in [part 3](http://nerddinnerbook.s3.amazonaws.com/Part3.htm) of the tutorial.

A basic example looks something like this:

[![876f59b7-2636-4af8-b201-0447ad4fd6c0](http://www.aberdeendevelopers.co.uk/wp-content/uploads/876f59b7-2636-4af8-b201-0447ad4fd6c0_thumb.png)](http://www.aberdeendevelopers.co.uk/wp-content/uploads/876f59b7-2636-4af8-b201-0447ad4fd6c0.png)


<span class="kwrd">partial</span> <span class="kwrd">class</span> Customer
{
<span class="kwrd">public</span> <span class="kwrd">bool</span> IsValid()
{
<span class="kwrd">bool</span> isValid = <span class="kwrd">true</span>;

<span class="kwrd">if</span> (Age < 18)
{
isValid = <span class="kwrd">false</span>;
}

<span class="kwrd">return</span> isValid;
}
}


This got me to thinking about what I didnt like about this particular method of performing validation and more importantly how Id prefer to see it being done. In my opinion most validation is part of the business rules of a system and as such should be stored in the Business Layer of the application. Also having the validation in the Data Access Layer creates a dependency on the Data Store when creating unit tests which prevent your tests from being fully robust and subject to change should the data in the data store change.
This got me to thinking about what I didn't like about this particular method of performing validation and more importantly how I'd prefer to see it being done. In my opinion most validation is part of the business rules of a system and as such should be stored in the Business Layer of the application. Also having the validation in the Data Access Layer creates a dependency on the Data Store when creating unit tests which prevent your tests from being fully robust and subject to change should the data in the data store change.

A test for the code above may look something like:


[TestMethod]
<span class="kwrd">public</span> <span class="kwrd">void</span> Customer_Over18_IsValid()
{
<span class="rem">//Arrange</span>
Customer cs = CustomerRepository.GetCustomer(1);

<span class="rem">//Act</span>
<span class="kwrd">bool</span> isValid = cs.IsValid();

<span class="rem">//Assert</span>
Assert.IsTrue(isValid);
}
Expand All @@ -69,18 +68,18 @@ The way I prefer to get round this is to create a validation class for each Enti

A basic example of this would be:


<span class="kwrd">public</span> <span class="kwrd">class</span> CustomerValidator : ICustomerValidator
{
<span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> IsValid(Customer cs)
{
<span class="kwrd">bool</span> isValid = <span class="kwrd">true</span>;

<span class="kwrd">if</span> (cs.Age < 18)
{
isValid = <span class="kwrd">false</span>;
}

<span class="kwrd">return</span> isValid;
}
}
Expand All @@ -90,21 +89,21 @@ This method completely seperates the validation code from any dependencies as th

A test for the code above would look something like this:


[TestMethod]
<span class="kwrd">public</span> <span class="kwrd">void</span> Customer_Over18_IsValid()
{
<span class="rem">//Arrange</span>
StubCustomer scs = <span class="kwrd">new</span> StubCustomer(<span class="str">"Norman"</span>, <span class="str">"Aberdeen"</span>, 31);

<span class="rem">//Act</span>
<span class="kwrd">bool</span> isValid = CustomerValidator.IsValid(scs);

<span class="rem">//Assert</span>
Assert.IsTrue(isValid);
}


In the example above the StubCustomer class has been created which has the Customer class as a base class. As the creation of the item under test is now controlled the unit test is far more robust and is only concerned with the functionality it is supposed to be testing. Therefore the only thing that will break this test is a change in the functionality of Customer which is what you would expect.

There are variations of the example above. For instance you may prefer to inject the dependency through a property setter instead. The above example is simply the way I prefer to do it.
There are variations of the example above. For instance you may prefer to "inject" the dependency through a property setter instead. The above example is simply the way I prefer to do it.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-02-20 18:38:00+00:00
layout: post
slug: feedback-from-functional-programming-talk
Expand Down
1 change: 0 additions & 1 deletion input/blog/2011-02-20-press-and-journal-article.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-02-20 18:20:00+00:00
layout: post
slug: press-and-journal-article
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: adnuguk
comments: true
date: 2011-04-27 19:03:53+00:00
layout: post
slug: job-aberdeenaberdeenshire-area
Expand All @@ -17,6 +16,6 @@ tags:

Through the [Aberdeen Developers website](http://www.aberdeendevelopers.co.uk/) I have been made aware of a job vacancy in the Aberdeen area.

The role will be as a software developer working on a brand new browser based product.  In the short term, a prospective candidate would benefit from having some Delphi knowledge in order to work with some existing software.  In addition, it would be beneficial if the candidate lived in the Aberdeen/Aberdeenshire area.  The position would also ideally suit someone who has, or is, working on their own concept and wants to be a start up, and is looking for some cash injection, as this type of investment is available.
The role will be as a software developer working on a brand new browser based product.  In the short term, a prospective candidate would benefit from having some Delphi knowledge in order to work with some existing software.  In addition, it would be beneficial if the candidate lived in the Aberdeen/Aberdeenshire area.  The position would also ideally suit someone who has, or is, working on their own concept and wants to be a "start up", and is looking for some cash injection, as this type of investment is available.

If you are interested in the position and would like some more information, then please feel free to contact Peter Gillian on pjg at skylark dot co dot uk, or you can call him on 01330 823950.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-06-02 19:02:00+00:00
layout: post
slug: adnuguk-may-2011-meeting-completed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-07-08 19:00:00+00:00
layout: post
slug: adnuguk-july-2011-meeting-completed
Expand Down
1 change: 0 additions & 1 deletion input/blog/2011-08-10-adnuguk-august-2011-meeting.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-08-10 18:57:00+00:00
layout: post
slug: adnuguk-august-2011-meeting
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-08-20 18:56:00+00:00
layout: post
slug: adnuguk-september-2011-meeting
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-09-01 18:54:00+00:00
layout: post
slug: adnuguk-october-2011-meeting
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-09-18 13:43:00+00:00
layout: post
slug: adnuguk-august-2011-meeting-completed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-09-21 20:42:00+00:00
layout: post
slug: consultant-job-opportunity-aberdeen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-09-21 20:49:21+00:00
layout: post
slug: windows-developer-required-aberdeen
Expand All @@ -16,24 +15,24 @@ tags:

An ADNUGUK Member has informed me about a vacancy for a Windows Developer looking for a change of career, or indeed someone wishing to create a start up and needs a business partner.



For the Windows Developer role, the following skills would be required.



Knowledge of:






* Windows Folders

* RTF Files

* HTML

* Outlook


If you are interested in the position and would like some more information, then please feel free to contact Peter Gillian on pjg at skylark dot co dot uk, or you can call him on 01330 823950.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-10-01 14:43:25+00:00
layout: post
slug: adnuguk-september-2011-meeting-completed
Expand All @@ -16,16 +15,16 @@ tags:
- Web Sockets
---

On Thursday 29th September 2011, the Aberdeen Developers .Net User Group was fortunate enough to welcome [Phil Leggetter](http://www.leggetter.co.uk/) ([@leggetter](http://twitter.com/#!/leggetter)) of [Pusher](http://pusher.com/) to do a talk entitled “[Why the realtime web isn't just another buzz phrase and why we should give a tweet](http://adnuguk-sep.eventbrite.com/)
On Thursday 29th September 2011, the Aberdeen Developers .Net User Group was fortunate enough to welcome [Phil Leggetter](http://www.leggetter.co.uk/) ([@leggetter](http://twitter.com/#!/leggetter)) of [Pusher](http://pusher.com/) to do a talk entitled "[Why the realtime web isn't just another buzz phrase and why we should give a tweet](http://adnuguk-sep.eventbrite.com/)"




If you were not able to attend the session you can find the slide deck that was used during the presentation [here](http://www.leggetter.co.uk/pusher/presentations/adnuguk_2011-09-29/why_the_realtimeweb_matters.html#7).



In addition, if you have any comments that you would like to make about the presentation, Phil has set up a feedback section on SpeakerRate, which you can find [here](http://speakerrate.com/talks/8484-why-the-realtime-web-matters). As always, feedback for these events is always welcome, and I would strongly encourage everyone to provide feedback.



If you have any other comments/suggestions about the User Group, then feel free to get in touch with me via my [blog](http://www.gep13.co.uk/blog/), or using the [contact page](http://www.aberdeendevelopers.co.uk/contact.aspx).
7 changes: 3 additions & 4 deletions input/blog/2011-10-03-typemock-unit-testing-webinar.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-10-03 11:53:00+00:00
layout: post
slug: typemock-unit-testing-webinar
Expand All @@ -16,13 +15,13 @@ tags:
- Unit Testing
---

In case you hadnt heard about it, Typemock are hosting a webinar entitled Tips for Easy Unit Testing: Dealing with Legacy Code – Part II. In this webinar you will learn:
In case you hadn't heard about it, Typemock are hosting a webinar entitled "Tips for Easy Unit Testing: Dealing with Legacy Code – Part II". In this webinar you will learn:

* Common problems with unit testing, and how to solve them
* Applying unit testing patterns to legacy code
* How to turn a real-world legacy code into maintainable code
* How to turn a "real-world" legacy code into maintainable code
* How unit tests help you understand and change code fearlessly
* How to write better unit tests that dont break
* How to write better unit tests that don't break

Registration for this event can be found here:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-10-10 15:26:00+00:00
layout: post
slug: adnuguk-november-2011-meeting
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-10-10 14:41:00+00:00
layout: post
slug: caledonian-code-crusade-featuring-mark-rendle-adnuguk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-10-26 06:14:00+00:00
layout: post
slug: business-partner-opportunity-in-aberdeen
Expand Down
3 changes: 1 addition & 2 deletions input/blog/2011-11-09-gill-cleeren-tour.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-11-09 07:47:00+00:00
layout: post
slug: gill-cleeren-tour
Expand Down Expand Up @@ -39,4 +38,4 @@ What you might not know is that Gill is actually doing 4 events in the UK. They



If you dont get a chance to see him in Aberdeen, you might be able to catch one of the other sessions.
If you don't get a chance to see him in Aberdeen, you might be able to catch one of the other sessions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-11-11 17:52:00+00:00
layout: post
slug: scottish-user-group-events-for-december-2011
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-11-11 17:44:00+00:00
layout: post
slug: scottish-user-group-events-for-november-2011
Expand Down
11 changes: 5 additions & 6 deletions input/blog/2011-11-13-october-2011-meeting-completed.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
author: gep13
comments: true
date: 2011-11-13 11:35:00+00:00
layout: post
slug: october-2011-meeting-completed
Expand All @@ -17,24 +16,24 @@ tags:
- Mark Rendle
---

On Thursday 13th October, Aberdeen Developers .Net User Group welcomed Mark Rendle for two talks entitled “Functional Alchemy: Tricks to keep your C# Dry*”, and “How to manage your manager”. Full details of the event can be found [here](http://adnuguk-oct2011.eventbrite.com/).
On Thursday 13th October, Aberdeen Developers .Net User Group welcomed Mark Rendle for two talks entitled "Functional Alchemy: Tricks to keep your C# Dry*", and "How to manage your manager". Full details of the event can be found [here](http://adnuguk-oct2011.eventbrite.com/).




If you were not able to attend you can see the slides below and you can also download them [here](http://www.aberdeendevelopers.co.uk/Uploads/Meetings/FunctionalAlchemy.pptx), and [here](http://www.aberdeendevelopers.co.uk/Uploads/Meetings/How%20To%20Manage%20Your%20Manager.pptx). In addition, the spread sheet that Mark showed during the presentation can been downloaded [here](http://www.aberdeendevelopers.co.uk/Uploads/Meetings/HTMYM-TimeAndMotion.xlsx) and the code that Mark was using can be found [here](https://github.com/markrendle/functionalalchemy).

### Functional Alchemy: Tricks to keep your C# Dry*

[ ![Get Microsoft Silverlight](http://go.microsoft.com/fwlink/?LinkId=161376) ](http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0)




### How to manage your manager

[ ![Get Microsoft Silverlight](http://go.microsoft.com/fwlink/?LinkId=161376) ](http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0)




NOTE: The above slide deck was gratefully converted into the above format using SilverSlide by Mark Mann ([@mark_mann](http://twitter.com/#!/@mark_mann)), you can find his blog [here](http://blog.mark-mann.co.uk/). Thanks again Mark!
Loading

0 comments on commit c63ade3

Please sign in to comment.