Category Archives: Microsoft

Items relating to Microsoft

Sudoku Project

Sudoku Project

The GitHub Sudoku project contains the C# code for a 9×9 Sudoku Solver along with corresponding test code using easy, medium, hard, and evil puzzles from web sudoku.

The code is reasonably generic and could be adapted to solve different size boards such as a 12×2 or 6×6 with some effort. In the future, code will be added to generate Sudoku boards of varying difficulty.

Other contributors are welcome and I’d love to see the solving algorithms you use.

Why Sudoku?

Sudoku is one of those games that doesn’t take much time to do and keeps your mind sharp. It’s a game that I’ve played occasionally for years, especially to pass the time when waiting.

Early in my career, I created a Sudoku solver that could solve the easy, medium, hard, and evil difficulty Sudoku puzzles on web sudoku.  I wanted to re-code the solver now to see how my coding skills have progressed over the years given the same objective. Unfortunately, the original code is lost to the ages.

Also, I wanted to code something different. Lately, I’ve been focusing my attention on Salesforce and other web programming related items and I wanted to take a break from that.

SFBulkAPIStarter: Attachment Support Added

SFBulkAPIStarter Overview

A couple years ago I was enhancing an ETL tool at work to add Salesforce Bulk API support so our data migration projects would execute faster. To help others understand how to use the Salesforce Bulk API, the SFBulkAPIStarter open source project was started.

It’s a C# library that has starter code demonstrating how to use the Salesforce Bulk API. The test project has test classes demonstrating how to do various Bulk API  tasks such as inserting, upserting, querying, and deleting records.

To take it for a spin, download it from Nuget.

Attachment Support Added

It’s been a while since I had contributed to the SFBulkAPIStarter project so I added support for adding an attachment to a specified record.

Attachment High-Level Steps

The steps to add an attachment to a Salesforce record were easier than expected:

  1. Create an Insert Attachment Bulk Job.
  2. Create a request.txt file containing one or more records with the following fields
    • Name – Name of the attachment to show in Salesforce.
    • Body – The “#” prefixed path of the file in the zip file.
    • ParentId – The Id of the Salesforce record to attach the attachment to.
  3. Create a zip file with the request.txt file and the file(s) to attach.
  4. Create a batch in the job whose request file is the zip file.

Attachment Code

Here’s the attachment method in the BulkAPIClient class that handles the attachment logic. Currently, this method handles attaching one attachment and not multiple.

Test Code

Here’s the test from the TestBulkApiClient class that attaches a file to a specified Salesforce record.

How often do you use the Bulk API? How about attaching an attachment to a record?

Happy Coding,


TypeScript 2.0 With Anders Hejlsberg

Anders Hejlsberg on TypeScript 2 is a new 30 minute discussion video with  Anders Hejlsberg describing the upcoming new features in TypeScript 2.0. Here’s a recap of the upcoming features.

Async Await

Javascript uses callback functions to allow a developer to specify the code execute after an asynchronous function executes. This can be implemented various ways such as with an inline function or with “promises”.

In TypeScript 2.0, one can use async await to call an async function and then the code to execute after it finishes comes after it instead of having to use a callback function. It has the “sequential” code style that I prefer.

Non-Null Variables

In Javascript, every variable is  nullable which leads to lots of “guard” code to check for nulls and act appropriately. With Non-Null Variables, TypeScript allows a variable to be declared as non-nullable. This reduces the amount of code needed to check for nulls and helps prevent null reference errors.

The “null reference error” is one of most problematic errors in programming. According to Anders, it costs $1 billion dollars annually.

What other TypeScript 2.0 features are you looking forward to? How have you used TypeScript?

Happy Coding,


Convention Over Configuration


Configuration is data that tells the system how to function. It often can be changed while the system is running to do something else. Configuration is good because the system isn’t hard-coded in its behavior and can be changed based on the allowable configuration options.

One major consideration with configuration is volume. There are systems with so much configuration that managing the configuration takes a lot of time and overhead. With Microsoft applications, I’ve seen this with configuration spread among config files, databases, and other data sources. In Salesforce, the configuration is usually in Custom Settings, Objects, and Custom Metadata Types. The overhead comes from not just developing the software to support the various options but documenting the configuration options and training others about the options too.

“Convention Over Configuration” Design Principle

A Convention is a standard or agreed upon way of doing things. In the software context, if things are done a certain way, the software will behave this way without having to be configured to do so.

Running Tests Example

In my Automated Unit Test Execution Salesforce Cookbook Recipe, the code runs apex classes that start with “Test”. As long as someone creates a new test class with the naming convention “Test<class_name>”, their tests will automatically run without having to tell the system to do so.


In ASP.NET MVC, views are automatically bound to their corresponding data entities as long as the same name is used in the view and the binding property on the underlying entity. This is great because in ASP.NET WebForms and other web frameworks, a decent amount of scaffolding code was marshalling the data from the view to the model and vice-versa.

Other Considerations

Whenever possible, I prefer to use convention over configuration to ease software overhead. However, there may be convention exceptions that need to be considered so the software can behave differently from the convention. This can be implemented with convention overrides or with configuration using a hybrid approach. I.E. convention and configuration.

As with any design principle, “convention over configuration” has to be considered in the context of the system in which it’s used to see if it makes sense to use.

What do you think of “Convention Over Configuration”? What other examples do you have? Do you have other patterns that drive system behavior without configuration?

Happy Coding,