Click here to Skip to main content
14,333,875 members

Dominic Burford - Professional Profile



Summary

Follow on Twitter LinkedIn      Blog RSS
6,514
Author
2,028
Authority
9,112
Debator
8
Editor
100
Enquirer
207
Organiser
2,623
Participant
I am a professional software engineer and architect with over eighteen years commercial development experience with a strong focus on the design and development of web and mobile applications.

I have experience of architecting scalable, distributed, high volume web applications that are accessible from multiple devices due to their responsive web design, including architecting enterprise service-oriented solutions. I have also developed enterprise mobile applications using Xamarin and Telerik Platform.

I have extensive experience using .NET, ASP.NET, Windows and Web Services, WCF, SQL Server, LINQ and other Microsoft technologies. I am also familiar with HTML, Bootstrap, Javascript (inc. JQuery and Node.js), CSS, XML, JSON, Apache Cordova, KendoUI and many other web and mobile related technologies.

I am enthusiastic about Continuous Integration, Continuous Delivery and Application Life-cycle Management having configured such environments using CruiseControl.NET, TeamCity and Team Foundation Services. I enjoy working in Agile and Test Driven Development (TDD) environments.

Outside of work I have two beautiful daughters. I am also an avid cyclist who enjoys reading, listening to music and travelling.

 

Reputation

For more information on Reputation please see the FAQ.

Privileges

Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilverAdmin
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSitebuilder, Subeditor, Mentor, Protector, Editor, Staff, Admin
Store personal files in your account areaplatinumplatinumSitebuilder, Subeditor, Supporter, Editor, Staff
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubeditor, Protector, Editor, Staff, Admin
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubeditor, Protector, Editor, Staff, Admin
Edit a Question in Q&AsilversilversilversilverYesSubeditor, Protector, Editor, Admin
Edit an Answer in Q&AsilversilversilversilverYesSubeditor, Protector, Editor, Admin
Delete a Question in Q&AYesSubeditor, Protector, Editor, Admin
Delete an Answer in Q&AYesSubeditor, Protector, Editor, Admin
Report an ArticlesilversilversilversilverSubeditor, Mentor, Protector, Editor, Staff, Admin
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubeditor, Mentor, Protector, Editor, Staff, Admin
Edit other members' articlesSubeditor, Protector, Editor, Admin
Create an article without requiring moderationplatinumSubeditor, Mentor, Protector, Editor, Staff, Admin
Approve/Disapprove a pending QuestionProtector, Admin
Approve/Disapprove a pending AnswerProtector, Admin
Report a forum messagesilversilverbronzeProtector, Editor, Admin
Approve/Disapprove a pending Forum MessageProtector, Admin
Create a new tagsilversilversilversilverAdmin
Modify a tagsilversilversilversilverAdmin

Actions with a green tick can be performed by this member.


 
GeneralComplete 360 Testing Pin
Dominic Burford27-Oct-16 2:49
professionalDominic Burford27-Oct-16 2:49 
GeneralCompleted the ASP.NET Web API build pipeline Pin
Dominic Burford24-Oct-16 1:18
professionalDominic Burford24-Oct-16 1:18 
GeneralOne code-base for all mobile platforms is a pipe dream Pin
Dominic Burford12-Oct-16 18:42
professionalDominic Burford12-Oct-16 18:42 
GeneralRe: One code-base for all mobile platforms is a pipe dream Pin
Member 1280340119-Oct-16 9:29
memberMember 1280340119-Oct-16 9:29 
GeneralRe: One code-base for all mobile platforms is a pipe dream Pin
Dominic Burford19-Oct-16 21:26
professionalDominic Burford19-Oct-16 21:26 
GeneralOur apps have gone live Pin
Dominic Burford11-Oct-16 18:54
professionalDominic Burford11-Oct-16 18:54 
GeneralFive truths about software development Part IV Pin
Dominic Burford13-Sep-16 2:44
professionalDominic Burford13-Sep-16 2:44 
GeneralIsolating unit tests using Dependency Injection Pin
Dominic Burford11-Aug-16 22:01
professionalDominic Burford11-Aug-16 22:01 
Following on from my earlier post Could this function be unit tested without modifying it?[^] the simple answer is yes it can. In this post I will explain how.

To summarise, the function that caused the problem used the current date to make a particular calculation using DateTime.Now. The original unit tests I wrote one day and all passed, then subsequently all failed the very next day as the function was returning a different result based on the current value of DateTime.Now.

My initial approach was to pass in a default value for the date. If no date was supplied then DateTime.Now would be used. Otherwise the supplied DateTime argument would be used. But I wasn't keen on this approach. Supplying default arguments to functions just so they can be unit tested had a bad code smell.

I had a look at the Pex and Moles[^] framework which supports unit testing by providing isolation by way of detours and stubs by allowing you to replace any .NET method with a delegate. This sounded pretty cool and I very nearly took this approach.

In the end however, I opted for a Dependency Injection approach. The benefit of this approach is that it forced me to refactor the code to make it less reliant on the environment, and that's a good thing.

In the code snippet below you will see I have defined an interface called IDateTime which contains one property called Now of type DateTime. The class ReportLibrary then contains a reference to this interface called _datetime. A private class called ActualDateTime implements IDateTime.

We then need to define a default constructor and an overloaded constructor (as we will pass in the required DateTime in the constructor). If we create an instance of the ReportLibrary class with no parameters (as our application will do) then the value for _datetime is defaulted to DateTime.Now. If we pass in a value to the constructor (as our unit tests will do) then we assign that value instead to _datetime.
namespace CoreLibrary
{
    /// <summary>
    /// We use this interface for contructor injection in our unit tests. 
    /// We are essentially mocking the DateTime.Now property for unit testing.
    /// </summary>
    public interface IDateTime
    {
        DateTime Now { get; set; }
    }

    /// <summary>
    /// Library functions used by the application
    /// </summary>
    public class ReportLibrary
    {
        private readonly IDateTime _datetime;

        private class ActualDateTime : IDateTime
        {
            public DateTime Now { get; set; }
        }

        //If no reference to IDateTime is passed to the constructor then default to 
        //using the actual DateTime.Now property
        public ReportLibrary()
        {
            this._datetime = new ActualDateTime { Now = DateTime.Now};
        }

        //We will inject a reference to IDateTime from our unit tests with the required value for DateTime.Now specified
        public ReportLibrary(IDateTime datetime)
        {
            this._datetime = datetime;
        }
        public int MyFunction()
        {
          int result;

          //The original line of code below
          //DateTime today = DateTime.Now;

          //This is the updated line of code
          DateTime today = this._datetime.Now;

          //rest of the calculation goes here
          return result;
        }
    }
}

So here is how we will invoke the function from the application.
ReportLibrary reportLibrary = new ReportLibrary();
int result = reportLibrary.MyFunction();

And here is how we invoke the function from the unit tests. Firstly we need to define a class that implements our IDateTime interface. Define this at the top of our unit test class.
[TestClass]
public class ReportLibraryTests
{
  //this goes at the top of our unit test class
  private class MockDateTime : IDateTime
  {
    public DateTime Now { get; set; }
  }
  //rest of the test methods go here
}

Then in the test method we create an instance of this class and assign the Now property with the required value for DateTime.Now.
[TestMethod]
public void MyFunctionTests()
{
  IDateTime dateTime = new MockDateTime();
  //set the DateTime.Now property and inject this into the ReportLibrary constructor
  DateTime today = new DateTime(2016, 8, 3);
  dateTime.Now = today;
  ReportLibrary reportLibrary = new ReportLibrary(dateTime);
  int result = reportLibrary.MyFunction();
  Assert.AreEqual(999, result, "Invalid result for 'MyFunction'");
}

And that's how I managed to isolate the function so that it works both in the application without any modification to its signature, and in the unit tests whereby different values for DateTime.Now can be supplied Cool | :cool:
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

Home | LinkedIn | Google+ | Twitter

GeneralCould this function be unit tested without modifying it? Pin
Dominic Burford4-Aug-16 1:41
professionalDominic Burford4-Aug-16 1:41 
GeneralRe: Could this function be unit tested without modifying it? Pin
Dominic Burford5-Aug-16 0:24
professionalDominic Burford5-Aug-16 0:24 
GeneralTeam Foundation Services 2015 build tools Pin
Dominic Burford12-Jul-16 9:27
professionalDominic Burford12-Jul-16 9:27 
GeneralMy first app using Telerik Platform Pin
Dominic Burford8-Jul-16 2:23
professionalDominic Burford8-Jul-16 2:23 
GeneralHaving a Mobile Strategy Pin
Dominic Burford5-Jul-16 1:23
professionalDominic Burford5-Jul-16 1:23 
GeneralExciting times ahead Pin
Dominic Burford31-May-16 6:00
professionalDominic Burford31-May-16 6:00 
GeneralRe: Exciting times ahead Pin
Sander Rossel31-May-16 9:43
professionalSander Rossel31-May-16 9:43 
GeneralRe: Exciting times ahead Pin
Dominic Burford31-May-16 20:47
professionalDominic Burford31-May-16 20:47 
GeneralBootcamps vs. College Pin
Dominic Burford23-May-16 2:41
professionalDominic Burford23-May-16 2:41 
GeneralWhen to use best practices Pin
Dominic Burford8-Apr-16 5:53
professionalDominic Burford8-Apr-16 5:53 
GeneralWhat's wrong with just being a solid programmer? Pin
Dominic Burford5-Apr-16 1:59
professionalDominic Burford5-Apr-16 1:59 
GeneralRe: What's wrong with just being a solid programmer? Pin
Slacker0075-Apr-16 2:19
professionalSlacker0075-Apr-16 2:19 
GeneralRe: What's wrong with just being a solid programmer? Pin
Dominic Burford5-Apr-16 2:28
professionalDominic Burford5-Apr-16 2:28 
GeneralWhen Interviews Fail Pin
Dominic Burford29-Mar-16 20:44
professionalDominic Burford29-Mar-16 20:44 
GeneralRe: When Interviews Fail Pin
Slacker00730-Mar-16 2:26
professionalSlacker00730-Mar-16 2:26 
GeneralStackoverflow Developer Survey Results 2016 Pin
Dominic Burford17-Mar-16 22:01
professionalDominic Burford17-Mar-16 22:01 
GeneralRe: Stackoverflow Developer Survey Results 2016 Pin
Slacker00718-Mar-16 0:14
professionalSlacker00718-Mar-16 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.