GithubHelp home page GithubHelp logo

objarni / alarmclockkata Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emilybache/timerexpiry-refactoring-kata

0.0 0.0 0.0 412 KB

exercise to practice removing duplication

License: MIT License

C 1.36% CMake 0.54% C++ 98.10%

alarmclockkata's Introduction

Timer Expiry Refactoring Kata

You would like to make a change to the function how_long_until_next_timer_expiry - this change is described below. Before you make that change, you'd like to refactor the function to make it easier to make the change. (Make the change easy then make the easy change!) Before you do any refactoring, you'd like to have some test cases as insurance against mistakes.

Adding tests

There are three different starting points for tests, using different test frameworks. Choose one of them to build on. If you like, start over and build the same tests in a different framework. You might learn something about test design!

Refactoring

When you are confident in your test cases, refactor to remove duplication and to make adding the new timer easier (see below). Note - there is another branch in this repo called 'with_tests'. That branch has reasonable tests built with all three frameworks that you can rely on while refactoring.

What this code does

The how_long_until_next_timer_expiry function should work out the number of milliseconds until a timer will expire. It's used by another function that pauses execution of the program until then. (The calling code is not included in this exercise). The how_long_until_next_timer_expiry function goes through six timers, named:

  • idt
  • p88n
  • Time Quota
  • zb12
  • dy9x
  • Monitoring Time

It works out which of these timers are currently active, and how long until each one should expire. It returns the time left until the next one will expire, (via a parameter).

The change you need to make

Add a new timer, named bti. This timer should be enabled when duration measurements are active and the operational flag OPERATIONAL_FLAG_BTI_PRESENT is set. The timer should expire when the time since the last packet is equal to bti_time_interval. You can get the time of the last packet using the method get_time_of_last_pkt.

alarmclockkata's People

Contributors

emilybache avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.