Taking advantage of the release of the new Star Wars movie, we review some references we find
A new Star Wars movie was released and we review some references we find in our day to day as programmers. Take a look on the dark side of the code.
Death star
If we develop mobile applications for Android and use the accelerometer to gather information on the movements of the device, we will see that gravity is very important for calculating this data. There is a constant located in the class SensorManager called GRAVITY_EARTH. But we can also see that there are also values for GRAVITY_PLUTO, GRAVITY_SATURN, etc. Strangely enough, GRAVITY_DEATH_STAR_I is also a constant, as described in the documentation:
Gravity (estimate) on the first Death Star in Empire units (m/s^2)
Constant Value: 3.5303614E-7
So if we want to use our cellphone on Death Star, we have the necessary data available. Also, note that it is expressed in Empire units (Empire units, not be confused with Imperial units), which happen to coincide with the metric system.
There is also a reference to Star Trek, but we are not going to name it here.
Yoda conditions
According to Wikipedia, the conditions are expressed contrary to what one would normally think, for example:
if(n == 1) // Instead of if(1 == n)
The advantages are: avoiding assignment errors:
if(n = 1) // Instead of if(n == 1)
And null pointer exceptions:
String n = null; if(n.equals("something")) // Instead of if("something".equals(n))
Aurebesh
Google Translate added Aurebesh as language. So now we will be able to translate some film references, such as:
There is no mobile application yet. But we can use the font in our web applications.
Star Wars API
Are you making an application and need to consume data from Star Wars? SWAPI is a public REST API which give you information about people, vehicles, planets, species and more! For example, take a look at this.
{ "name": "Chewbacca", "height": "228", "mass": "112", "hair_color": "brown", "skin_color": "unknown", "eye_color": "blue", "birth_year": "200BBY", "gender": "male", "homeworld": "http://swapi.co/api/planets/14/", "films": [ "http://swapi.co/api/films/6/", "http://swapi.co/api/films/3/", "http://swapi.co/api/films/2/", "http://swapi.co/api/films/1/", "http://swapi.co/api/films/7/" ], "species": [ "http://swapi.co/api/species/3/" ], "vehicles": [ "http://swapi.co/api/vehicles/19/" ], "starships": [ "http://swapi.co/api/starships/10/", "http://swapi.co/api/starships/22/" ], "created": "2014-12-10T16:42:45.066000Z", "edited": "2014-12-20T21:17:50.332000Z", "url": "http://swapi.co/api/people/13/" }
Star Wars in ASCII
Doing a telnet to towel.blinkenlights.nl we can see the ASCII version of Episode IV:
(Han shot first)