Do Trust and Faith belong in Software Development? Not Really!

27. April 2013
The words "Trust" and "Faith" don't normally come up in discussion surrounding software development. However, whether we like to say it or not, we really do put a lot of both trust and faith in software. In fact, software developers often put a lot trust and faith in there development tool. While this can be justified in certain cases; it is most often a mistake. The Good When following Test Driven Development (TDD) you basically don't trust anything by writing unit tests to verify everything ... [More]

‘SQL Query’ Micro Design Pattern

24. March 2013
There are a few programming practices, that I like to call Micro Design Patterns, that I use over and over again on various software projects I work on. One pattern that I call SQL Query, and use quite frequently when I need to write ad-hoc SQL queries for use within a Data Access Layer. This pattern lends itself to easier testability and a cleaner separation of concerns. What is the ‘SQL Query’ Micro Pattern? Basically, the SQL Query micro pattern involves using a Factory Method to return an ... [More]

Design Patterns , ,

Peeking inside the Twitter Windows 8 App

17. March 2013
I decide to peek inside the Twitter Windows 8 App package to see what language they are using and to see if I can find any open source projects being used within. Well, I found some interesting stuff… How to view inside the package You can view any Windows 8 app package that is installed on your computer as it resides within the following folder: C:\Program Files\WindowsApps Each package has it’s own folder within that folder. Here’s the full path to the package folder where the Twitter a... [More]

Windows Store App ,

What “var” really means in C#–It’s not “variant”

16. March 2013
With the release of C# 3.0 came the addition (among many others) of the “var” keyword. I’ve seen MANY people confused about what this keyword is, does and means. Among these people with incorrect assumptions to the function of the “var” keyword, I have seen programmers/developers with varying amounts / years of experience. So, I’ve decided to write up a simple explanation; actually the same one I’ve told and/or emailed people over the last couple years. “var” is not variant! Since “var” is the... [More]

C#

Windows 8 App: Simple Weight Log–My first Windows Store App

13. March 2013
A few weeks ago I built and released Simple Weight Log (my first Windows 8 app in the store.) The app allows you to enter your weight in a log by date and it charts the different weigh-ins in a line graph to allow you to easily visualize weight changes over time. View in Windows Store “Are you trying to loose weight? or, gain weight? If so, then Simple Weight Log will allow you to easily log and track metrics on your progress.” Application Features Simple and easy to use I purposely bu... [More]

Windows Store App ,

SQL Azure: Calculate Database Usage Percentage of Max Size

10. March 2013
Some times it can be useful to programmatically monitor your SQL Azure database usage statistics. Luckily, there is some short SQL code that can be run on the database to check how much disk space is currently used and what the currently allotted max database size is. The following script does just that. DECLARE @dbName nvarchar(255) = '{database_name}'; DECLARE @Max BIGINT = CONVERT(BIGINT, (SELECT DATABASEPROPERTYEX(@dbName , 'MaxSizeInBytes'))); DECLARE @Used BIGINT = ( SELECT ... [More]

Azure, SQL , ,

All Information Workers are NOT Equal or Even Approximate!

6. December 2012
There have been information workers for a long time. However, even after all this time, it is amazing that one of the biggest misconceptions is that all information workers are equal (or at least approximately equivalent.) It basically goes like this: an hour of worker A’s time is pretty much equal to an hour of worker B’s time. In reality this couldn’t be further from reality. It’s like saying a high school graduate today is as smart as Albert Einstein. Well, maybe that example is a little ext... [More]

General

Office 365 + Microsoft Account + Password Expiration = FAIL!

5. October 2012
One of my business email accounts is hosted in Exchange Server via Microsoft Online Services. Earlier this year they upgraded us to the new Office 365. Everything went well for a few months after the upgrade, until my password happened to expire on my earlier this week. Below is a solution I was able to figure out to regain access to my account (without calling Microsoft for support/help.) Background This specific email address is also a Microsoft Account (aka Windows Live ID) and has been eve... [More]

General , ,

Using MiniProfiler with SqlDataSource ASP.NET WebForms Control

8. August 2012
I recently implemented MiniProfiler into an existing ASP.NET WebForms application that makes use of databinding to the SqlDataSource control. Since the SqlDataSource uses a DbProviderFactory internally, it is fairly simple to exend the control to utilize MiniProfiler through inheritance and overriding a single method of the SqlDataSource. Here’s a very simple class that inherits from the SqlDataSource control and injects MiniProfiler support to be able to profile the SQL query used by the contr... [More]

C#, asp.net , , , ,

Mocking HttpRequestBase.ServerVariables using Moq

3. August 2012
Mocking is a very handy tool for unit testing code, especially when it comes to mocking the HttpContext for web application code. However, it’s not as straight forward as you might think to mock the HttpRequestBase.ServerVariables, however once you know what to do it really is pretty simple. Here’s a code example (using moq) that shows how to create a mock HttpContextBase that contains a mock HttpRequestBase with a mock ServerVariables property: public HttpContextBase CreateMockHttpContext() ... [More]

C#, ASP.NET MVC, TDD , ,

jHash v2.0 Released: Now with Routing Support!

1. May 2012
jHash is a small, lightweight (4kb minified / 2kb compressed) javascript library that makes it extremely easy to work with “location.hash". Version 1.0 had the ability to set / retrieve hash root values as well as “hash querystring” values. The newly released version 2.0 includes a new lightweight routing engine that facilitates an easier developer experience when building Single Page Applications. The jHash documentation contains full descriptions of the libraries methods and their usage.... [More]

JavaScript, HTML , ,

Design Patterns: Basics of Dependency Injection

13. April 2012
Dependency Injection and Inversion of Control (IoC) have become popular buzz words in the .NET development world over the last couple years. However, It seems that not very many developers really know what they are. Like most design patterns they are rather simple in idea, but the various implementations can become complex to someone new to them. Also, it seems that these two are often considered that they must go together or even mistaken as the same thing. This prompted me to write up this sho... [More]

C#, Design Patterns , ,

Awarded 2012 Microsoft MVP - Bing Maps

1. April 2012
Whether I won MVP or not I would still do what I do. My passion for technology and the pleasure of helping others it what drives me. This marks the 5th time I've been awarded Microsoft MVP, and am honored for this recognition. Thank you Microsoft! Congratulations to all April Fools MVP's; new and renewed! If you are not familiar with the Microsoft MVP Program, you can find information about it here: http://mvp.support.microsoft.com

General ,

SQLinq: Use LINQ to generate Ad-Hoc, strongly typed SQL queries

24. March 2012
SQLinq is a new library that allows ad-hoc SQL code to be generated at runtime in a strongly typed manner that allows for compile time validation of your SQL code. Why SQLinq? SQLinq is built with the core idea of simplicity and ease of use. SQLinq wont get in your way like other Data Access Layers will. SQLinq is not so much a Data Access Layer (DAL) as it is a code generation tool. Although, it’s not a code generator like others you may be used to. If you look at Entity Framework, you’ll se... [More]

C#, SQL , , , ,

Unit Testing with SqlException in .NET: Only with help from Reflection

2. March 2012
If you are writing you code to be able to easily unit test each method, and you would like to unit test situations where a SqlException exception is thrown, then you’ll definitely run into the issue of the SqlException objects constructor being marked “internal.” Members marked “internal” can be a nightmare for unit testing, and they are found all over the place in the .NET Framework. Basically you can’t call “internal” methods, constructors, fields, etc from you own code because it doesn’t resi... [More]

C#, TDD , , ,

IronJSMVC: Script ASP.NET MVC in JavaScript using IronJS

21. January 2012
Personally, I enjoy writing much of my applications using a statically typed language such as C#. However, I would really prefer to be able to write UI logic and script certain parts of my applications using a dynamic language if I could. I was thinking about this and the following question came to mind: What would it be like to write an ASP.NET MVC application entirely using JavaScript? So I thought I’d work up a prototype using IronJS (a javascript implementation for the .NET DLR.) Download... [More]

JavaScript , , ,

HTML5 IE9 Bug: SELECT box is Un-Selected using Mouse if CSS modifies position on hover

21. January 2012
I recently encountered this rather strange bug that only shows up in Internet Explorer 9 (haven’t tried 10, but likely there too,) but works just fine in IE8, Firefox, Safari and Chrome. Generally the HTML/CSS markup for an individual page within a normal web application can get pretty complex, so this bug took me a while to figure out what it was. Apperently, if you have a <SELECT> box contianed within a <TABLE> (which is done fairly often with data entry interfaces,) and you have ... [More]

HTML, JavaScript , ,

CanvasMap Prototype = HTML5 Canvas + Mapping

5. January 2012
When Microsoft released the Windows 8 Developer Preview (Sept. 2011) I was a bit annoyed that they failed to include a “native” Bing Maps control for us to build with. Instead they require you embed the Bing Maps v7 Ajax map within an IFrame to use it. There are a few issues with this that I wont get into now. So, consequentially, I decided to prototype my own map control with the intended purpose to use it with JavaScript based WinRT apps if it turned out well. Disclaimer: The code for CanvasM... [More]

Bing Maps, JavaScript , ,

2012 Bing Maps Feature Wish List

19. December 2011
The Bing Maps Silverlight control is really sweet (although it hasn’t been updated in forever) and the Ajax v7 control was a huge improvement performance wise over v6. However, the Bing Maps platform has a long way to go before I would consider it to be the mapping development platform I would hope it could someday become. Bing Maps Wish List Here’s a list of some features that I hope make their way into the Bing Maps platform for us developers to be able to utilize: 1) Bring 3D Mapping Back!... [More]

Bing Maps

ASP.NET MVC Themes: 3 different theming methods

19. November 2011
There really isn’t a single “one size fits all” solution to theming an ASP.NET MVC web application. From my experience working with the platform, there are really 3 different methods that can be used to theme your apps. Here they are in no particular order: 1. CSS Stylesheet This is the simplest and pretty much standard method that’s used to theme an ASP.NET MVC web application. Basically, you just create a different version of your sites CSS file for each “theme.” Then you include the approp... [More]

ASP.NET MVC , , ,

SQL Azure: REBUILD All Indexes in Database – Alternative to DBCC DBREINDEX

10. November 2011
Unfortunately there are some differences between SQL Server and SQL Azure. One of these differences is that SQL Azure does not support the “DBCC DBREINDEX” command. Thankfully there is an alternative you can use to rebuild the indexes within your SQL Azure databases. The alternative is to use “ALTER INDEX” instead. ALTER INDEX ALL ON TableName REBUILD Here’s an example that loops through all the tables in a database and rebuilds all their indexes: DECLARE @TableName varchar(255) DECLAR... [More]

SQL , ,

JavaScript: window.onbeforeunload Event - Show “Are you sure you want to leave this page?” Message

9. September 2011
All web developers have likely seen how inconvenient it can be for a user to edit some data in an application, then click a link/button to go on to the next task, but only to later realize that all changes made were never saved. This can pose a major problem for users, until they get it down that they need to click the “Save” button before leaving the page. Wouldn’t it be nice for the app to remind them to click the “Save” button? Everyone has seen the “Are you sure you want to leave this page?... [More]

JavaScript

Tag Editor Field using jQuery similar to StackOverflow

9. September 2011
The tag editor featured on the StackOverflow website (and all the StackExchange websites) is a real slick tag editor that makes it much nicer to enter tags than just a plain textbox. I searched a little and couldn’t find anything that works just like theirs, so I decided to build one. Download Full Source Code: jquery.selectit-0.1.zip Here’s some example usage of the tag editor: <div id='SelectBox' style='width: 350px'></div> <input id='btnClear' type='button' value='Clear... [More]

JavaScript ,

Entity Framework Tips and Tricks: Use GetObjectByKey When Querying a Single Entity

7. September 2011
I’ve been using Entity Framework a lot lately and it makes data access really nice. It’s fairly simple to use and maps all your tables to a .NET object model. However, just like any other library, it can be misused and have it’s own issues. I’ve been figuring some things out as I’ve been using it, so I thought I’d share a few tip and tricks that I’ve learned. Here’s the first one: Use “GetObjectByKey” when Querying for a Single data entity Take the following query: var person = (from p in con... [More]

C# , , ,

Mixing some Dynamic-ness with IronJS in .NET 4

24. August 2011
I recently started messing around with IronJS again, and I must say that this project is pure awesomeness! One of the first things I noticed is that when you call the “Execute” methods to run some JavaScript code it returns an “object.” Now, while this works just fine, I would prefer if it returned a “dynamic” object while running against .NET 4.0. There may be some reason that Fredrik Holmstrom (the author) decided to return an ‘object’, so I don’t mean to sound negative, but you have to admit ... [More]

JavaScript, C#, DLR , , ,