Thursday, March 20, 2014

Top Developer Training Resources

Columbus Developers have put together a list of our favorite training resources. 


Reference Sites



Learn HTML, HTML5, CSS, JavaScript, jQuery, jQueryMobile, AJAX, JSON and more
http://www.w3schools.com/

The defacto standard for jQuery information
http://jquery.com/

The Spring site
http://spring.io/

SharePoint Tech Center
http://technet.microsoft.com/en-us/sharepoint/default

SharePoint Dev Center
http://msdn.microsoft.com/en-us/SharePoint

MSDN Virtual Labs
http://msdn.microsoft.com/en-us/aa570323

MSDN Learning Resources
http://msdn.microsoft.com/en-us/bb188199.aspx

TechNet Virtual Labs
http://technet.microsoft.com/en-us/virtuallabs

Example Projects


Github
https://github.com/

CodePlex
http://www.codeplex.com

Interactive Training


Cool site that teaches you how to code
http://www.codecademy.com/

Video lessons, coding challenges and screen casts
https://www.codeschool.com/

Developer Video Tutorials


Video Training by AppDev
https://www.learnnowonline.com/

Introductory Videos on .NET
http://www.learnvisualstudio.net/

Lots of videos on Microsoft Technologies
https://channel9.msdn.com/

Video jump starts on Microsoft development
http://www.microsoftvirtualacademy.com

YouTube has development videos
http://www.youtube.com/

Hardcore Developer Training
http://www.pluralsight.com/training

Videos for developers, designers, business, 3D and Audio
http://www.lynda.com/

Videos on web design, rails, iOS, Android, PHP and WordPress
http://teamtreehouse.com/

Video Courses and eBooks on After Effects, Mobile, Software Development and Web Design
https://tutsplus.com/

Links to Videos, Whitepapers, Quick References, and PodCasts
http://www.dzone.com

Videos on Javascript and jQuery
http://learn.appendto.com/

College Courses


Free online college courses
https://www.coursera.org/

Free Courses from elementary to college level
https://www.khanacademy.org/

Online College Courses
https://www.edx.org/

Podcasts


Scott Hanselman's Podcast
http://www.hanselminutes.com/

Internet Audio Talk Show for .NET Developers
http://www.dotnetrocks.com/

Best Forums


http://www.stackoverflow.com

Books


Giant free collection of programming books
https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md#professional-development


Other


An online regular expression tester
http://regexpal.com/

Connection Strings
http://www.connectionstrings.com/

Regular Expression Library
http://www.regxlib.com

Design Patterns
http://www.dofactory.com

Solid Design Principles
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod

Law of Demeter
http://en.wikipedia.org/wiki/Law_of_Demeter

Test Driven Development
http://jonkruger.com/blog/2009/07/23/tdd-starter-kit-sample-projects-and-links/


Tuesday, March 18, 2014

Compare .NET Objects V2.0 Released

I have an open source project that I have worked on for several years now.  It is a .NET class library that has the ability to perform a deep comparison of .NET objects using reflection.  Initially it was a simple class that handled just lists, classes, properties and fields.  That single classes became bloated after years of adding features.  Version 2.0 refactors all the type comparers into separate classes.  I also made a portable class library build that targets Silverlight 5+, Windows RT 8+, Windows Phone 8+, Xamarin iOS, and Xamarin Droid.

Project Information

https://comparenetobjects.codeplex.com/



NuGet Package

http://www.nuget.org/packages/CompareNETObjects/

Monday, March 3, 2014

A Regular Expression That Parses Leap Years

We recently had some end users that put in some invalid dates that bypassed our standard regular expression for date validation.  Users put in 02/29/2014.  In case you didn't know, 2014 is not a leap year.  I found a great regular expression on RegexLib that handles leap years.  Even though we are talking about client side validation.  It should be said that server date validation should also be performed.


http://www.regexlib.com/REDetails.aspx?regexp_id=279

Here it is:
((^(10|12|0?[13578])([/])(3[01]|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(11|0?[469])([/])(30|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(2[0-8]|1[0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(29)([/])([2468][048]00)$)|(^(0?2)([/])(29)([/])([3579][26]00)$)|(^(0?2)([/])(29)([/])([1][89][0][48])$)|(^(0?2)([/])(29)([/])([2-9][0-9][0][48])$)|(^(0?2)([/])(29)([/])([1][89][2468][048])$)|(^(0?2)([/])(29)([/])([2-9][0-9][2468][048])$)|(^(0?2)([/])(29)([/])([1][89][13579][26])$)|(^(0?2)([/])(29)([/])([2-9][0-9][13579][26])$))

I was skeptical because the regular expression is so long and it is easy to make a mistake with something this complex.  I created some NUnit tests to verify the functionality.  I would have to say that Saurabh Nath did an excellent job.

Here is the set of NUnit tests that I created:

[TestFixture]
public class LeapDateTests
{
    private Regex _dateRegex;

    [TestFixtureSetUp]
    public void Start()
    {
        _dateRegex = new Regex(@"((^(10|12|0?[13578])([/])(3[01]|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(11|0?[469])([/])(30|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(2[0-8]|1[0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(29)([/])([2468][048]00)$)|(^(0?2)([/])(29)([/])([3579][26]00)$)|(^(0?2)([/])(29)([/])([1][89][0][48])$)|(^(0?2)([/])(29)([/])([2-9][0-9][0][48])$)|(^(0?2)([/])(29)([/])([1][89][2468][048])$)|(^(0?2)([/])(29)([/])([2-9][0-9][2468][048])$)|(^(0?2)([/])(29)([/])([1][89][13579][26])$)|(^(0?2)([/])(29)([/])([2-9][0-9][13579][26])$))", RegexOptions.Compiled);
    }

    [Test]
    public void TestDaysInMonthFor2014Positive()
    {
        for (int month = 1; month <= 12; month++)
        {
            for (int day = 1; day <= 31; day++)
            {
                //Thirty days hath September, April, June, and November
                if (month == 9 || month == 4 || month == 6 || month == 11)
                {
                    if (day > 30)
                        continue;                       
                }

                //Except February which has 28
                if (month == 2 && day > 28)
                    continue;

                string dateString = string.Format("{0}/{1}/2014", month, day);

                Assert.IsTrue(_dateRegex.IsMatch(dateString), dateString);
            }
        }
    }

    [Test]
    public void TestDaysInMonthFor2014Negative()
    {
        for (int month = 1; month <= 12; month++)
        {
            for (int day = 1; day <= 31; day++)
            {
                string dateString = string.Format("{0}/{1}/2014", month, day);

                //Thirty days hath September, April, June, and November
                if (month == 9 || month == 4 || month == 6 || month == 11)
                {
                    if (day > 30)
                        Assert.IsFalse(_dateRegex.IsMatch(dateString), dateString);
                }

                //Except February which has 28
                if (month == 2 && day > 28)
                    Assert.IsFalse(_dateRegex.IsMatch(dateString), dateString);
            }
        }
    }

    [Test]
    public void TestLeapYearsPositive()
    {
        for (int year = 3000; year > 1800; year--)
        {
            if (!IsLeapYear(year))
                continue;
           
            //February 29th
            string dateString = string.Format("02/29/{0}", year);
            Assert.IsTrue(_dateRegex.IsMatch(dateString), dateString);

            //February 30th
            dateString = string.Format("02/30/{0}", year);
            Assert.IsFalse(_dateRegex.IsMatch(dateString), dateString);

            //February 30th
            dateString = string.Format("02/31/{0}", year);
            Assert.IsFalse(_dateRegex.IsMatch(dateString), dateString);
        }
    }

    [Test]
    public void TestLeapYearsNegative()
    {
        for (int year = 3000; year > 1800; year--)
        {
            if (IsLeapYear(year))
                continue;

            //February 29th
            string dateString = string.Format("02/29/{0}", year);
            Assert.IsFalse(_dateRegex.IsMatch(dateString), dateString);

            //February 30th
            dateString = string.Format("02/30/{0}", year);
            Assert.IsFalse(_dateRegex.IsMatch(dateString), dateString);

            //February 30th
            dateString = string.Format("02/31/{0}", year);
            Assert.IsFalse(_dateRegex.IsMatch(dateString), dateString);
        }
    }

    private bool IsLeapYear(int year)
    {
        //See:  http://www.timeanddate.com/date/leapyear.html
        bool evenlyDivisibleByFour = year%4 == 0;
        bool evenlyDivisibleByOneHundred = year%100 == 0;
        bool evenlyDivisibleByFourHundred = year%400 == 0;

        if (!evenlyDivisibleByFour)
            return false;

        if (evenlyDivisibleByOneHundred && !evenlyDivisibleByFourHundred)
            return false;

        return true;
    }
}