Agile doesn’t work if your code isn’t

I’ve worked on a few software projects over the years and many of them have been run within an Agile environment.

Agile is a software planning methodology where the work is carried out in small chunks, the requirements are listed in a backlog, which is worked on through these small chunks of development time, called sprints. At the end of a sprint a piece or pieces of work are delivered. This allows software teams to move quickly through the software requirements, be able to deliver software quickly and be able to handle changes in requirements as they go, become agile in the direction they move forward

This is the general theory, unfortunately from what I’ve seen over the years teams that have a Agile project management methodology, but who’s software is still built using a pre-Agile approach struggle to deliver what Agile promises.

The reasons for this are, if your software architecture is still very closely coupled, meaning one layer (the front-end) can not be fully developed in separation from the backend. It is extremely hard for the developers to make quick, fast changes because they run into numerous issues. They may have to wait for the backend team to make a change to an API in order to provide data that the front end needs, if there is no tests in place there isn’t the time for tests to be added or new tests to be written. This can lead to bugs coming into already delivered software and as the team moves forward in their Agile way, the time available to fix bugs and write tests gets less and less, leading to the possibility of the bug list growing and growing.

Implementing an Agile software project management approach is far easier than moving an large enterprise application to being able to be worked on in an Agile way. Arranging two week sprints, setting up a task list board and having a backlog and your ready to go is far easier than getting your software setup to be Agile, but it is possible.

The key to solving these problems is moving the architecture of the project to a more separated approach. Where each layer can be developed on independently, and doesn’t rely on another layer having a new piece of functionality in place before work can start on a new feature.

Dividing the work in a sprint between delivering features and updating the architecture of the application to be more separated allows, over time, the project to become more in line with an Agile approach. The developers can amend the application so the front end can run in separation from the backend. The UI layer can be written in separation from the front-end layer, allowing the UI to be mocked to show users how new features could look so feedback can be given earlier in the process. Leading the feedback being added into the sprints work load before all the other layers have implemented a feature.

Modern web tools can help

Using more modern web frameworks and tools can help. Using something like Angular to build just the front-end Logic, while the UI is built by another developer. This UI can be what is demonstrated to the end user in sprint planning when gathering requirements so the entire team knows what is expected. Using frameworks like NgRx and Nx workspaces allow the Angular developers to move the Angular code add to a consistent pattern that all the Angular developers on the team can follow, leading to a consistent structure allowing any of the Angular developers to work on any part of the application (especially if this is a large enterprise application) without much ramp up time. This can be extremely beneficial for distributed teams or teams with offshore developers.

Tools like NestJS or Node can allow the front-end team write mock endpoints which they can use to build from, while the backend team works on the real production ready APIs.

If the structure of the response is agreed upon, in sprint planning, then the mock APIs (which could return static Json) should be fine to get started building against.

Agile Can Work

Agile can really work as a way of managing the workload of a team, but without an architecture that can support quick code changes bugs will linger and more and more time will need to be spent on fixing issues.

An agile project management approach with a flexible approach to the codes structure will lead to applications that can be delivered quickly.

I like the Agile methodology, but we need to consider the structure of our existing code before going head first to a fully agile approach.

IR35 and it’s possible effect

IR35 is looming over all contractors in the uk, it could be in place in April 2020, and there no doubt if it does come into full effect, then it will change how contractors operate.

For those who don’t know about IR35 then it is new legislation where the uk government is trying to stop those contractors who have been working as full time employees but still being paid on a contractor rate.

The idea is that if you have a contract where you are employed to work for a firm in a role where a full time employee could actually do the role, the. You as the contractor needs to prove that your contract is actually outside the IR35 guidelines. If it falls within. The IR35 rules then you will have to pay the same level as tax that a permanent employee pays.

This is a high level overview of IR35 it is worth really looking into the official government websites in order to find out more about IR35.

How IR35 could change how I work

For me if the IR35 rules do become law then it will change how I currently work. I would have to only take on contracts where it is clearly set out what the project is be working on and when it is expected to finish, to show that I am only employed to work on that project. Another way to show that the contract is outside IR35 I’d need to show that I’m not needed to work onsite, instead I’ve been employed to work as a consultant on a single project, and it’s up to me on how and where I work on this project. So if I want I could say that I work only from my home office or a specific work space. I’ll also need to show that I’m using my own equipment to work on this project, though I could see this being an issue for some large organisations where for security reasons they want people working on their projects to use equipment the company provides.

These changes, aren’t to much of a change for how I currently work, I think it makes me work in more of a freelance working model than a contractors who just works as a extra resource for a company who comes into the office day to day and just works on the same project.

How will this be effecting recruitment agencies

If IR35 does come in it could have some serious changes to how recruitment agencies work. They will have to now find developers who can work on a project instead of getting in an extra resource for a company. It will be interesting to see how they will be changing or will they leave the contractor market altogether and just concentrate on sourcing full time employees?

The contracting market is going to be interesting in the coming months, does this mean I’m looking to go permanent? Well, no. I enjoy working for myself and if the IR35 rules are changing to me needed to work more as a project specialist then that suits me.

I enjoy working on Angular and Angular based project, so if you are looking for an Angular specialist to work on your next web application project, feel free to contact me.

Using Angular Elements for a micro-frontend
Photo by Ricardo Gomez Angel on Unsplash
Photo by Ricardo Gomez Angel on Unsplash

For my latest client, I was asked to look into how we could structure an Angular application so it could be developed in different sectors.

The application is made up of 12 major sections, each section performs a certain task within a workflow. So while each section is linked, they each have their own set of APIs which they use.

We also wanted to have each section be set up so it could be developed by different developers within a distributed team.

So we have one large parent application that manages the login and main navigation. Then within each section, we have a complete sub-application.

Possible Approaches

There were a couple of approaches we could take, one was to load each sub-application within an iframe, but this means that each sub-application cannot have data past into in via @Input() properties and, well frames are an old approach.

We could have created a monorepo, which are extremely popular now in Angular, but the client has already built some of these sub-sections within their own repos. They didn’t want to start changing their approach to their repo structure. Sometimes as a consultant, while you know there is a great new way of tackling a problem you need to hold back and follow how the client wants to work.

Enter Angular Elements

So with these constraints, we decided that a better approach would be to use Angular Elements. With Elements, we could create each sub-section application as a stand-alone app, but still, be able to ‘package’ it as an Angular Element. Then each of these elements can be loaded in the main parent application as a web component.

Another great benefit of Elements is that when we want to make an update to a sub-section, we can simply generate a new main.js file for that element. Then we just replace the new main.js file for that element in the main parent application. Then when the user reloads the parent application the new updates to the sub-section are available. This was a great benefit as it means that when making updates the parent application can still keep running. As this application is being constantly used being able to keep it available and make new releases was a real problem for the client and being able to solve this problem through using Angular Elements was win for the client.

How I implemented this solution

To start with I created two smaller applications, one for each sub-section. Then using the ngx-build-plus library from Manfred Steyer, I managed to build a single file, the main.js file.

Then I created the parent application, for this app I used NgRx because as the functionality of the parent application grows I want to use NgRx to make the app more Reactive.

In this parent app, I built out the login functionality of the app, when a user has successfully logged in we store some needed details in session storage. This data can be accessed by the Angular Elements when they are loaded.

So the parent app has two main routes, one for each sub-section, then in each route, we have the main component that acts as a homepage for the section. This ‘homepage’ component is where each Angular Element is loaded.

Through using Angular Elements we can take these large scale applications and break them down into smaller micro applications. That are easier to develop across a team.

Next Steps

Moving forward, we’re planning on building out each micro application, so they are full-featured apps that can be loaded as Elements.

If you have a large scale application, that either needs to be upgraded from AngularJS to Angular or needs to have sections of the app rebuilt as part of a refactoring project. Then using Angular Elements as a way to make smaller changes over time instead of one large re-write is a great way to go.

Thoughts on NgRx

I’ve been using NgRx for a short while now and I thought I’d write up some of my initial thoughts on it.

Getting started can be tricky, it is a steep learning curve, but once you understand what each part of the framework is for and the underlying approach NgRx is taking a then it’s easy to get going.

One complaint about NgRx is the amount of code you have to write, the number of files you have to generate in order to get something working. For me I don’t think this is such a problem with file is designed to do one thing and one thing only. This separation of concerns makes reading through an NgRx based code base easy to understand. When you open one of these files, a reducer for example, you know exactly what that files role is, what is does and how it works. It’s just concerned with the one thing and shouldn’t have any other unrelated functionality in that file.

With today’s modern editors it makes switching between files so much easier and faster. If you had to use Eclipse to write NgRx you would definitely have a case to complain about the number of files.

One of the things I really like about using NgRx is this prescriptive approach it takes. As a contractor I have to work with a new code base every few months and being able to ‘get up to speed’ with how an application works can take a while. Even though they are all Angular applications, I find that there are 100s of ways an Angular application can be structured, based on the needs of the business or the experience of the developers who have worked on the app.

If an application has a good developer, who thinks about and plans how to write their code, and a business who are concerned with the quality of the product over just getting things done. A applications codevase can be well structured without NgRx, but through using a framework like this means that the code is well written and based on good practices.

So when someone like me starts working on the project I can go through the application and see how data is passed through the app, how actions are being used and when and how the application flows.

So I’m enjoying using NgRx , it definitely has its place, in developing large scale applications, with a team of developers working on the application for other projects NgRx isn’t the best approach, but for a large application it’s a great choice of framework.

Using NgRx with Elements

Recently I’ve started a new project where we plan to restructure a large application into smaller, more manageable individual projects.
As well as dividing the application into small modules we want to set out a way that all the developers on the team can write each part of the application in a consistent way.

One approach we’re looking at in using Angular Elements with NgRx. Each individual sub-section of the application is loaded into the main parent application as an Angular Element and NgRx is used as the framework for having a consistent pattern through each application on how data and state is loaded.

I’ve used NgRx before, especially when writing a introduction to NgRx chapter of my book, Getting Started With Angular 8. So if want to learn about how to use NgRx check the chapter from my book. Using NgRx with Elements is something new to me, so this was an interesting exercise.

In a previous contract I’ve used Nx as a way to create something similar. We used Nx to manage all the sections of the application we created as Angular elements and generate a library which was used across all the sections of the application to share common functionality. This worked really well, but it did lead to all the code being in a monorepo.

In this new project we don’t want to have a monorepo, instead each sub-section is in its own repo. This allows a developer to get the single project and it makes managing the deployment easier. There are many pros and cons to using either a monorepo approach or not. For this client, the multi repo approach is what they have in place.

Using Angular Elements (which I admit when I first heard about Elements I wasn’t to sure on the benefit it would bring) is allowing us to really separate out each sub-section so they can be developed as a single application in its own right. Once the application has be built and tested it can be packaged up as an Element and loaded into the parent application. We’re using Ngx-build-plus to manage the build of the elements which takes a lot of the work out of creating a single bundle for the Element.

The use of NgRx is allowing us to write a cleaner code base, I know NgRx has a lot of boilerplate code, but it is a consistent pattern and if multiple developers are working on multiple parts of the application. It can lead to a lot of repeated code, bad habits can appear in the code base. Using NgRx means that if a developer picks up a different sub-section to work on they can follow along with the structure NgRx defines. This makes fixing bugs, adding new features and working out how an application works easier. We’ve all been there where we’ve take over a project written by another developer and a common question you ask yourself is ‘why have they written it like this’. Well with NgRx that’s not a question we should be asking.

It’s early days with this approach, we still need to test this further to make sure there aren’t any further issues that we may run into before we completely switch over to using Elements and NgRx, but so far I think it’s a good approach for developing large enterprise applications if you don’t want to us a monorepo approach that Nx prescribes.

What’s been happening at CGCSoftware

We’re into September now and I thought I’d give a small update on what’s been happening behind the scenes at CGCSoftware towers.

The main thing that has happened is I’ve started a new contract working for Cambridge Assessment. Working in one of their teams on a large scale Angular application. It’s an interesting project working with NgRx and Angular Elements to create a more loosely coupled application allowing different developers work on individual sections of the application, but still access the APIs that run the application in a consistent way.

I’m finding working with Angular Elements really interesting, they have real scope to give so much more flexibility in how Angular applications can be set up. Not only are they great for gradually upgrading an AngularJS application to Angular. They allow teams to create individual parts of a large scale application in separate pieces which can be slotted together in the main application.

The second big thing that has happened is that my book, Getting Started With Angular 8, has been released.

Writing a book has been a massive project, it’s taken far longer than I thought it would, but I’ve learnt so much through writing the book.

Not only have I learnt more about Angular, but how to create content for the book. Originally you think that it’s just a simple case of writing out you thoughts on the topic of the book (in this case Angular) but there is so much more that you need to think about. How to structure the chapters, how to make sure the reader is left feeling that they have learnt something, how a section you felt made sense when you originally wrote it, didn’t make sense at all.

Having published the book through Leanpub I can make further updates to the book as newer versions of Angular come out or new features are added.

So August has been busy, I did manage to get a holiday in as well, which was great. Now we’re into September and got another busy month ahead. Looking to work some more with NgRx, while still getting up to speed with how things work at the new contract. Also looking at ways to be involved in some more open source projects in the coming months.

Reactive Programming, a shift in mindset

As part of my upcoming book Getting Started With Angular 8, I spent a time researching Observables and RxJs in Angular. In the book I spend a complete chapter going through how Observables work and how RxJs is a JavaScript library that comes with Angular, which helps with working with Observables.

While this chapter gives a detailed explanation of using Observables and Observers, how you use them within your Angular applications.

One thing I have noticed now within the Angular community, there are more and more talks and articles about how to make use of Observables and RxJs to create fully reactive applications.

Now developers are beginning to understand what Observables are and what RxJs brings to their applications, the next question is how can we make use of this to the benefit of our applications? More and more community leaders are showing ways we can use RxJs to make applications more reactive.

Changing the mindset from imperative to reactive

In the Observables and RxJs chapter of the book I go through how to use and Observable with RxJs, but the approach I use is a more imperative approach. Where we create and Observable, set it up and then Subscribe to the Observable when we want to make use of it.
Now after seeing some fantastic talks from NgConf about how we can make use of RxJs to turn how we setup our Observables to make the way data is passed throughout the application more reactive.

Some of the great talks that show this new approach are:

  • Data Composition with RxJs – in this talk Deborah Kurata show a pattern for creating streams of data with RxJs to generate a View Model behind our components. Models that load data via Observables that don’t need to be subscribed to.
  • Mastering the Subject: Communication Options in RxJs – in this talk Dan Walhin shows how we can use the Subject observables to pass data or messages to multiple components within our application.
  • Thinking Reactively – Mike Pearson goes through why thinking in a more reactive approach is a great idea. He makes some fantastic points about why taking this reactive approach will benefit our applications.

Having a more reactive mindset means we use patterns to structure how data is passed into and out of our components, so the application reacts to changes from the user. Building applications this way makes our apps appear faster and more responsive to the user. A fast acting application makes a happy end-user.

As Angular developers I think we should start sharing different approaches to how we can write more reactive Angular applications. If we look at sources from outside Angular, like existing patterns which may not be used currently in this imperative approach. These patterns will help us develop in a more reactive mindset.

These talks are a great starting place if you want to start take your knowledge of Observables and RxJs and how they can be used to making a more reactive application. If you’re not sure how to use Observables and RxJs then feel free to check the chapter in my upcoming book.

Angular and Nest idea for fullstack apps
Photo by Steve Halama on Unsplash

I’ve recently worked on a project where we found ourselves in the situation where we was waiting for some APIs to be developed by the backend team. So in order to not stop our development we decided to look at creating mock APIs.

Now there are many online services that can provide you with a mock end point to work with, but there are limitations with the number of endpoints you can make or the structure of the data you can return.

So we decided to take a look at using NestJS in order to create our mock APIs. First impressions were really positive, as an Angular developer I found getting started with Nest very easy. With Nest using similar concepts to Angular (Services, Modules etc) I found Nest a great way of adding a backend to my Angular application, Nest is something I plan to look at further.

I can see that there will be two approaches to creating a fullstack application, one approach seems to be ReactJS with Node/Express and the second approach is Angular and Nest. If you look at the job market you’ll see a lot of roles where the tech stack is React and Node in order to create a complete fullstack application. Now with Nest becoming more and more popular I can see Angular and Nest becoming a tech stack for creating a fullstack application.

If we look at how Nrwl are developing enterprise applications they are taking this approach of using Angular with Nest as their stack for their clients. As a side note when we decided to create our mock APIs we was using Nrwl’s Nx service, which makes managing the setup of a complete Angular/Nest application so easy and with the addition of Cypress it makes a fantastic complete approach to creating a full stack application.

As an Angular developer I would recommend that any Angular developers look at using Nest even if the applications they build are using APIs created in another language by another team within their organisation. The reason I think we should look at Nest is because if, like I did in this application, you have to wait for the ‘real’ APIs to be ready you could use Nest to create a mock APIs.

Eventually I can see the Angular/Nest approach becoming a standard way of building fullstack applications, which is something I’m planning to work on while I’m between projects.

Writing a book is hard, but worth it

For the last 6 months, I’ve been working with Packt publishing writing a book on Angular. This is the first time I’ve ever written a book and it has been a big old slog of work, but it has been worth putting in the work.

We all see these ‘famous’ developers who have written books, attend all the conferences and even find time to work on open source projects and while it’s not a good idea to compare yourself to others, sometimes you can’t help yourself. So for the last year, I’ve had an idea of writing a book, but never actually started. Then I was contacted by Packt asking if I’d be interested in writing for them. I think they had read some of my blog posts and were interested.

This was the push I needed, and so I quickly replied to them and said yes, my life as an author has started. But if you’ve never written a book you can be completely unprepared for what you need to do. I wish I had either asked someone about what is involved in writing a book before I started, it may have put me off.

So what you need to know before writing a book is, first, no matter how much time you think it’ll take it will take longer. I originally thought that I’d find enough time in the day to write and then be able to make good progress on the book. You see I work for myself as a contractor, so if I don’t work I don’t get paid. I needed to carry on working as I write the book. I did think that it’ll be easy to work all day and then write for a couple of hours in the evening. Unfortunately, this did not happen every day, first of all, you finish a days work and your brain doesn’t have the capacity to then switch from coding all day to writing. It’s hard to concentrate, what you write makes no sense and you just can’t think about coding after spending all day working as well.
So I thought I’d spend more time at the weekends writing, but soon life gets in the way. You need to spend time with your family or there are things to do around the house. Your plan of spending all day Saturday and Sunday may soon turn into an hour on Saturday and a couple of hours on Sunday. (Thankfully my wonderful wife is very supportive of me and was happy for me to work on the book when possible).

I soon found that getting up early and spending a couple of hours in the morning helped. I was getting up at 6am and writing before work started. I had a contract where I could work from home, that helped a lot.

The second thing you need to know about writing a book is that you need to be consistent. Writing every day if you can, even if it’s just an hour helps so much. Getting that daily writing means that you can carry on from where you were in the previous day far easier. You can get ‘into’ writing quickly, ideas for what you are going to say come to you easier because you’ve got ideas flowing from you. It’s like pushing a large ball up a hill, the more momentum you get the easier it is. Momentum is key in writing a book.

You’ll also have to be comfortable with feedback on your work. As I submit chapters to the publishers they are reading and reviewing them. Which means I get feedback on what I’ve written, now if I’ve written a section or a sentence that I think is fine, but the publisher thinks it’s confusing or needs some more work, you have to be comfortable with this feedback and respect the experience they have. I may know about Angular, but they know about books.

Not only do you need to be consistent and declined you also need to have a detailed plan of what you’re going to write. Before I started I need to provide an outline of the book, what the chapters are, what the reader will learn in each chapter and how many pages you’ll have in each chapter. In hindsight, I wish I had spent a little more time on this plan than I did. I guessed the number of pages for some chapters and you will have to fill those pages. So if you think you can write 40 pages on Unit Testing, you may find this hard, think about it that’s about 12,000 words!!!

Now, not only do you have to write the text for the book you need to find the time to write the supporting code for the book too. This can take a large amount of time as well and needs to be something to consider if you’re planning on starting a book

Now, while I found writing a book hard I do think to go through the process I’ve learnt so much about Angular, the topic of the book. Having to explain concepts to someone is the best way to learn and to find out what you do know about a topic and what you don’t know. You really have to research and understand a topic before you can write about it. Gaps in your knowledge will be filled in through this research.

So would I go through this again? I think I would, but maybe on a smaller scale or through self-publishing. I have been thinking about writing a smaller book on a topic within Angular, something on NgRx maybe.

Writing is hard, it takes planning, time and dedication, but the learning you’ll do through writing is a great benefit.

My book isn’t out yet, hopefully soon, just going through the last reviews and amends now, but when it’s out I’m going to let as many people as possible know, and hopefully, someone will even buy it.

Show Some Love for the Angular CLI

I’ve recently listened to the latest episode of Adventures in Angular, a great podcast. In this episode they were discussing the merits of the Angular CLI, what it does for us as Angular developers, how much is saves a company on time and money.

The Angular CLI makes writing Angular applications so fast and easy. Before the CLI we had to handle all the build steps ourselves, using tools like Grunt than Gulp. Both fantastic build tools, but having to fight our way through JSON config files was not easy, especially if you wanted to create the ideal setup for your project. It would take days of tweaking the config settings working on the ideal build process.
Then you had to share this build setup with your other team members, and if one thing was different on their system, then the build would fail for them, it was a nightmare.
Thankfully the CLI has taken all that away from us, now there is one universal way of building and running an Angular application locally, which works the same for all members of a team.

Another great benefit of having a CLI is that we no longer have to worry about what build system a project is using. Whether it’s Grunt, Gulp, Bazel or Rollup, this is all handled behind the scenes by the CLI. So as new build systems are coming out, the CLI team can add them to the CLI and we as Angular developers can either accept the new build system the team have added to the CLI or make some changes to our angular.json file and choose the build system we want for our projects.

I think one of the greatest benefits of the CLI is how easy it makes running Unit Tests. Before Angular, in AngularJS, setting up Karma and Jasmine was a painful experience. Again, tackling JSON files, making sure all the paths were correct, spending hours searching for answers to errors when we finally tried running the tests. Reading blog posts where someone showed us a few ‘simple’ steps to making it all work first time, and finding that after following these ‘simple’ steps Karma still didn’t work for us, then trying to figure out where we went wrong. Setting up Unit Tests was a painful and long process, but now with the CLI it’s all handled for us. All we do is run a simple command, and boom all our Tests are run.

The Adventures in Angular episode really did show how much time and effort the CLI now saves us, not only as developers, but the costs it saves companies. No longer do companies have to pay developers for setting up their local build systems, now an Angular developer can be up and running in no time.

If, as an Angular developer, you’ve gotten use to having the CLI around, take a minute to think about all the benefits it brings us. The CLI is really an amazing tool, it really helps separate Angular from the other front-end frameworks out there.