Points do not make prizes

If you grew up in the UK in the 80’s then you may remember the line “What do points make? Prizes!” from a popular TV show of the time. The idea that points is a sign of success makes sense for games shows and sports teams but not for software teams. Points used by software teams are meant to measure the complexity of the work, not the value. But let’s be realistic – most teams use them as a measure of time.

Not all points are equal

I have worked for many teams where, as the end of the sprint approaches, the manager and scrum coach are pushing teams to finish their stories and “bank the points”. They want to impress their managers (and other teams) with the high number of points the team completed but this leads to the illusion that points are all that matter, ignoring the actual value that those stories contain.

“What gets measured gets managed — even when it’s pointless to measure and manage it, and even if it harms the purpose of the organisation to do so”.

Simon Caulkin

If we use story points as a measure of value, is a story estimated at 8 points of more value than one estimated at 3 points? We cannot be sure. It depends on what they are about. The smaller may be something that is causing problems for hundreds of customers and fixing that may lead to a better workflow, whereas the larger one is something that is useful to a handful of users and wouldn’t necessarily increase adoption.

Value in a sprint is partly determined by the order of the stories. Higher value stories are (usually) at the top of the sprint and are what the team should be working on first. The lower ones, although they can still deliver value, can be delayed until a later date if something else comes along that is worth more. This obviously doesn’t work for points.

If you are using story points as a measure of team and sprint success then people may start gaming the system to increase the number of points delivered e.g. exaggerating estimates, rushing delivery, working only on simpler stories etc. This will eventually lead to the story points being an inefficient metric to measure team success.

This is also true of anything we decide to measure – number of stories completed, number of releases to production etc. so the aim is not to use a measure as a target.

What does the customer want

Whenever I see points being used in this way I ask teams to think about what would you tell the customers at the end of a sprint?

Hey, just wanted to let you know we delivered 87 story points this release.

The customer is going to look at you and wonder what you are talking about! What is a story point and why should they care about it? It means nothing to them. They are more interested in features and bug fixes – things that make their jobs easier, faster or simpler. Do you include the number of story points in your release notes? No. You detail the work that has been done – what features have been added, what issues have been addressed etc. Things that of more value to them.

So why should the team be bothered about recording and measuring story points?

Estimation vs Value

I believe story points are a great planning tool to estimate when work might be finished. It takes practice, but they can be a useful way to gauge complexity and estimate when the work will be complete. So when we are planning sprints they enable the team to prioritise the right amount of stories. And if we need to re-plan at any point we can remove the correct amount of story points to make room for the new work. But one thing they don’t measure is the value of that work.

Value cannot be determined by the number of points or even the priority of the item in the sprint or backlog. Value is defined by the user. Only they can tell you how much a certain change makes their job easier. So how do you measure value? *You* cannot. But using story points to define value is a path you don’t want to go down.

Conclusion

Story points are useful to estimate how much work there is, but not how valuable that work is. Don’t use them to measure how well the sprint went. My experience indicates that this is mostly done by scrum masters who are more concerned about velocity than value.

And value is what will win you prizes.

Failure is an option

I have worked on a number of Agile projects and one of the things I find, especially when working with people who are new to Agile, is the focus on doing things correctly from the start. One thing that people often say about Agile is that it helps you to “fail fast” – although this can be better changed to “learn fast”. But this doesn’t just relate to the project you are building it also refers to the Agile framework itself.

When you start implementing Agile there is a desire to write great user stories and you ask yourself a lot of questions as you create them

  • Are they at the right level of abstraction?
  • Are we covering the whole problem?
  • Is it too broad?
  • Is it too specific?
  • How do we write one that doesn’t involve a user?

The list goes on. But, at the end of the day, you aren’t going to get it right from the start. But people insist on trying to avoid getting it wrong.

If you aren’t experiencing failure then you are making a far worse mistake: You are being driven by the desire to avoid it.


Edwin Catmull

Getting it wrong is all part of the learning process. We don’t write the perfect user stories first time, just like we don’t learn to walk the first time we stand on our feet. It takes time, and practice…and failure!

But this doesn’t just relate to the product you are building, it also means you should reflect on the methodology itself. As part of your retrospectives you should reflect on the whole process – the stories, the stand-ups…even the retrospective itself. There are always ways you can make small improvements to the process – change the questions in your stand-up, use different formats for the retrospective etc.

A lot of people starting in Agile are keen to do it right – to write the perfect User Stories, estimate them precisely, deliver everything on time, hold the perfect daily stand-ups, run the perfect retrospectives etc. But that’s not what Agile is all about. It’s about trying things in small increments, reflecting on what you’ve done and deciding if you should carry on in the same way.

How often do you apply this to the Agile methodology itself? I would hazard a guess that you’ve altered your sprint length (or at least discussed it). Or maybe you’ve changed the questions in your retro to “mix it up a bit”. But what about your user stories? Have you reflected on them? Are they written at the right level? Maybe what was good a couple of months (or projects) ago isn’t right now.

It’s all about experimenting and trying different things – not just in your code but in your practices and processes. Be adventurous – try something different. If you aren’t failing then you aren’t learning.

Failure is an option. We need to embrace the failures so that we may learn from them.

Without feedback, Agile is just Waterfall

Over the years that I’ve been using SCRUM as an Agile methodology I have come to like the patterns it uses to ensure better planning, fail-fast development and improve communication around a feature or product. However, this is generally where I have seen SCRUM finish. People assume that once we have regular sprints, the team velocity remains steady and the work is getting done that they have successfully implemented SCRUM and everyone deserves a pat on the back. But there is one aspect missing that is vital to ensure SCRUM works. Feedback!

With all the planning, monitoring and internal feedback that teams do it seems that everything goes well. The features are getting written, any problems are found quickly and it is done incrementally so after every sprint the team has something to demo to the stakeholders. The stakeholders review the feature, give everyone a pat on the back for implementing what they asked for and everyone leaves smiling, happy in the knowledge that things are going well.

If you don’t get any external/valid feedback (outside of stakeholders) until the product is done then you are just doing waterfall with a different name. Although stakeholder feedback is useful it’s not the same as real user feedback. The stakeholders e.g. PO, PM etc. are seeing the project day-in, day-out and have a biased opinion of what is happening because they have direct communication with the developers and designers. And their primary goal is to get the software completed and released to the customer so it can generate revenue. But the functionality, performance and usability of the software is what the end user is more concerned about and their input must be sought out during the development stages, not at the end.

Some teams that I have worked on have waited until a feature is complete before they look for user feedback but in my opinion that is too late. The team may have moved on to another feature, a different team/role etc. and making them switch context back to older code means it will take longer to remedy the situation and this adds more time to the feedback cycle. It is important to get feedback whilst the work is in progress. It doesn’t have to be pretty. It doesn’t have to be bug free. It only needs to show the basic functionality – enough so that the user can understand where you are headed and can help validate that you are on the right track or tell you that you have lost sight of what the end user really wants.

We have access to tools that allow us to continuously build our products on every check-in, run a suite of tests and deploy, all in one click. So why aren’t we using these to provide something that a user can try and give us feedback? This doesn’t need to be a web site. It can be an MSI or MSP. And why do we still need to wait for the management to fill out paperwork to say the product is good enough for external use before users can have it? I bet you would find customers who would be willing to try an early release/technical preview of your product before anyone else, but have you asked them? It doesn’t even need to be external customers, it could be your support team, vendors, the pre-sales team – anyone who uses the software regularly and can give you an insight that your stakeholders cannot.

Real user feedback is important. A lack of confirmation of what you are developing is the right thing until it is too late – or will require a lot of work to remedy – is not Agile. It’s Waterfall just with a different name.

Adal JS and Azure AD

I was recently following a Pluralsight tutorial called “Azure AD for Developers”. I’ve wanted to find out more about Azure AD (but was afraid to ask Winking smile) so I thought this video would be a good start. I followed the tutor and created the ASP.NET WebApi and Angular applications as he showed (I prefer to type everything than download the exercise files. You tend to find error messages and the solutions when you type everything yourself).

When I got to the point of testing I ran the apps and I could login to my app correctly but when I attempted to call an API it returned an error:

Error :interaction_required
adal.min.js:2 Error description:AADSTS65001: The user or administrator has not consented to use the application with ID ‘{GUID}’. Send an interactive authorization request for this user and resource.
Trace ID: {GUID}
Correlation ID: {GUID}
Timestamp: {TIME}

I spent a good amount of time looking over the video again, but the tutorial didn’t have any problems? Why was mine different? I checked I had used the correct App ID’s –the GUID’s were correct – the URL’s were correct?!?! What was going wrong!!

Then I found this web site:

https://blog.ithinksharepoint.com/2016/05/16/dev-diary-s01e06-azure-mvc-web-api-angular-and-adal-js-and-401s/

Although the post is a tutorial it also shows the possible pitfalls – including the one I had fallen into.

The error was in my Angular App where I had initialized the adalProvider. In my haste I had assigned my endpoints list to “endpoints”, but the ADAL property is called “endPoints”. D’oh! After changing this typo the API calls were returning correctly. Phew!

adal

I hope this post helps someone else fix this issue without the same amount of “googling” I had to do.

Technical Debt: The Payday Loan of Software Development

Payday loans are being advertised a lot on TV these days. The idea being if you get stuck with an unexpected bill before you get your next pay-check you can take our a short term loan, measured in days rather than months, and pay it back on your next payday. The downside being they charge a very high APR. The idea being if you pay it back quickly the interest is limited and you get your car/boiler/washing machine fixed ASAP. The problem comes from not paying it all off at your next payday. The interest rate can be crippling and you will find it harder every month to payback the loan and the total debt never seems to go down. This is also the same for technical debt.

We’ve all been in the situation. Something needs implementing/fixing but it needs to be done yesterday. The bosses are under pressure to get this thing done and are prepared to borrow from the Technical Debt bank to get it done. However, some people treat this debt as a bottomless pit. Once something goes in there they don’t need to worry about it anymore. They see term “technical debt” as just that – a phrase, a bit of management speak – it’s not actually a debt. They don’t feel like they’ve borrowed anything and, therefore, have nothing to pay back but, in reality, they have borrowed from the bank of maintainability. And this bank will bankrupt you if you don’t pay it back!

This is why I compare it to a Payday loan. The borrowing is only supposed to be for a short amount of time e.g. to get the feature/bug done quickly, and if you don’t pay back the debt then it starts to snowball and, before long, it’s not just a small debt anymore. And we tend to find that, because we didn’t remove that technical debt straight away, other parts of the codebase have started to rely on it, making it more difficult to refactor. And we could come across the broken window theory where others have seen what we’ve done and think it’s OK to write code like that.

Over time the debt becomes larger than the original loan and it’ll take a lot of effort to pay it back. When managers ask us to add new features the timescales are getting bigger due to the problems we have to code around. We need to have time to pay down the debt otherwise it is going to become unmanageable and bankruptcy may be the only solution (in development terms, bankruptcy would be the same as a re-write of the product/library). But if you go for a rewrite what is stopping you from making the same mistakes again? I know from experience you are not going to get a whole lot of time to do the rewrite and, inevitably, short cuts will be taken.

But, as developers, what can we do? Refactoring is good for our work, but it’s not something that can be sold to a customer. Businesses generally don’t want to invest in development that doesn’t directly affect sales. We have a couple of options at our disposal:

  1. Persuade your manager to allow you (or the team) to work on one technical debt item per sprint
  2. Get everyone in the team to add a little refactoring to any code they touch as part of the development process
  3. Refactor the code outside of normal work time
  4. Live with the code and try to make the best of a bad job

Just remember, it’s not about fixing it all in one go. If you had the resources to do that then you probably wouldn’t have gotten into debt in the first place. The aim is to reduce the debt, little by little. A little refactoring here. A small rewrite here. Over time, these changes add up and, after a while, you should find yourself with a more manageable debt (or, if you are lucky, completely debt free), which will give you the chance to go away and write those new features with the fancy new technologies – the reason we go into these roles in the first place.

Refactoring: Rome wasn’t built in a day

People often ask me to help them get started with their refactoring. They have an idea about what they want to end up with but need a little help getting started. As refactoring and testability is one of my passions, I am always willing to help. One thing I have noticed in a lot of these requests is the size of refactoring that is being planned. Some people have chosen whole libraries or applications to refactor so as to get them unit tested but, always aiming high is always a good idea, you need to reach that loft goal using tiny little steps.

When you look at a piece of code and realise you want to refactor it, you need to break it down into small, manageable pieces. I mentioned in an earlier post that you shouldn’t wait for permission to start refactoring but you shouldn’t start by aiming to refactor a whole library of functionality. The chances are it will take you too long to refactor all of it and, in the meantime, people will come in and change things. Even if you’re lucky enough to be the only one changing that library other work will get in the way and the longer it takes to finish it off the more laborious it will feel.

If you are making small, targeted changes and getting them under test you will get a better feel of accomplishment as you complete the refactoring and add it back into the live codebase. As you complete more and more smaller changes you (and others) will start the see the bigger picture develop. All of a sudden you have that massive class covered with tests and you can start to break it down into smaller, more focused classes and test them, safe in the knowledge that you aren’t breaking any existing functionality. Believe me, people will see the benefits of this as the QA team start filing less and less regression bugs and the teams can start to focus more on the new features instead of old bugs.

Sometimes it may not feel like the smaller changes are going to have any affect on the overall codebase but they will accumulate and, before too long, your code will start to look (and smell) better. Plus you’ll have done it without too much effort and with little impact on other tasks. So, set your targets high by all means, but keep the steps to reach that goal small and manageable. After all, Rome wasn’t built in a day…

What does it mean to be a professional software developer?

People will often refer to themselves as professional developers, but what does that involve? What do people expect from someone who refers to themselves as a professional developer? Here are my thoughts:

Practice, Practice, Practice

As a professional you need to practice what you do to help develop your skills and expertise. Look at professional sports people. The best train hard all the time, improving their skills that they are good at and working on the things that they struggle with. It’s the same with developers. If there is a part of our role that we aren’t good at, then we need to work on it and improve. This may involve taking on tasks in your role that you are not experienced in and learning how to do them, or attempting a Coding Kata to help learn new languages – or keep our current skills fresh.

Avoid short cuts

A problem that inevitably occurs in software is technical debt. At some point in our careeers we’ve added to that mountain of work that will be “fixed at a later date” but never got round to revisiting it. You may think that it is OK to take the short cut to allow the deadline to be met but it often leads to the broken window theory. All of a sudden, before you realise it, the debt mountain has grown massively!! As professionals we need to actively stop taking the short-cut to fixing issues and start making changes for the long term.

The management team are (hopefully) aware of the number issues a piece of software causes – and the number of bug fixes that need to be made to resolve them, so we need to educate them that avoiding the short cuts is going to make their life easier in the future as well. They don’t want to be fighting fires with the existing software all the time, just like we don’t, but the deadlines mean they can’t afford the time to let you make the changes you want. In these situations, sometimes forgiveness is easier than permission. Avoiding the short-cut and paying off that little bit of debt everytime we touch the code will make everyone happier in the long run.

Taking on the tough/boring tasks

There are always parts of our job that we would rather not do. It might be source control admin, performing manual confidence testing on our software, reviewing and maintaining the backlog in the management portal etc. but they need to be done by someone. That person should be you. No one wants to do the boring, administrative work. We all want to be writing new features, fixing those annoying bugs or investigating new technologies for future projects etc. but there is a price to pay. We need to lead by example that, although they are not the tasks we look forward to, we are willing to do them and get them out of the way so we can get back to what we really want to do. And I have found that procrastinating over them only makes them more arduous when we finally have to face up to them. Don’t leave them to the junior members of the team as they won’t look at you with respect. They’ll regard you as someone who isn’t prepared to get their elbows dirty with the mundane stuff and they will resent you for it. Your reputation as a professional will be tarnished and, sometimes, it’s a tough mark to clean off.

Read blogs

There are a huge amount of people in the world who write about their experiences (like me Smile ) to share theri knowledge with others and, in turn, help themselves improve. I read a number of different blogs about development languages (.NET, JavaScript, Angular, Visual Studio, TFS etc.) to keep up to date with what is happening. I also read blogs from other developers about unit testing, design patterns, agile etc. to understand different views and increase my knowledge of the area. And you can also use YouTube to watch presentations from various conferences around the world that cover different topics. I found the Google “Clean Code Talks” are quite good to help understand unit testing design, but there are lots of choices out there – you don’t even have to watch them for your favourite programming language. If you are C#/C++ based, try watching a video about unit testing in Ruby for example.

These few points may seem obvious, but it’s good to remind ourselves now and again, what is required. Ultimately, it all helps expand our knowledge and, I promise, you will become a better professional for it.

Today is a good day to refactor

Some software developers think refactoring is a hard thing to do. It needs to be given its own work item in the sprint and the developer needs to spend a specific amount of time refactoring a specific part of the code. This leads to refactoring being adding to the “engineering” backlog to be looked at when there is time in the schedule. Unfortunately, this will lead to refactoring never being done. How many managers are going to justify a developer spending time changing code that works when there is a long list of work that needs to be done for the next release? There are more important things to do – features to write, bugs to fix etc. and these are what pay the wages, not spending time reorganising the code. But this attitude is what leads to a build up of technical debt, long development times, more bugs being introduced, hacks/fixes to get around the existing bad code etc. And the longer this carries on the worse it gets.

But what can you do to stop it? Refactor NOW! Everytime you work on the code you should be looking for places to refactor. Maybe technology has changed and you need to use a new language feature to remove an in-house solution. Or maybe you knowledge on a certain area is better than when the code was originally written and you can see a better way of doing something. The point is, you should go ahead and make those changes. Keep the changes small and always surround your refactored code with tests. And over time, bit by bit, you will see the code changing into a more solid foundation for future work.

But what should you refactor? When you are changing existing code, try and apply the Single Responsibility Principle to those areas. Extract functionality to new, smaller and more focused classes and then write tests for the new classes. It might not seem like you are making a huge difference to the code with small changes, but they will all add up. And, eventually, you (and your colleagues) will start to see the benefit of the small changes – less bugs, improved readability, easier to add/change functionality, more code re-use etc.

One thing to remember – refactoring is different to re-writing. If you are re-writing something then you are changing the functionality and, possibly, breaking the existing tests. If you break an existing test then you are re-writing (exceptions exist where the tests does do the right thing, but generally you shouldn’t change the existing tests). If you do find you break a test and think your changes are correct then you’ve found a bug. Raise that as a bug, but don’t fix it. You don’t know what side effects that change will have on the rest of the code – especially if you are changing a library, or shared function.

Everyday is a good day to refactor – especially today!

Refactoring – Forgiveness or Permission?

There comes a time when you realise that your code needs to be refactored. The existing tests take too long to run or their are large parts of the code that aren’t covered by any tests and you want to rectify that so future development cycles can be quicker and less bugs get found by the QA team. But there is a problem – there is no time in the project timescales to do any refactoring or testing. This may be a mute point to some as they refactor every time they change the code – kudos to you. That is probably how we would all like to work. However, this is not always possible because the business and the managers are measuring performance on how quickly we write features, not improve the code quality or test coverage.

Find a recent pain point
Look back through the recent list of bugs for a project and try to find something that has caused some angst with the management. Maybe it caused a big customer to complain, maybe it slowed or stopped a deal from happening, or maybe it meant the team spent hours trying to find the problem and then QA had to re-run their tests to confirm it had been fixed. Once you have found something, look at the code and see what refactoring could have been done to avoid the issue. Show how the bug manifested itself in the first place. What tests could have been written around the code to prevent the issue happening again? Highlight the issue to your boss (or maybe the whole department) and show them what a small amount of extra effort would have made.

Show by example
Sometimes we know the leaders just don’t understand the benefits of what you are proposing – the code works at the moment so why do we need to change it? These people live for real data and the only way you will get them to understand is by a real world example. You do the same as above and find a recent problem, but this time provide a solution for it. Show how quickly the tests can be run to prove everything is OK. Show how a breaking change to the code will be highlighted by the tests and indicate to the author that what they have done has broken something. Hopefully they will see this and start to understand how much this testing lark will help improve the quality of the code and reduce the chance for future bugs getting out into production.

Alternatively, if you already have tests that take a long time to run, refactor the code and the tests so they run more quickly. Maybe they rely on the database, or the disk, which is what slows them down. Change these to use dependency injection for the external objects and show how they can be replaced with mocks for testing and how the mocks can be configured to replicate a number of scenario’s that wouldn’t be possible with a real dependency – and then show them how long it takes to run them (but make sure they are quicker, first!!).

Just Do It
The old saying is that forgiveness is easier than permission. It is easier to do something and then tell people about it afterwards then getting there buy-in from the start. And if you do ask, and they say no, can you still go and do it without any kind of repercussions? As you write a feature, or modify the existing code, then refactor as you go along. Add the tests for the code you’ve modified and submit them for a code review, or back into source control. Once you’ve done the work people aren’t going to ask you to undo it because they don’t like it. And you can use what you’ve done to help prove the point about testing helping prevent bugs sneaking into the code.

Conclusion
In an ideal world we would be given the time to refactor and test our code, but in reality this isn’t the case. Everything has be done as soon as possible and the business leaders don’t understand the benefit of spending time now to write tests – because they can’t make money out of the tests. But if you can show them real examples how refactoring and tests would have prevented a recent problem from happening – and stop it from recurring in the future – then I find they are a lot more receptive about allowing time to refactor and test the code. My personal experiences show that asking for forgiveness has higher benefits than getting permission in the first place, but it may mean putting in that extra effort to still meet the existing deadlines. But I think it’s worth it.

Refactoring for testable code: Where to start?

SpaghettiCode

The benefits of having unit tests in your code are well documented throughout the web. However, if we want to refactor the code to add unit tests, where we you start? We are obviously working with a legacy codebase and don’t have the luxury of re-writing the functionality from scratch. After all, the code works right? (Well, most of the time it does!). So we’ve got a collection of files and classes that need to be unit tested, but we need to find somewhere to start.

Start at the top
If we are unfamiliar with the code then the best place is going to be the entry point for the app. It is going to be quite daunting starting here as there are going to be (possibly) hundreds of classes and thousands of lines of code. But we don’t need to read every line of code – just get an idea of what it does. This is (hopefully) described in the function name.

If we already have a good understanding of the code and what it does then we probably have an idea what part needs unit tests.

List the responsibilities
Once we have a class, make a list of the responsibilities it has. For the most part, this will be a summary of all the function names, but make sure you get an overall idea (it doesn’t have to be specific, just representative). For a large class this is going to be a big list, but it’s going to be worth it. When you look at this list you might be shocked at the amount of responsibility the class has. But you’ll realise why it was impossible to test as well.

What we are trying to do here is identify new classes. These new classes will have only one responsibility – be an algorithm, a cache, access the disk etc. By just having a single class to do the work we are designing our code to fit the Single Responsibility Principle of the SOLID principles.

List the dependencies
Most large classes will have dependencies on other classes. These could either be passed in via the constructor, created in the constructor or, if you are really unlucky, created within the functions themselves. We want to know what our class needs to function correctly so make sure you get all the dependencies. If they are only associated with one function, make a note beside the dependency or the function.

Identify groups of functionality
Once we have the lists, try to group similar responsibilities together. For example, connect and disconnect, file operations, loading settings, operations done by the dependencies etc. We are now starting to identify areas we can refactor into new classes, which we can then design to be testable.

As you look at all three lists you should begin to see areas that can be pulled out to separate classes. These might be based on just the responsibilities, but they may also cross over with the functionality groups. You are free to choose what you want to put into the new class, but remember – we are trying to write code that is easier to test (and easier to understand), so a good way to check if you the class is too large is to write a one line description. If you have to put the word “and” in that line, then you’ve probably broken the Single Responsibility Principle. The “and” part may belong in another class.

Designing the class
Now we have identified our class, we need to design and write it. To help make a class testable we need to be able to fake any external dependencies it has. These may be the disk, a database etc., or any of our own classes. One thing you must be careful not to do it to use the “new” keyword within the new class. If an object is created within the class then we have no way of faking it’s responsibilities. And if we can’t fake them then we are relying on external sources that we cannot control reliably.

I will go into detail on the class design in my next post.