What is Tao? It’s a complex idea – but one method of thinking of it is to find the natural way of doing things, and then making sure you do things that way. It is intuitive knowing, an approach that can’t be grasped just in principle but only through putting them into practice in daily life.
The principles of Tao can be applied to almost anything. We’ve seen the Tao of Physics, the Tao of Pooh, even the Tao of Dating. Tao principles apply just as well to DevOps – because who can know fully what DevOps actually is? It is an idiom as hard to define as “quality” – and good DevOps is closely tied to the good quality of a software product.
Want a simple example? A recipe for cooking a dish normally starts with a list of ingredients, because that’s the most efficient way of describing cooking. When making a simple desert, the recipe starts with a title: “Strawberries And Cream”. Already we can infer a number of steps in making the dish. We must acquire strawberries and cream, and probably put them together on a plate. The recipe will continue to describe the preparation of the dish in more detail, but even if we read only the heading, we will make few mistakes.
So what does this mean for DevOps and product creation? When you are putting things together and building things, the intuitive and natural way to describe the process is to do it declaratively. Describe the “whats” rather than the “hows”, and then the “hows” can be inferred.
The Tao of Building Software
Most build tools have at their core a way of declaring relationships between software components. Here’s a Make snippet:
a : b cc b
And here’s an Ant snippet:
And a Maven snippet:
Many people think they wound up in a Lovecraftian hell when they see XML, even though the brackets are perfectly euclidean. But if you squint hard enough, you will see that most tools at their core describe dependency trees.
The Apache Maven tool is well-known, and very explicit about the declarative approach. So, let’s focus on that and try to find the Tao of Maven.
When we are having a good day with Maven and we are following the ways of Tao, we describe what type of software artifact we want to build, and the components we are going to use to put it together. That’s all. The concrete building steps are inferred.
Of course, since life is interesting and complex, we will often encounter situations were the way of Tao eludes us.
Consider this example:
type:pom antcall tar together ../*/target/*.jar
Although abbreviated, I have observed this antipattern several times in real world projects. Whats wrong with it? After all, this antipattern occurs because the alternatives are non-obvious, or more verbose. You might think it’s fine.
But first of all, notice that we are not describing whats (at least not in a way that Maven can interpret). We are describing hows. Fixing this will probably require a lot of work, but any larger build will ensure that it eventually becomes mandatory to find a fix.
Pause (perhaps in your Zen Garden) and consider that dependency trees are already described within the code of most programming languages. Isn’t the “import” statement of Java, Python and the like enough? In theory this is adequate – if we disregard the dynamism afforded by Java, where it is possible to construct a class name as a string and load it. In practice, there are a lot of different artifact types that might contain various resources. Even so, it is clearly possible in theory to package all required code if the language just supported it. Jsr 294 – “modularity in Java” – is an effort to provide such support at the language level.
So what have we learned? The two most important lessons are simple – when building software (or indeed, any product), focus on the “Whats” before the “Hows”. And when you’re empowered with building tools such as Maven, make sure you work with the tool rather than around it.
About the Author
Joakim Verona is a consultant with a specialty in Continuous Delivery and DevOps, and the author of Practical DevOps. He has worked as the lead implementer of complex multilayered systems such as web systems, multimedia systems, and mixed software/hardware systems. His wide-ranging technical interests led him to the emerging field of DevOps in 2004, where he has stayed ever since. Joakim completed his masters in computer science at Linköping Institute of Technology. He is a certified Scrum master, Scrum product owner, and Java professional.