Simply Business homepage
  • Business insurance

    • Business Insurance FAQs

    Business insurance covers

  • Support
  • Claims
  • Sign In
Call Us0333 0146 683
Chat With UsChat support 24/7
Tech blog

Deprecating Code Gracefully

1-minute read

Martin Sadler

Martin Sadler

18 July 2016

Share on FacebookShare on TwitterShare on LinkedIn

In this post I describe a neat but simple trick that you can use to help inform developers of proposed architectural direction changes in the code they are modifying.

This is especially useful on a large, constantly evolving monolithic code base where refactors may take time and require a concerted effort across the whole team.

An example illustrates the concept quite nicely:

bundle exec rspec spec/features/deprecated_classes_spec.rb


This is a great call to action.

It encourages teams to have a conversation about the desired approach, read the docs, and collaborate where required. This may be the time to upgrade this part of the system or it maybe just fine to update the sha and carry on, assuming the relevant parties have agreed so. This change also has the benefit of showing up in a pull request and so any changes may need to be justified.

In summary, it provides an opportunity to constantly improve and share the knowledge. One of our principles at Simply Business is "maintenance is a must" and this certainly embraces that.

In Practice

Feature: Deprecated classes

As a developer I want to raise awareness of deprecated classes So that we don't build on code we want to refactor when we next modify it And therefore we "do it right"

Scenario: Modifying a class which is marked as deprecated due to the new support framework Given a list of deprecated files | file | sha | | app/support/book.rb | f92f8a | | app/support/page.rb | fbb220 |

And a deprecation message: """ Refactor with a goal!

This test fails because you have made a change to one or more files which we would like to deprecate in favour of our preferred design approach.

Please consult with the guidelines here or talk to the 'Acme' group within the company for guidance. """ When any of the files is detected as being modified Then this test will fail with a deprecation message`

Step file

step "a list of deprecated files" do | files | @files = files.to_h @files.delete('file') end

step "a deprecation message:" do | msg | @msg = msg end

step "any of the files is detected as being modified" do @expected = @files.keys.each_with_object() do | filename, current_shas | contents = (dir,'..','..',filename))) current_shas[filename] = Digest::SHA1.hexdigest(contents) end end

step "this test will fail with a deprecation message" do expect( @expected ).to match( @files ), @msg end

You can view the full source for the example on the Github repository.

Ready to start your career at Simply Business?

Want to know more about what it's like to work in tech at Simply Business? Read about our approach to tech, then check out our current vacancies.

Find out more

We create this content for general information purposes and it should not be taken as advice. Always take professional advice. Read our full disclaimer

Find this article useful? Spread the word.

Share on Facebook
Share on Twitter
Share on LinkedIn

Keep up to date with Simply Business. Subscribe to our monthly newsletter and follow us on social media.

Subscribe to our newsletter


Public liability insuranceBusiness insuranceProfessional indemnity insuranceEmployers’ liability insuranceLandlord insuranceTradesman insuranceSelf-employed insuranceRestaurant insuranceVan insuranceInsurers


6th Floor99 Gresham StreetLondonEC2V 7NG

Northampton 900900 Pavilion DriveNorthamptonNN4 7RG

© Copyright 2024 Simply Business. All Rights Reserved. Simply Business is a trading name of Xbridge Limited which is authorised and regulated by the Financial Conduct Authority (Financial Services Registration No: 313348). Xbridge Limited (No: 3967717) has its registered office at 6th Floor, 99 Gresham Street, London, EC2V 7NG.