Navigation

Object-oriented programming is a powerful way of modeling the world. Objects encapsulate data and behavior, and can interact and be composed in many useful ways.

As developers, one question we often consider is which types (in both technical and non-technical sense of the word) of objects to privilege by building them into our systems. Is an Address a proper object, or is it just a bit of data that can be encapsulated under a User? Are PowerUsers and NewUsers different enough to merit their own classes? (Probably not.)

But as our systems evolve, it can become difficult for existing object models to respond to new requirements. That’s apparently what is currently happening with tiger species. Because there are nine recognized tiger species, preservation efforts are spread across the six non-extinct species. A new proposal based on examination of DNA suggests that there should only be two tiger species.

As one researcher quoted in the piece says, “It’s really hard to distinguish between tigers…. The taxonomies are based on data from almost a hundred years ago.” Although your object model may not have legacy code that is quite that old, this case demonstrates the importance of reconsidering what traits and behaviors you allow to be first-class citizens in your system.

In the case of tigers, reducing the number of recognized species to two (one inhabiting continental Asia, and another the archipelago of Indonesia) would allow conservationists to try more flexible strategies. One example mentioned in the article is moving tigers within the same (redefined) species from one area to another (the updated definition of a continental Asian tiger would include the Amur tiger of Russia, the Bengal of India, and the South-China tiger). To a non-expert, it seems that interbreeding between these population groups would also help increase their numbers and perhaps increase genetic diversity.

Figuring out how to classify real-life entities can be very difficult. For tigers, what characteristics define a species? A century ago it might have been their physical appearance, while today we can look at the genetic level. In software, we have to think hard about the taxonomies we choose because they quickly become metaphors we live by.

The lesson for developers is that making your object model too fine-grained can introduce unexpected constraints when requirements change. To paraphrase Keynes, “When my information changes, I alter my code.”

Share:

Like this:

Note: If you are struggling with thoughts of depression or suicide, please refer to the resources at the end of the post.

Four weeks ago tomorrow, a Germanwings A320 crashed in the French Alps resulting in the deaths of all 150 individuals on board. I will not recount the details here, but investigators who were able to reconstruct the events leading up to the crash found evidence from cockpit records that the first officer intentionally crashed the plane. This post highlights three issues related to the crash: the extreme rarity of all airline disasters, let alone those caused by deliberate pilot action; risks associated with the Werther effect; and government and airline regulations regarding pilots’ mental health issues.

From 1976 to 2013, there were only eight commercial aircraft accidents attributed to pilot suicide by the Aviation Safety Network. Out of millions pilots, over one billion commercial flights, and many billions of passengers (counting repeats, obviously) that is a vanishingly small rate. An FAA review of aircraft-assisted pilot suicides in the US identified eight such events between 2003 and 2012, al limited to general aviation (i.e. non-commercial). This is a decrease by half from the previous review covering the decade before. Not only is pilot suicide incredibly rare, it is also becoming less frequent.

If this crash makes you more likely to drive instead of fly, you will be putting yourself at much greater risk. When airline traffic decreased by about 15-20 percent following the events of September 11, 2001, Gerd Gigerenzer estimated that fatal car crashes went up by about 10 percent (due to excess road miles driven), accounting for about 350 additional deaths.

In addition to a disproportionate fear response, widespread reporting of suicides can also inspire copycat behavior. This phenomenon is known as the Werther effect, named for the title character in Wolfgang von Goethe’s novel The Sorrows of Young Wertherwhich was blamed for a rash of suicides amongst young males across Europe in the 1770s. This copycat behavior was popularized in Robert Cialdini’s book Influenceand based on earlier research by David Phillips. In a 1980 paper, Phillips found that

After publicized murder—suicide stories there is an increase in noncommercial plane crashes and an increase in airline crashes. This increase in crashes persists for approximately nine days, and then the level of crashes returns to normal.

The paper is gated, but some figures from it can be found here. Evidence for the Werther effect implies that the media should be very careful with how they present stories of suicide. This piece by Matt Haig does a very good job of discussing the Germanwings incident and can be summarized by its title and opening blurb:

I’ve suffered from depression. The only life I’ve ever considered taking is my own. For 15 years I was depressive on and off, and the ignorant speculation about Andreas Lubitz’s mental health strikes me as being harmful.

Although the ultimate responsibility for safety lies with pilots, airlines and government agencies also have a responsibility to passengers to ensure that potentially suicidal pilots receive treatment and do not put others at risk. In the US, the FAA takes this duty very seriously. As one of my flight instructors said, “The FAA doesn’t care about you, they care about the people you might endanger.” In the 2003 report mentioned above, the authors note:

All pilots involved in these aircraft-assisted suicides were male, with a median age of 46 years. The pilot was the sole occupant in 7 of the 8 aircraft that were intentionally crashed. Four of the 8 pilots were positive for ethanol, and 2 of the 8 were positive for Selective Serotonin Reuptake Inhibitor (SSRI) antidepressants.

Unfortunately demographics of professional pilots overlap considerably with demographics most likely to commit suicide.

Current FAA aeromedical regulations require that individuals on one of four approved SSRIs undergo additional screening before before receiving their aviation medical certificate. Pilots with a diagnosed mental illness must also see an approved medical examiner every six months for a neurological screener. Airlines also typically require an annual MMPI screening for pilots. (Note that these regulations do not apply in Europe, and I am unfamiliar with the process there.) While this process is admirable in its emphasis on passenger safety, the increased burden on pilots is enough to persuade some to conceal their illness from the FAA, or worse, forego formal treatment altogether (self-medicating with other substances is all too common). The aviation industry has a long way to go in making mental health issues more open for discussion, as does much of society.

What can be done to preserve pilot and passenger safety? If you are a potential passenger, do not switch to driving when you hear about airline accidents. If you comment on these issues on social media, avoid glamorizing suicide. If you are a pilot or in the aviation community, be aware of FAA regulations, do not fly if you are in a mentally unsound state, and be willingly to openly discuss these issues. Finally, if you are experiencing mental health issues reach out to someone around you.

In the US:

Mental Health America has community support groups around the country. Their toll free number is (800) 969-6642.

Share:

Like this:

John Oliver’s recent interview with Edward Snowden is circulating widely online, but given the ignorance displayed in “man on the street” segments it deserves more attention. Those segments are included in the video below, and misapprehensions range from the belief that Snowden sold secrets to associating him with WikiLeaks (that’s not Snowden, it’s Julian Assange).

To be clear, this is not a sympathetic interview. There are some humorous parts, but Oliver is not tossing softballs. He asks Snowden difficult questions about whether he understood the implications of the information he released, and whether turning it over to journalists was a responsible decision. As a Snowden supporter some parts of the conversation were frustrating to me, but that probably means that it was a fair interview.

The most important part of the video below concerns Section 215 of the Patriot Act, which allows government collection of “any tangible thing” that is “relevant to” a terrorism investigation. That’s an unbelievably broad provision, and one that its author James Sensenbrenner claims has been misinterpreted by lenient FISA courts and should be put out of business. We must have a very serious national conversation about this bill before its renewal on June 1 of this year.

There were several good quotes from Edward Snowden in the interview. Here are my two favorites:

You will never be completely free from risk if you’re free.

You shouldn’t change your behavior because a government agency somewhere is doing the wrong thing. If we sacrifice our values because we’re afraid, we don’t care about those values very much.

Like this:

With the subtitle, “How to Rebuild Our World from Scratch,” you can probably guess the genre of The Knowledge. I read this ambitious book over the holidays, hoping that I could learn some of the basics of fields I’m less familiar with such as organic chemistry and medicine. On that front the book delivers, but does it live up to its title?

Some parts of the book were very practical while others seemed superfluous. Purifying water with bleach (p. 37) could be useful in even a small-scale disruption. But in the wake of a larger disaster I find it hard to believe that knowing how to build an internal combustion engine (p. 199) or mix gunpowder (p. 232) would be near-term priorities. (As an aside, the book contains a one-decimeter line segment from which you can reconstruct the entire metric system, but I happen to think that less formal systems of measurement such as the acre–the amount of land a yoke of oxen could plow in a day–would become popular in apocalyptic scenarios.)

The Knowledge is a fun read and contains some useful tips, but I would not want it to be my go-to book for emergencies. That is why I was interested to learn of the “Manual for Civilization” initiative, started by The Long Now Foundation. This is a library of books that were listed by domain experts and Long Now staff and donors in answer to the question “If you were stranded on an island (or small hostile planetoid), what books would YOU want to have with you?“

After reading through the answers I have compiled a short list of my own with the additional qualification that the book offers knowledge that is beneficial even if disaster doesn’t strike. The name after the title is the first recommender on whose list I noticed the book, with a link to their full list of recommendations. (Kevin Kelly’s compilation seemed especially good; his book Cool Tools would likely fit in the list below).

Share:

Like this:

Venkatesh Rao had a great piece last week on imagination as a survival skill. Here is the gist:

I suspect failure-to-self-actualize will become the leading cause of death (or madness) in the developed world.

Rao defines “self-actualization” as

the imaginative embodiment of internal realities (what the daemon feels) in the form of a dent in the universe: a surprising and free external reality that actualizes a new possibility for all

and “imagination” as

the ability to create unpredictable new meaning while generating more freedom than you consume.

The post is very good, worth reading twice. However, there is one key shift that Rao overlooks. He focuses on imagination as an essential ability for the wealthy (the “one percent”), but it has even bigger implications for a future of 100 percent unemployment.

The prediction I would make is that we would see a lot more leisure. For those whose skill adaptation is adequate, that leisure will take the form of earlier retirement, later entry into the work force, or shorter hours. For those whose skill adaptation is inadequate, that leisure will show up as unemployment or reluctant withdrawal from the labor force.

I think that if you look only at males in isolation, you will see this in the data. That is, men are working much less than they used to. For some men, this leisure is very welcome, but for others it is not. In that sense, I think that we should look at the fears of the early 1960s not as quaint errors but instead as fairly well borne out.

The availability of inexpensive leisure (think cable TV and Youtube) has increased the reservation wage of low-wage workers. This has made unskilled individuals less willing to work for near-minimum wage jobs, as detailed in this New York Times article.

Self-actualization of highly skilled individuals as described by Rao has created so much freedom for those at the bottom of the income distribution that they now choose not to work. In their own words, though, the willingly unemployed do not seem to live fulfilling lives. Self-actualization is as important for them as it is for the wealthy, but they suffer from a failure of imagination.

Share:

Like this:

A recipe is basically a fixed set of actions and ingredients, while cooking techniques are just the possible actions. If we invent cooking patterns – an abstraction on top of each ingredient / action pair – we could have more understanding of the dish we are preparing while keeping the flexibility in ingredient and technique choice.

Let’s take fritters as an example. Wikipedia says the following:

Fritter is a name applied to a wide variety of fried foods, usually consisting of a portion of batter or breading which has been filled with bits of meat, seafood, fruit, or other ingredients.

A pattern in its most obvious form. Notice the “wide variety”, a fixed ingredient (batter) and a list of possible variables (meat, seafood, vegetables, fruit) that could influence the fritters you end up making.

I find this idea very exciting, because I enjoy cooking and am also in the process of learning more about software design patterns.

Cooking patterns seem like an accessible way to introduce beginners to more abstract ideas about software, too. Algorithms are often described as “recipes,” and this is a nice way to build on that concept.

For leveling up your cooking skills, ChefSteps looks promising. Their resources include classes, projects, and an ingredients wiki. I have signed up for one class and plan to follow up on this recommendation after completing it.

Like this:

A great majority of the web is built on open source software. Approximately two-thirds of public servers on the internet run a *nix operating system, and over half of those are Linux. The most popular server-side programming languages also tend to be open source (including my favorite, Ruby). This post is about adding a new open source library to an existing code base. What questions should you ask before adding such a dependency to a production application?

The first set of questions are the most basic. A “no” to any of these should prompt you to look elsewhere.

Is the project written in a language you support? Is it in a language you support? If not, is it compatible (e.g. through stdin/stdout or by compiling to your language of choice)?

Is the project in a version of of the language you support? If it’s written in Python 3 and you only support Python 2, for example, using this library could lead to headaches.

Can you use the project in your framework of choice (e.g. Rails or Django)?

Are there conflicts with other libraries or packages you’re currently using? (This is probably the hardest question to answer, and you might not know until you try it.)

Assuming there are no immediate technical barriers, the next questions to ask are of the legal variety. Open source licenses come in many flavors. In the absence of a license, traditional copyright rules apply. Be especially careful if the project you are investigating uses the GPL license–even basing the code you write off of a GPL open source project can have serious legal ramifications. There’s a great guide to OSS licenses on Github. If you’re the author or maintainer of an open source project checkout choosealicense.com.

The next thing to consider is whether and how the project is tested. If there is not an automated test suite, consider starting one as your first contribution to the project and be very reluctant to add the project to your application. Other related questions include:

Are there unit tests?

Are there integration tests?

What is the test coverage like?

Do the tests run quickly?

Are the tests clearly written?

Finally, by using an open source project you are also joining a community of developers. None of these questions are necessarily show-stoppers but knowing the size of the community and the tone of its discourse can save you pain down the road.

Is the project actively maintained? When was the last commit?

Does the community have a civil, professional style of debate and discussion?

Is there only one developer/maintainer who knows everything? This doesn’t have to be a deal breaker. However, if there is a single gatekeeper you should make sure you understand the basics of the code and could fork the project if necessary.

This is by no means an exhaustive list but these questions can serve as a useful checklist before adding an open source as a dependency for your project.

Share:

Like this:

Computer science is increasingly relevant to a wide range of professional fields, yet many working programmers today do not have a formal CS education. This makes it difficult for the uninitiated to read academic research in computer science and related fields. Keeping up with the latest research is not a job requirement for most programmers, but understanding fundamental papers (such as the ones listed on Papers We Love) is important for building on established knowledge.

However, jargon and unfamiliar symbols present a non-trivial barrier to entry. This came up in the discussion on a recent episode of the Turing Incomplete podcast. A few existing resources were mentioned such as Wikipedia’s math symbols page and Volume I of The Art of Computer Programming. None of these is ideal for new programmers who may not know the names of the symbols, though.

Share:

Like this:

The first principle is that you must not fool yourself – and you are the easiest person to fool. – Richard Feynman

Programmers love to fool themselves. “This line has to work! I didn’t write that bug! It works on my machine!” But if ever there was a field where you can’t afford to fool yourself, it’s programming. (Unless of course you want to do something like lose $172,222 a second for 45 minutes).

Over the years I’ve enjoyed lots of articles that talk about false assumptions that programmers accept without really questioning them. I thought it would be helpful to have these collected in one place for reference purposes. If you know of articles that would be a good fit on this list, let me know and I will add them.

Like this:

My Journal of Quantitative Criminology article “The Impact of Leadership Removal on Mexican Drug Trafficking Organizations” is now in print. For the abstract and other discussions of the research see here, as well as the posts tagged “Mexico,” “drug trafficking,” and “leadership removal“.

Here is a timeline of the research and publication process:

Read an article in the Economist about DTO leadership removal, December 2010

Preliminary research for a graduate seminar in time series analysis at the University of Houston, Spring 2011

Draft of paper incorporating other research on organized crime and political violence for a seminar at Duke University, Fall 2011

Revised manuscript rejected from a political violence journal after R&R, Late summer 2012

R&R from JQC, Summer 2013

Accepted for publication in JQC, December 2013

Published online, March 2014

Published in print, December 2014

All in all, a four-year project, with no significant changes to the manuscript in about 18 months previous to the print publication. The paper absolutely improved thanks to feedback from reviewers and quality, but I think you will agree that this is a very long feedback cycle.