In computing terms, a stack is an abstract data type that dates back to 1946 when Alan Turing documented the terms 'bury' and 'unbury' as a means of calling a returning subroutines.
The idea behind a stack, in computer terms, is that a stack is a collection of elements where you can add or remove from the collection:
- Push adds an element to the collection
- Pop removes the most recently added element that has not yet been removed
In this week's kata; Stack, you are tasked with building a stack data type which supports not just push and pop but also:
- Empty check which indicates if the stack is empty or not
- Size which counts the number of elements in the stack
- Peek which checks the stack without popping
As Jordan notes, day to day, you may not have to build a stack yourself, but you will very likely come across them in the form of a call stack, which is why this is an important kata to practice with.
Getting set up can be the roadblock to starting a kata. In our screenkatas you can join our Software Craftspeople and let them show you how to set up your repositories for Java, PHP, Python and Typescript. For other languages, check out our guide on GitHub.