Coding For a Living


A place to share and comment about coding for a living.

Become and Expert: JavaScript Mike McIntyre

This post provides some resources that will help you become a JavaScript expert.

Do you know when

    and when not - to use the JavaScript var statement?

    it’s safe to use non-strict comparison operators?

    to cache your JavaScript objects?

    to use feature detection?

    you should use inline event handlers?

If you had difficulty with ANY of the questions you will benefit from the following JavaScript resources:


JavaScript is formalized in the ECMAScript language standard.

Reading the standard is a good way to become a JavaScript expert.

Click here to download a PDF containing the ECMAScript languge standards:

Standard ECMA-262

Mozilla offers an excellent JavaScript Guide for newbies and a complete JavaScript Reference for all:

JavaScript MDN

JavaScript Reference - JavaScript MDN

W3Schools provides an online tutorial:

JavaScript Tutorial

The W3 has developed many of Web APIs available to JavaScript developers:

JavaScript Web APIs - W3C


Visual Basic 2012– Caller Information Mike McIntyre

New in Visual Basic 2012 is the caller information feature. This feature enables you to obtain information about the caller of a method.

By using Caller Info attributes, you can obtain information about the caller to a method. You can obtain file path of the source code, the line number in the source code, and the member name of the caller. This information is helpful for tracing, debugging, and creating diagnostic tools.

To obtain this information, you use attributes that are applied to optional parameters, each of which has a default value. 

For more information about using the Caller Information feature click:

       Caller Information (C# and Visual Basic)

Sample Use

' Imports System.Runtime.CompilerServices ' Imports System.Diagnostics Private Sub DoProcessing() TraceMessage("Something happened.") End Sub Public Sub TraceMessage(message As String, <CallerMemberName> Optional memberName As String = Nothing, <CallerFilePath> Optional sourcefilePath As String = Nothing, <CallerLineNumber()> Optional sourceLineNumber As Integer = 0) Trace.WriteLine("message: " & message) Trace.WriteLine("member name: " & memberName) Trace.WriteLine("source file path: " & sourcefilePath) Trace.WriteLine("source line number: " & sourceLineNumber) End Sub ' Sample output: ' message: Something happened. ' member name: DoProcessing ' source file path: C:\Users\username\Documents\Visual Studio 2012\Projects\CallerInfoVB\CallerInfoVB\Form1.vb ' source line number: 15

xRad–Well Known Schemas Mike McIntyre

In my three previous xRad posts I explained the use of well known names and how they help make extra rapid application development (xRad) possible.

  Coding For a Living  xRAD Well Known Names– Part 1
  Coding For a Living  vRAD Well Known Names– Part 2
Coding For a Living  vRAD Well Known Names– Part 3


In this post I will expand on the ‘well known’ concept that speeds up application development by discussing well known table schemas.

There are many database tables that are commonly used in business applications. A few examples are:

  Customer CustomerType Comment Location Table
  Contact ContactType Role Profile Price
  Address AddressType Version File  
  Order OrderType User Permission  
  Item ItemType AppLog Role_Permission  


Since 1992 we have identified 1104 well known table schemas.

Like well known names, well known table schemas are used in my databases, models, code, generators, and snippets.image

And, like well known names, well known schemas reduce development time because they are reusable.

Some benefits of well known table schemas are:

1.  When a new project starts up no design time is spent on the well known tables.

2.  Programmer documentation about well known schemas has not changed since 2011.  We will add more well known tables schemas but they will be additions, not changes.

3.  We run one script to install all well known tables at the beginning of a project.

4.  Code, text, comment, and documentation generators - auto create data access code, enum code, validation code, classes, and more for the well known tables. Once we install the tables and run the generators everything just works.

We’ve found it’s easier to install the well known tables and generate supporting code than to pick and choose.

vRAD Well Known Names– Part 3 Mike McIntyre

In my two previous vRAD posts I explained the concept of well known names and introduced ‘PostalCode’, a well known name I have used for application development since 1992.

  Coding For a Living xRAD Well Known Names– Part 1
  Coding For a Living vRAD Well Known Names– Part 2

At the end of my last xRAD post I asked: Can you think of at least three more ways the well known word PostalCode helps us build applications rapidly?

Here are a few of many correct answers:

  1. Reduces code review time. PostalCode classes and class members which encapsulate data and behavior, were last changed in 2004.
  2. Reduces testing time; PostalCode classes and class members which encapsulate data and behavior, were last tested in 2004.
  3. Avoids elusive names that are open to subjective interpretation.
  4. Promotes self-documenting code and reduces code comments.
  5. Provides a common name across the tiers of a multi-tier application.
  6. Makes it possible to document legacy systems faster.


In three posts I have explained the concept of well known names and how a single well known name can speed up application development by promoting re use over new development.image

Since 1992 we have developed 1513 well known names. Examples are:  PhoneNumber, EmailAddress, City, State, Country, Customer, FirstName, LastName, Contact, Url, Product, UnitOfMeasure.

Our well known names are used in schema scripts for databases, in models, in code, generators, in documentation, and much more.  We have code snippets for every well known name.

When we start a new project an average of 88% of the names we need come from our well known names.

In future posts I will explain how the ‘well known’ concept applies to other things used for application development; things like ‘well known tables’, well known methods, well known constants, and more.

Visual Studio 2012– JavaScript Strict Mode Mike McIntyre

Visual Studio 2012’s JavaScript Strict Mode provides better error checking.

Strict Mode

Strict mode is a way to introduce better error-checking into your code. When you use strict mode, you cannot, for example, use implicitly declared variables, or assign a value to a read-only property, or add a property to an object that is not extensible.

For example, in the following example all the code is in strict mode, and the variable declaration outside the function causes the syntax error "Variable undefined in strict mode."

"use strict"; function testFunction(){ var testvar = 4; return testvar; } testvar = 5;
"use strict"; function testFunction(){ var testvar = 4; return testvar; } testvar = 5;

Can machines think? The Imitation Game Mike McIntyre

Can Windows, iPhone, and Droid smart phones compete head-to-head with humans in Alan Turning’s ‘Imitation Game’?

imageThe ‘Imitation Game’ was proposed by Alan Turing in his 1950 paper "Computing Machinery and Intelligence," which opens with the words: "I propose to consider the question, 'Can machines think?'"

Since the words "think" and "machine" can't be defined in a clear way that satisfies everyone, Turing suggests we should ask if the machine can win a game, called the "Imitation Game". It involves three participants in isolated rooms: a computer (which is being tested), a human, and a (human) judge. The human judge can converse with both the human and the computer by typing into a terminal. Both the computer and human try to convince the judge that they are the human. If the judge cannot consistently tell which is which, then the computer wins the game.

Turing writes 'What will happen when a machine takes the part of A in this game?' Will the interrogator decide wrongly as often when the game is played like this as he does when the game is played between a man and a woman? These questions replace our original, 'Can machines think?'"

What do you think? Can Windows, iPhone, and Droid smart phones compete head-to-head with humans in Alan Turning’s ‘Imitation Game’

Visual Basic 2012–Iterators Mike McIntyre

Iterators are used to perform custom iteration over collections such as lists or arrays.

Iterators make it possible to use the iterator programming pattern. Wikipedia states: “In object-oriented programming, the iterator pattern is a design pattern in which an iterator is used to traverse a container and access the container's elements. The iterator pattern decouples algorithms from containers; in some cases, algorithms are necessarily container-specific and thus cannot be decoupled.”

Iterators can be used to create a custom iteration over array or collection class.

Iterators can increase performance because they allow you to asynchronously consume the elements of a large collection.

Iterators can decrease memory use too.

Learn more by clicking: What's New for Visual Basic in Visual Studio 2012


Visual Basic 2012– Async Feature Mike McIntyre

The VisualBasic 2012 Async feature makes it simpler to make code asynchronous.

With it you can call into asynchronous methods WITHOUT callbacks and WITHOUT splitting your code into different methods.

The following example shows a Visual Basic async method.

' Add an Imports statement and a reference for System.Net.Http

Imports System.Net.Http
Class MainWindow
    ' Mark the event handler with async so you can use Await in it. 
    Private Async Sub StartButton_Click(sender As Object, e As RoutedEventArgs)
        ' Call and await separately. 
        'Task<int> getLengthTask = AccessTheWebAsync(); 
        '' You can do independent work here. 
        'int contentLength = await getLengthTask; 
        Dim contentLength As Integer = Await AccessTheWebAsync()
        ResultsTextBox.Text &=
            String.Format(vbCrLf & "Length of the downloaded string: {0}." & vbCrLf, contentLength)
    End Sub 
    ' Three things to note in the signature: 
    '  - The method has an Async modifier.  
    '  - The return type is Task or Task(Of T). (See "Return Types" section.) 
    '    Here, it is Task(Of Integer) because the return statement returns an integer. 
    '  - The method name ends in "Async."
    Async Function AccessTheWebAsync() As Task(Of Integer)
        ' You need to add a reference to System.Net.Http to declare client. 
        Dim client As HttpClient = New HttpClient()
        ' GetStringAsync returns a Task(Of String). That means that when you await the 
        ' task you'll get a string (urlContents). 
        Dim getStringTask As Task(Of String) = client.GetStringAsync("")
        ' You can do work here that doesn't rely on the string from GetStringAsync.
        ' The Await operator suspends AccessTheWebAsync. 
        '  - AccessTheWebAsync can't continue until getStringTask is complete. 
        '  - Meanwhile, control returns to the caller of AccessTheWebAsync. 
        '  - Control resumes here when getStringTask is complete.  
        '  - The Await operator then retrieves the string result from getStringTask. 
        Dim urlContents As String = Await getStringTask
        ' The return statement specifies an integer result. 
        ' Any methods that are awaiting AccessTheWebAsync retrieve the length value. 
        Return urlContents.Length
    End Function 
    Sub DoIndependentWork()
        ResultsTextBox.Text &= "Working . . . . . . ." & vbCrLf
    End Sub 
End Class 
' Sample Output: 
' Working . . . . . . . 
' Length of the downloaded string: 41763.

To learn more click: Asynchronous Programming with Async and Await

vRAD Well Known Names– Part 2 Mike McIntyre

This post explains several ways well known names help my company build applications rapidly.

In my previous vRAD post I introduced ‘PostalCode’, a well known name I have used for application development since 1992.

In our development world, the well known word PostalCode is used where ever a zip code, post code, or postal code is represented or stored, for example:

1. as the column name of all database table columns that store a zip code, post code, or postal code

2. in data models where ever a zip code, post code, or postal code is used

3. as the property name in all classes that require a zip code, post code, or postal code

4. in programmer documentation

5. in code and other generators

PostalCode helps build applications rapidly because it reduces development and development project time.

How? Reuse. Reuse as in where the same thing is used again for the same function – again, and again, and again.  Since 1992:

1. No design time has been spent coming up with what to name things that will represent or store zip codes, post codes, or postal codes.

2. Programmer documentation about PostalCode has not been changed since 1992.

3. Anyone who has worked for me for more than a couple of months can teach a new person to use PostalCode because it is – you guessed it – well known.

4. Code generators, which require postal codes, post codes, or zip codes - for schemas, models, code, and tests – used the well known name PostalCode. We never spend time modifying that part of our code generators.

Can you think of at least three more ways the well known word PostalCode helps us build applications rapidly?

Answers will be published in the next xRad blog post..

Cool Parallax Background for Windows Store App Mike McIntyre

From Wikipedia: “Parallax is a displacement or difference in the apparent position of an object viewed along two different lines of sight, and is measured by the angle or semi-angle of inclination between those two lines.”

A Parallax can create an interesting visual effect when used for a background in a Windows Store App.

David Catuhe explain how in this blog post ‘How to create a cool parallax background’.