# Abstraction

Abstraction is something like a platonic ideal — it is not itself real, but is a state of being or an ideal that relates to the world. Abstractions are general rules or relations that we derive from use and classification of specific examples. In the video, the speaker, Tom Stuart, uses numbers as an example of an abstraction. Despite being one of the most fundamental structures in our understanding of the world, numbers are just a set of abstractions. “One-ness” is a concept rather than an object. There is nothing that is a “one,” and no matter how long we look, we will never find “one.” Rather, one-ness is some quality we derive from an object to distinguish it from the things around it.

Finding these abstractions in the world saves work. By deriving the qualities or abstractions underlying objects we can make conclusions based on their classifications. Ones can be added to twos to make threes. Twenty sets of Five equals One Hundred. And rather than counting One Hundred objects to see their total amount, we can group them into fives and count twenty groups. Abstractions use higher-level processes but yield results quicker and more consistently, given the appropriate abstraction is derived. A larger example involves counting $1,000. By using the relations between numbers we can find this solution in a short time (10 stacks, 5 bills per stack, $20 per bill), whereas counting $1 at a time — though a simpler process — takes a much larger amount of time, and is more prone to human counting errors.

All code uses some amount of abstraction. Good code tends to involve more abstraction. By understanding how objects relate to each other or by deriving the rules underlying some concept, we save time and code rather than working through all possible situations. Tom Stuart gives the example of coding a poker game. Rather than writing statements for each card combination, he finds the underlying concept behind certain combinations and uses those concepts to derive elegant conclusions.

For example, a straight is a set of successive cards. Rather than comparing each individual card with the other cards in the hand to determine whether the cards are successive, he takes the set of cards, adds one, deletes the overlap between the original set and the final set, and then analyzes the result. If two cards remain, then the original set was a straight. More importantly, size of the straight is irrelevant — the abstraction obtains whether it is a straight of 2, 3, 4, 5, 6; or of 6, 7, 8, 9, 10 (or 10, J, Q, K, A assuming you give the latter cards numerical values). Thus rather than running through each size of straight, by abstracting the underlying essence, concept, or rules of what IS a straight, a more concise, elegant, and accurate solution can be found.