Using CSS Modules with Angular, TypeScript and Bootstrap

posted on 21 February 2018 in programming

CSS is simultaneously both the simplest and hardest programming language at once. What could be simpler than selectors, properties and values? And yet how quickly can CSS become an overwhelming mess, paralyzing unsuspecting developers who are too afraid to change a style because it’s hard to find and test all it’s usages, so they just add another style to the mess.

CSS Modules aims to alleviate a lot of these problems by scoping styles to a specific component, so other page styles won’t conflict with your component and your styles won’t leak onto other areas of the page.

Read Article

Faster AngularJS tests using the component driver pattern

posted on 13 February 2018 in programming

When writing tests I prefer to test multiple functions and their interactions at once, rather than constraining a test to a single function or unit. This ensures that the test operates in more realistic way, and avoids maintaining unnecessary tests over code paths that can’t be reached.

Protractor e2e tests for AngularJS interact directly with the DOM and usually provide more value than unit tests. I’m not interested in whether a controller behaves a certain way, I’m more interested in what happens when a user clicks a certain button on a page. But protractor tests are slow. In the largest AngularJS project I manage, there are over 300 protractor tests that take up to 15 minutes to complete, that’s a very slow feedback loop. In order to bring the test time down I’m turning back to AngularJS unit tests, using the component driver pattern to still inspect and interact with DOM elements.

Read Article

Write AngularJS like it's 2018

posted on 07 February 2018 in programming

When React became mainstream it changed the way we thought about writing single page JavaScript applications, it promoted readability and maintainability over abstracting complex interactions. These principles resonated with the JavaScript community and influenced the development of Angular, unfortunately many of us are still stuck maintaining AngularJS (Angular 1.x) apps that are growing ever more complex.

This post presents 9 tips for writing better AngularJS based on more modern principles. These tips are the distilled learnings from working with a team of developers managing an AngularJS app over the last 3 years that has grown to over 25,000 lines of Angular.

Read Article

Vanilla MVVM for Xamarin Forms

posted on 19 December 2017 in programming

Want to do MVVM without the frameworks? Xamarin Forms provides everything we need to implement the pattern and make our ViewModels testable.

Note that some naming, patterns and code have been borrowed from the excellent FreshMVVM framework. This is a great lightweight framework to get started with if you don’t want to roll your own.

Simply put, MVVM helps us to abstract any UI logic out of the View and into a ViewModel to make it testable, while the data and business logic remains in the Model.

To avoid boilerplate code we’re going to create a couple of base classes, one for our Views, and one for our ViewModels.

Read Article

Advanced Redux in Xamarin Part 3: Database Middleware

posted on 21 July 2017 in programming

In this final post in the series on advanced Redux in Xamarin, we'll look at how to integrate a local database with Redux, we'll write Middleware that intercepts CRUD Actions and applies them to our database.

Read Article

Advanced Redux in Xamarin Part 2: Persistent Actions Middleware

posted on 20 July 2017 in programming

In this second post in the series on advanced Redux in Xamarin, we'll look at how to persist Actions so application state can be restored when the app restarts. We'll do this by creating Middleware that will intercept each action and save it to a persistent store, then rehydrate the application state from that store on app startup.

Read Article

Advanced Redux in Xamarin Part 1: Action Creators

posted on 11 July 2017 in programming

Redux is an implementation of the Flux architecture that manages UI changes through a single global State object that can only be mutated by dispatching Actions. It provides a way to easily reason about state changes and to share that state across multiple separated areas of the UI.

Originally developed for React in JavaScript, it’s now finding its way into other languages, there are a number of implementations of Redux in .NET (e.g. Redux.NET, YAXL.Redux and Reducto). Rather than rehashing the basics of how to use Redux in Xamarin (there are plenty of good articles), in this post series we’ll look at some more advanced concepts, starting with Action Creators.

Read Article

No iOS code signing key matches provisioning profile

posted on 06 July 2017 in programming

Recently my team have come up against this error a few times building a Xamarin app using Visual Studio 2017 both on the Mac and PC, and it took a bit to work out the fix.

No iOS code signing key matches specified provisioning profile ‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’

Read Article

Two's company, three's a mob: Mob programming

posted on 26 April 2017 in programming

First there came pair programming, a development disciple that promised team collaboration, improved quality, inbuilt mentoring and redundancy. Now the development community is taking it to the next level - mob programming. Mob programming, or mobbing, is where the entire team works together on a single problem, sharing one PC, one keyboard and one mouse.

Read Article

Starting a promise chain to handle exceptions correctly

posted on 04 January 2017 in programming

Here’s a little promises quirk that I’ve overlooked for a while. Generally we all write promises like this:


And we know that any exception raised will skip to the catch handler. Except for the initial doSomething() call. If an exception is raised here it will be treated like a normal exception and stop executing all the rest of your code. So how do you deal with it?

Read Article