We work using the agile methodology SCRUM. For those that aren’t familiar with the process, here’s a brief explanation.
SCRUM is a process of working to create a product that is iteratively developed by breaking down all new requests for big features know as Epics into bite sized chunks called Work Items. Each project usually has a team of 5 – 9 people (the optimum being seven) working on a set of items for an agreed length of time, known as a Sprint.
Our team sprints usually last two weeks so every two weeks we have a new set of items divided up between the team.
As a new developer I’m trying to focus on producing the best work in the minimum amount of time. This is obviously going to take me longer than someone who has a number of years development experience but getting into the right process now may save me so much time in the future.
In our team we are using Test Driven Development (TDD) so instead of jumping into development, you write out unit (or integration tests) to check that your work passes. This produces a quick way to check after you have finished development if any issues have arisen within your code even after years of functionality being added. New functionality means new tests to be written so eventually you build up a solid set of tests to fully cover the code you have written. This is known as code coverage. The tests that you write are located in a separate test project alongside your project within your solution.
Early on into my transition, I asked my manager (who’s been developing for about 10 years across different technologies and software) the best way to approach a task. Here’s his advice in 9 simple steps.
1. What’s your goal?
You must clearly understand your work item, what the business requires from this change and what the business value of this change is. If you’re not sure about any of these things talk to people to gain this knowledge before attempting any coding.
2. Discuss the best way to accomplish your goal with others
Consult with other more experienced minds in your team to help you get to your solution quickly. The aim here again is to use your time efficiently. By all means try and overcome challenges yourself but be mindful of the time you spend on it. You should not and do not need to shoulder all the work yourself. No matter what level of experience you have, don’t be afraid to ask for help.
3. Breakdown your goal into tasks and objectives
Smaller chunks are easier to digest. It’s just logical. So before you begin, think about your goal and what you need to do then tackle each task one step at a time.
4. Look for similar, existing unit tests and run them
Think about the current functionality that exists in the product your enhancing. Is there anything similar that you can step through and debug to help you make your task easier? If you find any methods like this try and find tests that execute these methods to check if you can extend them to fulfil your new task.
5. Write your new test
If all else fails, write a brand new test from scratch. But start by writing a test and not by writing the code for your solution.
6. Solve the task with the minimum amount of code
Try and use the least amount of code to write a solution for your task in order to fulfil it. Don’t worry about efficiency yet, just get it done.
7. Make your test pass
Run the test over your small chunk of new code ensuring that it passes and fulfils it’s task.
8. Then refactor your code
Now that your test has passed you can extend your solution to become more efficient. Don’t forget that for every new method you may need a new test.
9. Work back through step 7 – 9
Repeat steps 7 through 9 to ensure that the changes you have made in your code don’t make the test fail. If it does, debug the test to find out why it’s now failing.
Feel free to add in as many asserts to verify the outcome of your tests are correct and reliable at any stage.
And that’s it! Easy right? Well no actually, it take quite a lot of discipline especially when you’re a junior developer to avoid jumping straight into coding the solution. But writing tests as you go along will save you time during and after the development of your tasks.