Wednesday, June 1, 2016

Jose Oquendo & Variables

In the history of major league baseball, only four men have played all nine positions in one game. This does not, of course, include Will Ferrell's even more impressive feat of playing for ten different teams in one day. But when I think of utility players the first that comes to mind is Jose Oquendo.


Oquendo played twelve seasons, the first two with the Mets, and the rest with the Cardinals from 1983-1995. In 1988, Whitey Herzog penciled Jose to play second in 69 games, third in 47, short in 17, first in 16, right in 9, center in four, two in left, to catch one and to pitch one.

If Cal Ripken was a constant in the Orioles' batting order, Oquendo's defensive positions were always variable. Here's what Oquendo's defensive assignments for May of 1988 looked like:

How do we represent all of Oquendo's different positions in Swift? Here's how:



Unlike when we tried to move "ripken" out of batting third, there are no errors when changing Oquendo's variables.

I like to imagine that Oquendo had several different gloves and when called upon to play a different position he grabbed the appropriate glove. The same applies when working with variables which are declared once with the keyword "var" and then re-assigned new value after the assignment operator (=). 

When Whitey assigned first base to "oquendo", Oquendo grabbed a first baseman's glove. When assigned to shortstop, Oquendo grabbed an infielder's glove. When Herzog assigned a different position to Oquendo, Oquendo dropped the old glove (in this case, the position value) and picked up the new one. 

The same happens with the values of a variable. In this case, the variable "oquendo" has values such as "2B", "SS", "3B", "CF", and "1B". Variables do not hold onto their values the way the constant "ripken" held onto the third spot in the batting order. Rather, a variable grabs its new value and goes with it until a new value, or in Oquendo's case a new position is assigned to him, and it needs to grab a different value (and Oquendo needs to grab a different glove).

Variables are important because they help the Whitey Herzogs of the world use the Jose Oquendos as circumstances change. Ozzie Smith needs a day off from shortstop? We'll put in Jose. Willie McGee's not feeling well. We can stick Jose in centerfield. Things change. Variables allow for their values to change.

When do we use variables? We use variables when we think the value of something will change. Think of Joey Votto's batting average, Jose Iglesias' fielding percentage, Clayton Kershaw's ERA, Jake Arrieta's WHIP, or Ichiro's hit total. They are going to change over the course of a season. They are variables.

On Deck: What Makes "ripken", "4,256", and ".406" Strings?

No comments:

Post a Comment