Posted by: the author | August 22, 2013

Code Regions

Today, I was watching a Channel 9 video about Visual Studio 2013 for Web Developers (found here).  There’s a lot of great stuff in it, but one thing in the beginning of the video that stood out to me was that you can do code regions in JavaScript.  Who knew, right?  Here’s how:

//#region SomeCoolName

function someCoolFunctionName() {
// Some cool function stuff
}

//#endregion

Simply enough for me.  However, you’ll need the Web Essentials 2012 extension for it, which is found here: http://vswebessentials.com/

Okay, so that’s for JavaScript.  We already should all know how to do it in C#.  I’m a huge fan of keeping code neat and organized.  So, I was actually kind of surprised to not see support for regions in XAML code.  Just a little digging for that one day, earlier this year, led me to this: http://visualstudiogallery.msdn.microsoft.com/3c534623-bb05-417f-afc0-c9e26bf0e177

A simple example from that site shows this:

<!– Region (Any Text You Want) –>
Your Code
<!– EndRegion –>

Ah, now that’s what I wanted.  It worked great when I took over a project with a pretty structured layout in a Grid element.  Grouping things into regions certainly helped organize all of that. 🙂

Posted by: the author | October 5, 2012

SQL Joins Analogy

I was reading through Microsoft SQL Server 2008 Bible (by Paul Nielsen, Uttam Parui and Mike White) today and found a really nice, simple way of looking at how joins work:

A Join Analogy

When I teach how to build queries, I sometimes use the following story to explain the different types of joins. Imagine a pilgrim church in the seventeenth century, segmented by gender. The men all sit on one side of the church and the women on the other. Some of the men and women are married, and some are single. Now imagine that each side of the church is a database table and the various combinations of people that leave the church represent the different types of joins.

If all the married couples stood up, joined hands, and left the church, that would be an inner join between the men and women. The result set leaving the church would include only matched pairs.

If all the men stood, and those who were married held hands with their wives and they left as a group, that would be a left outer join. The line leaving the church would include some couples and some bachelors.

Likewise, if all women and their husbands left the church, that would be a right outer join. All the bachelors would be left alone in the church.

A full outer join (covered later in this chapter) would be everyone leaving the church, but only the married couples could hold hands.

Posted by: the author | June 3, 2011

Magic

using System.Magic;

namespace My.Magic
{
    public static class MagicSoftware
    {
        public static PerformMagic(Magic spell)
        {
            System.ApplicationResources = spell;

            MakeApplicationJustWorkAndDoWhatIWantWithNoProblemsOrErrors();
            RestoreDatabaseRegardlessOfSpaceIssues();
            FixConfigFilesWithMagic();
            StopAskingForMyPasswordAfterISaveIt();
        }
    }
}

Posted by: the author | March 4, 2011

DOS

C:\DOS>
C:\DOS>RUN
RUN\DOS\RUN

Posted by: the author | March 3, 2011

I’m a…

Another one I found on a t-shirt…

I’m a programor
I’m a programar
I’m a progarmmor
I write code…

Posted by: the author | March 2, 2011

Baby Logic

I found this one on a t-shirt and posted it elsewhere once before, but am now posting it here to my blog.

while (still_a_baby == true)
{
    if (hungry == true || diaper_needs_changing == true ||
        wants_to_play == true || just_feels_like_it == true)
    {
        EndSleep();
        StartCry();
    }
    else
    {
        EndCry();
        StartSleep();
    }
}

Posted by: the author | March 2, 2011

Washington State Winter

Weather weather = new Weather();

weather.State = State.Washington;
weather.Type = new Random(PrecipitationType);
weather.Temperature = new Random( 5, 50 );
weather.Season = Season.Winter;

while (weather.Temperature >= 33.4 && weather.Temperature <= 33.6)
{
    weather.PrecipitationType = Precipitation.Snow;
    Snow();
}

while (weather.PrecipitationType != Precipitation.Snow)
{
    if (weather.Temperature <= 33.3)
    {
        FreezeAllRoads();
        LowerDrivingSkillIQOfWashintonDrivers(-100);
        ReleaseAllPsychoticDriversWith4X4VehiclesOntoRoads&();
        PlaceRandomCarsInDitches();
        CauseDriversToAbandonCarsInTheMiddleOfTheRoad();
    }
    else
    {
        MeltSnow();
        CauseEveryoneToActNormal();
        Rain();
        BlowStrongWind();
        weather.Type = new Random(PrecipitationType);
    }
}

Posted by: the author | January 4, 2011

Planning…the developer way

“You start writing code, I’ll go find out what they want.”

A developer wants to write code, not write documents all day and get to writing code 5 million years later!  I can’t say that I’m any different in that desire, but I know how good planning makes for a much better product in the end.  With any luck, someone else plans it all and you come in right when the good stuff starts to roll out.  Although, being a part of the planning process helps out a lot and gets you rolling pretty fast.  In any case, this phrase pretty much sums up how I had to work my way through school as there was little time to plan and lots of time to write code if projects were going to be turned in on time.

Posted by: the author | December 27, 2010

Why I Created This Blog

With the millions of blogs out there, I’ve never come across one that’s about programming…my style.  I’m a software developer and I like to keep relaxed and find the humor in things rather than get stressed and be serious all the time.  So, I will occasionally take the time to post some quirky code that I either came up with or saw/heard somewhere and find to be hilarious in some sort of way.

For example:

while (awake)
{
    WriteCode();
}

Hence, the name of the blog here. 😀

Enjoy!

Categories