Giter VIP home page Giter VIP logo

simple-kotlin-cache's Introduction

Simple aged cache

An exercise to help individuals new to modern software engineering practices understand the basics of test driven development.

Background

The simple aged cache was one of the first bits of code that I paired on in the early 2000s while working at a telecommunications company. Ever since, I've been a fan of test driven development and pair programming.

Over the years that followed, I've attempted to introduce variations of the cache as part of the interview process at several companies. Most early attempts were fairly unsuccessful.

While working at Gnip in 2009, the team heard about the now infamous Pivotal pairing interview. In response, we began interviewing candidates using a linked list. Which, as you may know, isn’t too far from implementing a cache. Unfortunately, the linked list also proved challenging mainly because we asked candidates to do all the typing.

In response, we introduced the simple aged cache as a whiteboard problem rather than as a live coding exercise. The move to a whiteboard was very successful, resulting in several new hires who ultimately led to Gnip’s success. Rumor has it, the simple aged cache is still used as part of Twitter's technical interview after the Twitter acquisition of Gnip.

The exercise

Fast-forward to today, the simple aged cache presented here combines both whiteboard and coding approaches.

The exercise - get the tests to pass!

  • Explore using an inner class ExpirableEntry
  • Try not using built in collection classes; Lists, Maps, or Sets.
  • Try both Java and Kotlin examples.
package io.collective;

import java.time.Clock;

public class SimpleAgedCache {

    public SimpleAgedCache(Clock clock) {
    }

    public SimpleAgedCache() {
    }

    public void put(Object key, Object value, int retentionInMillis) {
    }

    public boolean isEmpty() {
        return false;
    }

    public int size() {
        return 0;
    }

    public Object get(Object key) {
        return null;
    }
}

Hope you enjoy the exercise!

Thanks, @barinek

© 2021 by Initial Capacity, Inc. All rights reserved.

simple-kotlin-cache's People

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.