Allen Conway's .NET Weblog

Exploring all things .NET and beyond...

Big News From Microsoft Build 2015 Day 1


As typical, there are usually some big and cool announcements made on the Microsoft .NET front in regards to the framework and surrounding technologies. Today at Build, 3 of the biggest announcements made were the release of .NET Core for Mac and Linux, the the release of Visual Studio Code, and finally the ability to compile and run Android and iOS app code in a Universal app for Windows.

The .NET Core release announcement will have the most impact for ASP.NET 5 (vNext) allowing one to build web sites and services on Windows, Linux, and Mac using .NET Core. Visual Studio Code will have an impact by being an all platform code editor which should give some competition to the likes of Sublime and Notepad++. Finally the ability to reuse Android and iOS app code to build and create Windows Universal apps will position Microsoft well going forward.

As a good friend and colleague of mine Anthony Handley said best, "This really IS a new Microsoft." This huge push for OSS and cross platform enabled development will certainly strengthen Windows 10 and Windows based development overall. Since it appeared Microsoft was running a distant 3rd in the mobile space both from hardware and software perspective, these moves to allow Android (Java / C++) and iOS (ObjectiveC) code to be compiled on Windows to make and run Windows Universal apps to reuse existing code is a winners move in my opinion. Combine this with the ability to run a portion of the .NET framework on Mac and Linux, you have a nice 1-2 punch strategy. This will certainly (and hopefully) bring Microsoft back into the picture as they drop the 'proprietary' walls and allow in cross platform app building.

As a modified version of the old saying goes, "if you can't beat them, join them, become best friends, and conquer the world!"

Microsoft releases .NET Core preview for Mac and Linux

Microsoft Launches Visual Studio Code, A Free Cross-Platform Code Editor For OS X, Linux And Windows

Huge news: Windows 10 can run reworked Android and iOS apps

Orlando Code Camp 2015


It was nice to see everyone that came out to Orlando Code Camp 2015! As I understand it there were 800+ attendees and a ton of great speakers and content. I enjoyed doing my presentation entitled, "Single Page Applications for the ASP.NET Developer using AngularJS, TypeScript, and WebAPI" There was a great turn out and was I was happy to be there.

For those interested, here is the URL to the GitHub repository with the sample app:
BowlingSPA GitHub

This is the slide deck from the presentation:


I really enjoy speaking at events put on by the Orlando .NET User Group (ONETUG). They are a fantastic group of individuals, and I look forward to hopefully speaking down in Orlando later this year at another user group event!

I'm Speaking at Orlando Code Camp 2015


Orlando Code Camp 2015 is almost here! This Saturday, March 28th I'll be down at Code Camp presenting on my session titled, "Single Page Applications for the ASP.NET Developer using AngularJS, TypeScript, and WebAPI" If you are interested in web development, or just curious about what SPAs entail this should be a great session to attend. 

The best part about Code Camp is it is FREE to attend and draws some fantastic speakers and attendees from all around. In all the years I have attended, I really think it's on par with some of the major software conferences and has many of the same speakers too. It's well worth attending to get some great information and have a chance to network with area peers. 

Check out the site to register, and hope to see you there!

Resolve Multiple Interface Bindings With Ninject

The old adage "program to an abstraction, not a concretion" reigns true and used in most modern application design via the use of Interfaces and concepts like IoC and DI. The polymorphic behavior of Interfaces and their ability to have multiple implementations allows us to do some really cool things as well as be staged for highly testable code with mocking frameworks like Moq.

However I'd say 99% of the time we typically have 1 Interface bound to a single concrete class using our DI framework. There will be cases where you will want to take advantage of having more than 1 implementation of an Interface and need to configure this.

Ninject is a great DI framework and you can achieve this through the use of named bindings. In this case if we have an Interface named ICalculate you could have 2 (or more) implementations. However upon injecting the class into a constructor, how would you dictate which instantiation/binding to use? The named bindings accomplish this as follows.

1. Provide a name for the bindings using the same Interface to allow them to be unique:
Bind<ICalculate>().To<CalcImpl1>().Named("Calculation1");
Bind<ICalculate>().To<CalcImpl2>().Named("Calculation2");

2. Specify the named binding as an attribute applied on the argument of the Interface being injected:
readonly ICalculate _calculate;
public MathCalculations([Named("Calculation1")] ICalculate calculate){
    _calculate = calculate;
}

It's that easy! For more information, see the Ninject documentation here.

I'm Speaking at Modern Apps LIVE! (LIVE! 360) Las Vegas

I'm excited to be speaking at the upcoming Modern Apps LIVE! conference co-located at the Visual Studio LIVE!, LIVE! 360 Las Vegas conference March 16-20. This conference track has a fantastic lineup of speakers including Jason Bock, Brent Edwards, Anthony Handley, Rocky Lhotka, and Kevin Ford with a variety of topics surrounding Modern Application Development. 
There is still time to save $500 using my speaker registration code: LVSPK30 Click on the banner below to go straight to the registration page.


Speaking

Here are the Modern Apps LIVE! sessions I'll be speaking at during the conference:

I hope to see you there and don't miss out on the registration savings above!!

Upgrading to Angular 1.3: Global Controllers Not Supported by Default

If you recently upgraded to Angular 1.3.x, you my get the following JavaScript error when trying to run your application:

Error: [ng:areq] Argument 'MyController' is not a function, got undefined

This issue is a result of some breaking changes where AngularJS no longer supports global controllers set on the window object as of version 1.3. In reality if you have a production application using global controllers, it is not advised and would be a prime target of refactoring regardless. However you might of had a small test app or the like that upon upgrading Angular to v1.3.x it stops working unexpectedly. The intention behind this change was to prevent poor coding practices.

The actual breaking change is highlighted on GitHub here: https://github.com/angular/angular.js/blob/g3_v1_3/CHANGELOG.md#breaking-changes-13

I like how the use of global controllers according to the change was for, "examples, demos, and toy apps." I agree with the statements, so I'm OK with this change. It really is code smell to use controller functions in the global scope.

Let's look at code that would have worked in Angular versions prior with a trivial sample:

<body ng-app>
    <div ng-controller="MyController">
        <input ng-model='dataEntered' type='text' />
        <div>You entered: {{dataEntered}}</div>
    </div>
    <script src='/Scripts/angular.js'></script>
    <script type='text/javascript'>
        function MyController($scope) {
            $scope.dataEntered = null;
        };
    </script>
</body>

The breaking change requires one to register the Controller with a Module to provide scope and pull it off the global window object. The changes required are shown below:

<body ng-app="SimpleAngularApp">
    <div ng-controller="MyController">
        <input ng-model='dataEntered' type='text' />
        <div>You entered: {{dataEntered}}</div>
    </div>
    <script src='/Scripts/angular.js'></script>
    <script type='text/javascript'>
        (function () {
            function MyController($scope) {
                $scope.dataEntered = null;
            };
            angular.module("SimpleAngularApp", []).controller("MyController", ["$scope", MyController]);
        })();
    </script>
</body>

You might find this will have the biggest impact going forward when you are throwing together quick demos or examples using Plunker or a small test harness. Just remember to register the controller with a Module to prevent running into this error. 

There technically is a workaround if you must make a fix quickly, but not advised long term. You can choose to set $controllerProvider.allowGlobals(); which will allow the old code to run. You can read about it here: https://docs.angularjs.org/api/ng/provider/$controllerProvider

If your apps have previously been constructed using best practices, this should not impact you at all. For additional changes between Angular 1.2 and 1.3, see the following link: https://docs.angularjs.org/guide/migration

I'm Speaking at Modern Apps LIVE! (LIVE! 360) Orlando

I'm excited to be speaking at the upcoming Modern Apps LIVE! conference co-located at the Visual Studio LIVE!, LIVE! 360 Orlando conference November 17-21. There are still a few days left to save $600 using my speaker registration code: LSPK17 Click on the banner below to go straight to the registration page.



Here are the Modern Apps LIVE! session I'll be speaking at during the conference:

MAH05: Building a Responsive Single Page App
MAF01 Workshop: Modern App Development In-Depth: iOS, Android, Windows, and Web

I hope to see you there and don't miss out on the registration savings that end 10/24!