Developing on Staxmanade

Leave yourself a breadcrumb for tomorrow.

Have you ever arrived at work and sat down, not exactly sure what you were working on the day before? You spend some time going through emails. Start looking at your codebase, maybe the last couple commits you made trying to get back into the mental groove you were in the day before.

There is a lot of information about how long it takes to get back into the programming zone. If you leave yourself a breadcrumb or two, it is much easier to get started when you come back to your task.

Some of my favorite breadcrumbs.

Leave a failing unit test.

If you practice any sort of test driven development, leaving a failing test to pick up the next day can be one of the most useful methods to get going again when you come back to the problem. If you’ve spent the time to think through the problem enough to write a failing unit test, this can help to ease you into the task at hand and get rolling the next day.

Explicitly leave a note or compiler error in the code.

Now, it’s probably common to check your working code in at the end of the day, but sometimes you just can’t work it to completion. That’s ok, and if you use a tool that supports something like this, leave yourself a breadcrumb of one or more compiler errors.

If I’m writing some C# I sometimes use the #error precompiler directive with a helpful message.

image

This allows me to come in the next day. Hit build on the project and immediately see where I was in the codebase last and need to pick up again.

Other, less specific, but useful options:

  • Send yourself an email describing what you’re working on and what still needs to be done.
  • Write in your favorite notes app. I like to use OneNote to keep track of my ‘scrum notes’ which help me describe what I did today and what I plan on doing tomorrow.
  • Sticky note? (can’t say I’ve used a pen/paper in a while – but if it works for you go for it)

It doesn’t have to be anything special, just a little note to yourself that can help you get a jump start on your next task at hand.

What other methods do you use to get back into the problem at hand?

Convert an existing WinJS app to use TypeScript

I recently published a little sample project up in the ToTypeScriptD github organization that walks through converting a new Windows 8 WinJS application to TypeScript.

It’s intended to show some of the basic first steps it takes to convert a project over to TypeScript and also how you can leverage ToTypeScriptD to help automatically generate .d.ts based on the windows *.winmd assemblies.

If you’re writing any TypeScript WinJS apps, feel free to check it out. I’d appreciate any feedback you have that can improve on this guide’s steps/approach for porting an existing WinJS library over to TypeScript.

Happy Scripting!

Introducing ToTypeScriptD - Automatic TypeScript Definition files for C++/CX or .Net assemblies

If you’re unfamiliar with TypeScript, I’d highly recommend checking it out. It’s my new preferred way to write JavaScript based applications.

If you write an application in TypeScript and need to interact with an external set of either JavaScript or C++/CX dependencies then you will quickly find that you are going to be mucking with some TypeScript Definition files and the more you take a dependency on the WinRT runtime the more type definitions you probably need to manually create.

It’s true that the TypeScript team has created a set of TypeScript Definition files for WinRT and WinJS, but I couldn’t get any comment as to how they were generated. And the more I looked into what was provided, the more I realized that there were inconsistencies and inaccuracies that were not good. Which led me to believe that they weren’t working on a super-secret tool to automatically generate these for us.

What is ToTypeScriptD ?

ToTypeScriptD is a quick little attempt at automatically taking the type system provided to us by a C++/CX winmd or .Net assembly file and projecting that into a set of TypeScript Definition files. This tool can basically take anything that is Ecma 355 Common Language Infrastructure (CLI) and spit out a .d.ts file for you automatically.

Why would I need this?

In the project readme I describe two use-cases that I know of (so far).

  1. If you build a 'Modern' (come on, we still call it Metro) Windows 8 app with WinJS and want to leverage TypeScript, wouldn't it be nice to get a set of TypeScript Definition files that reflect the native API's you're calling in the platform without manually creating the definition files?
  2. Say your building an MVC/WebAPI server application. It would be useful if your C.I./Build system could generate a set of TypeScript interfaces that were based on the server objects used to render your JSON API. This can be useful for client side JavaScript/TypeScript libraries that need to consume these objects and also provide a simple way to document the format of the input and output API response objects.

How do I get the project and start using it?

Before you install the tool and dive in head first, I would like warn you that I have only been working on this for about 2 weeks (in my off-hours) and there is going to be lots of room for improvement. But it’s currently generating a solid set of .d.ts files for .winmd files.

Head over to the project home page and check out the Readme for some quick-start information.

I’d would love to hear feedback. If anyone is interested in helping out, you can submit new issues or review the open issues list and start submitting pull requests.

Happy TypeScripting!

TypeScript Presentation at the Northern Nevada Software Developers Group (NNSDG)

This past week I gave a talk on TypeScript which was fun and well received.

If you have any interest in the slides they are hosted up on GitHub

Or if you just want to look at the talk in MarkDown

The markdown page is useful for a quick lookup on syntax if you forgot how something should look. I’d like to continue to evolve the presentation, so if you have any feedback or suggestions, please feel free to open a pull request and start a conversation.

Thanks to those who attended!

Authentication error connecting to Git on TFS

I’m throwing this out there since I couldn’t find much on this specific problem. #payingItForward

Problem

I struggled getting the git command line to authenticate with Git Team Foundation Service online.

My current environment is Windows 8, msysgit, with the git-credential-winstore tool installed. (Love that credential tool)

When I first tried to (push, fetch, or pull) from a newly created TFS Git repository I received git-credential-winstore authentication dialog, entered my credentials and received the following error,

Failed to erase credential: Element not found
fatal: Authentication failed

After googling that error I found this link http://blog.jennysjottings.co.uk/2013/01/20/github-glitch/ who’s approach did not work in my case.

Solution: Short Version

  1. Log into your TFS account (online)
  2. go to your account settings then credentials
  3. setup the alternate login

Solution: Long version

  1. First go to the following link:  Use Git  and XCode with TFS
  2. scroll down to the section titled:

    Enable basic authentication for your account

  3. Follow those directions
Hope this helps.

Happy Git-ing!

RichEditBox gives UnauthorizedAccessException (Access is denied) error when SetText called.

While working on a little WinRT app I recently spent WAY too much time trying to figure out why I was getting the following exception

System.UnauthorizedAccessException was unhandled by user code
  HResult=-2147024891
  Message=Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
  Source=Windows.UI
  StackTrace:
       at Windows.UI.Text.ITextDocument.SetText(TextSetOptions options, String value)

when all I was trying to do was programmatically set the text of a RichEditBox. EX:

theRichEditBox.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, textValue);

After searching and searching and eventually taking a walk to cool down, I decided that I would play with the IsReadOnly flag. I have it set to “True” in the XAML because I don’t want users to edit the text. I then wondered if this was causing the problem.

I tweaked the code as shown below and it magically started working. Notice how I’m turning off the IsReadOnly flag off, then setting the text, and returning the read only state after the text has changed.

theRichEditBox.IsReadOnly = false;
theRichEditBox.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, textValue);
theRichEditBox.IsReadOnly = true;

Dear Exception: you were not helpful. Sigh.

Windows 8 Share Charm Data Inspector

In a previous post I mentioned I would share the app I created during a Windows 8 hackathon event.

I spent some more time adding polish, testing, re-thinking my initial designs and today, I’m excited to say that it is now in the app store!

What does this app do?

The Share Data Inspector is an application that allows you to inspect the details of data being shared from other applications through the Windows 8 Share Charm (Win+H).

For example, if you open the Video app, select a movie and use the share charm (Win+H) to share the video, what data is actually shared? The Share Data Inspector will appear up as an application you can share the just about any data with and you can inspect at a lower level what values are shared.

This application will give you insights into data that you never thought was being shared.

How do I get the app?

Open your Windows 8 App Store and search for “Share Data Inspector”. (or click the link “View in Windows Store” button.

I’d like to suggest a feature:

If you’ve downloaded the trial app and would like to see some improvements. Head over to this site, suggest a feature and help this application grow from a hackathon created app into a full-fledged application.

Happy Sharing!

Windows 8 Hackathon: Good for participants. Bad for Microsoft.

Last weekend I participated in a Windows 8 hackathon. In 24 hours of coding I had an app created and submitted to the App Store for certification.

24 hours to create an app?

I'll share details about the app I created in a future post. For now, I have since removed my app from the review process in the Developer Portal.
Before I get into why I (temporarily) removed my app. I would like to first talk about a number of the real benefits I saw with the hackathon.
  • I work from home as a remote employee. Don't worry I'm not at Yahoo. The event was a fun change of pace; working in a room of developers hacking away on their own ideas. You could feel the energy and this energy is probably why it was possible to burn the midnight oil hacking on my own app.
  • This contest forced me to work all the way through submitting an app to the store which I believe to be more of a mental hurdle than an actual one. This process was definitely made easier with Microsoft on hand to answer questions and get over some of the non-obvious steps in the process.
  • Working in a room with the others proved to be useful when you got stuck on something. Shouting out 'I'm stuck on problem X’ and have someone there to point you in the right direction and unblock you is great.
  • The short timeframe forces you to focus on your Minimum Viable Product. Work on what is necessary and avoid getting side tracked.
  • Related to the focus above I really got into the zone hacking away at my app; this certainly reminded me of why I love this profession.
  • Meet developers in the area.
  • Learn interesting problem domains and how others tackle them in their apps.

Now, why am I really writing this post?

I believe Microsoft is shooting themselves in the foot with how they are running these hackathons.
I can’t say I speak for how the hackathons are being run, but my experience showed me the following.
With Microsoft’s own employees running these events and not giving a lick to the quality of the applications being submitted they are setting themselves up for failure.
I can see from a marketing perspective that having a large number of apps in the store will help them drive more people to their platform. That’s crap. There are far too many reasons Microsoft should be driving QUALITY into the store and not quantity.
Let’s list a few reasons this is going to backfire:
  • NOBODY wants to use crappy apps developed in 24 hours. NOBODY!
  • There are very few apps that can be written in 24 hours without maintaining some sort of a quality bar.
  • The certification process will get clogged causing the testers to care less about finding quality issues and pounding through “numbers”.
  • We'll have a huge collection of crappy apps where the sheer number of apps will make finding a good quality app nearly impossible.

How can they make this better?

Something interesting about this is generally when you talk about Pros/Cons to something, you have to give-up something to fix a Con and that sometimes means taking away from the Pros.
However, I feel like we can keep ALL of the pros I listed above while also reducing the amount of Cons if only Microsoft incentivized their employees to drive quality into the store.
  • Do – push people to get an app done and help them through the app store
  • Do – provide guidance around how to build-in quality
  • Do – provide some metrics that will help the app succeed in the end (design, best practices, possibly even saying, “That’s been done”)
  • Do – recommend they cancel submitting their application if it hasn’t met the developers quality metric. (This isn’t going to save the app store, but would help to reduce the number of write-once-let-die-in-the-store apps)
  • Don't – offer a prize for "the most apps submitted" within 24 hours.
I’ve developed on the Microsoft platform for a long time and really hope there is a place for the Microsoft App Store in the future, but with their push for a large number of apps they’re not setting themselves up for an easy road back in the game.

DefinitelyTyped TypeScript definitions now on NuGet

I recently started playing with TypeScript on an asp.net MVC web application.

We're leveraging some third party js libraries and found the type definition files over at DefinitelyTyped a huge help when dealing with libraries not originally written in TypeScript.

The first thing I tried to do was add them via NuGet and when I didn’t see them up there, I strolled to the DefinitelyTyped issues list and saw an open GitHub issue requesting the functionality.

So I took on the task. Created a PowerShell script to automate publishing and synchronize changes to the DefinitelyTyped repo up to NuGet.

This morning I pulled the trigger and published 127 different NuGet packages for each DefinitelyTyped TypeScript definitions.

As an example:

If you ran this in visual studio NuGet Package Manager console

Install-Package angularjs.TypeScript.DefinitelyTyped

You would get the following installed into your project

image

Note how we didn’t ask it to install jQuery? The powershell script leverages the reference path:

/// <reference path="../jquery/jquery.d.ts" />

in each TypeScript definition to help determine dependencies. We then configure the NuGet package with a dependency on the jquery DefinitelyTyped TypeScript definition package.

image

 

Happy TypeScripting!