April – 4th Agile Principle

Business people and developers must work together daily throughout the project.

We are now getting to one of the most widely ignored principles of agile development. It is clear, succinct and quite definite. It says that business people and developers must work together daily. Note that it doesn’t say business people and developers should work together daily. The keywords are must and daily. Why is this principle often ignored? Because business people are often too busy to talk to developers. There are several reasons for that. First of all, they usually have other responsibilities than managing software development. Second, they may simply not be available every day. Third, business people and developers often don’t understand each other. It’s almost as if they speak a different language. Developers speak about technology and business people speak about goals, opportunities, and strategies.

Before we go into these issues, let’s briefly elaborate why it is important that developers and business people cooperate on an ongoing basis. Unlike the waterfall method or any other method that is based on a grand plan, agile development relies on a progressive formulation of requirements. This is the same feature that makes agile development adaptive and open to change. The drafting of requirements happens incrementally and thereby mirrors the development process. Specifications evolve throughout the project. There is no single prescribed method for how business requirements are being translated into detailed technical specifications. It can be done in a number of ways. However, it is understood that business people and developers must be in an ongoing dialog to make this happen.

Frequently, requirements begin with a high-level road map or whitepaper. This document contains a description of the overall goals and high-level functionality of the project. It is generally too abstract to be used for technical implementation. However, it may be followed a description of the envisioned architecture. The next step consists of defining different large-scale features (epics) that touch upon distinct aspects of functionality. This step again requires a dialogue of business people and developers. Epics are still too abstract and too large to be worked on directly. The entire process of requirements gathering can be seen as a successive refinement of specifications to the point where specifications can be encoded in computer language. Epics are broken down further into units of work that agile teams consider appropriate for concrete implementation, so-called user stories.

A user story is a conceptual tool of agile development. It describes a software feature from the perspective of a user. For example: “As an administrator, I want to be able to approve new comments before they are posted.” This is a proper user story containing a user role and a feature description. During the course of technical planning of a user story, further details are specified, such as the user interface particulars for that specific story. Diagrams, tables and UI mockups may be created during this phase. This implies again that there is dialogue between those who provide specifications (business) and those who implement them (developers). Without continuous cooperation, requirements end up being too vague and software artifacts end up being incomplete or flawed. The requirements refinement process runs parallel to implementation and testing. It requires management from the business side. Together, they make up a sort of pipeline that runs from high-level specifications to usable software.

In a typical Scrum team, there is an appointed manager (called “product owner”) who leads the requirements refinement process. The product owner acts as a sort of intermediary between business and development. On the other hand, a typical Kanban team is cross-functional and has no appointed roles. Members from business provide guidance directly without a project manager. Project management is often handled on demand by individual team members, depending on the nature of the task. In a Crystal team, project management depends on team size. There may or may not be an appointed project manager, often an executive sponsor. Business and development come together for Blitz planning sessions to define tasks and schedules. The refinement process is informal and relies on other methods such as co-location, daily meetings, or brief review-and-feedback loops with expert users. The problem of translating business requirements into software features and codeable functions can be solved in many ways. The one thing that all the different agile methods have in common is that business people and developers work together on an ongoing basis.

What can be done to improve communication between business people and developers? The problem of allocating sufficient time for exchanges can be solved in different ways. Appointing a product manager who works face-to-face with the team works well. Setting up regular meetings, such as feature planning, iteration planning, reviews, and backlog refinement meetings also works well. Having an executive sponsor working with the team is likewise a good solution if the sponsor is approachable and dedicates enough time to the task. Even informal communication can succeed if business people and developers are co-located at the same work space. The language problem can at least partly be tackled by developing a domain-specific vocabulary. Organisations usually have quite specific structures, roles, workflows, service offerings, etc. It is important to agree on a fixed terminology for these when phrasing requirements. This helps eliminating ambiguity, because ambiguity and vagueness are the principal obstructions to a successful implementation.

In summary, the 4th agile principle describes one of the most important factors to determine success or failure of software development projects.

March – 3rd Agile Principle

Deliver working software frequently, from a couple of weeks to a couple of months, with a preference to the shorter timescale.

You might wonder how the third agile principle differs from the first. The first principle talks about “early and continuous delivery” of software. This sounds a bit similar to “delivering software frequently”. However, there is a significant difference. The first principle is all about customer satisfaction. It is realised by continuously delivering value to customers. The third principle is all about method. The principal method used to achieve the goals of the first principle is development in iterations. An iteration is a defined time span during which the entire software development life cycle (SDLC) is traversed. An iteration starts with requirements analysis and ends with software delivery. It can be modeled as a closed and repeating cycle.

If we recall the waterfall model, there are some major differences. Mot importantly, the waterfall model traverses the software development cycle only once. This usually takes a much longer time. It is common that the duration of this long-term traversal cannot be predicted exactly. For that reason, deadlines are often postponed. Another major difference is that roll out/deployment and maintenance phases are periods at the end of the waterfall SDLC, whereas agile methods do not stipulate predetermined phases for these activities at all. Agile teams carry out maintenance “on the go”; it is part of the normal development work.

The time frame of an agile iteration is more rigid, by contrast. It is commonly fixed and takes anywhere between a few weeks and a few months. For example, teams that use Scrum often work in cycles of 2-4 weeks. There is no delay or postponement. Instead, if a feature is not ready, it is moved to the next iteration. The quantity of work completed within this relatively short amount of time is of course much smaller. So, at the beginning of each cycle, the team continues to build upon the foundation laid in the previous cycles. The process is therefore also incremental. This has certain advantages for both developers and clients.

Let’s state again that the agile process is both iterative and incremental. This is important. At the end of each iteration, new features and fixes are demonstrated to the stakeholders. In many cases, the iteration also results in a release, which means that software is deployed to production at the end of a single iteration. However, this is not written in stone. For example, a team may decide to work in 2 weeks iterations while adopting a release cycle of 4 weeks to match maintenance windows. Another team may prefer a continuous delivery model where features are released to production as soon as they become available.

It does not matter, as the iteration is not strictly coupled to the release plan. What matters is that software is delivered frequently and that the time span of an iteration is kept as short as practicably possible. This makes for a short feedback loop which allows stakeholders to intervene quickly. It increases the control of business stakeholders and allows for an amount of flexibility that is impossible to attain with the traditional waterfall process. For example, change requests and bug fixes can often be implemented and released within a single iteration making for a time to market that can simply not be achieved with any other method.

From what has been said, it follows that the agile process is also evolutionary and adaptive. Because large scale features are built incrementally over the span of multiple iterations, developers build on the foundation of existing architecture and functions. New blocks of software are added to existing blocks. Existing blocks are sometimes refactored or changed. It is therefore possible to test concepts in practice before a feature is completed. It is also possible to improve concepts and functions over the span of multiple iterations. The end result is always working software.

This means that software features, especially large scale features (called “epic” in Scrum methodology), are not typically conceived at the drawing board. Instead, prototypes and proof-of-concepts make their way into working software long before the planning and implementation of a large scale feature is completed. This is another major difference to the waterfall model. The key advantage provided by a short feedback loop is that bugs, logical errors and flawed concepts can be spotted and corrected early. This keeps the cost of such improvements to a minimum.

Because the evolutionary and adaptive nature of the agile software development process, planning and design is often restricted to a relatively small time frame and is open to change. For example, the requirements for implementing an epic could change midway during one of the many iterations it takes to complete the epic. In some cases, these requirement changes necessitate rethinking and altering existing features or even rethinking architecture. Code refactoring, the restructuring and improvement of existing code without changing its functionality, is therefore very important in agile development. Without continuous refactoring, agile projects are in danger of accumulating technical debt.

Continuous refactoring is perhaps the price that has to be paid for the extreme flexibility and quick time to market that agile development affords. A team that follows an adaptive approach must guard against code smells and software entropy. Only with sustained attention to these problems, software will stay maintainable and extensible in the long run.

The Open Closed Principle Revisited

An interesting discussion came up in a recent code review. Looking over the OOP implementation of a menu class, a colleague remarked that classes should always be designed open for extension and closed for modification. Sounds right, as it reflects generally accepted OOP practices. The open-closed principle, the “O” in SOLID, is an essential principle of sound object-oriented design. You probably already knew that. Here is the initial design of that class.

class Menu {
private constructor()

static createForUser(user: User) : Menu
static createForLegacyUser(user: LegacyUser): Menu

public getThisMenu(): MenuData
public getThatMenu(): MenuData
public getAnotherMenu(): MenuData
}

The menu class can be instantiated in two different ways, either with a regular user or with a legacy user. Both user objects provide authorization via ACL. The menu class has several getters that return different menus. The dynamically created MenuData contains only the menu options the user has access to. The private implementation methods are omitted. These perform authorization using the user objects and also translate the menu items into the user’s UI language. The menus themselves are configured in external YAML files and their structure can be changed as long the expected YAML format is maintained.

As you can gather from the design, this class is not designed with extension in mind. It is possible to add other menus, but only by extending it and adding a getYetAnotherMenu() method. Unfortunately, inheritance is not very practicable here. Extending for other types of users isn’t possible at all, because the respective authorisation code would have to be added to the implementation. Let’s summarise:

  1. Very easy: adding or removing menu options and sub menus to the existing menus
  2. Possible, but not that easy: adding or removing menus
  3. Not possible: adding other types of users

An obvious weakness of the above design is the redundancy in the getters and the fact that the menus themselves are fixed. This can be improved quite easily:

class Menu {
private constructor()
static createForUser(user: User) : Menu
static createForLegacyUser(user: LegacyUser): Menu

public getMenu(menuIdentifier: string): MenuData
}

Instead of invoking it with menu = Menu.createForUser(user).getThisMenu() to obtain menu data, this class is now invoked with menu = Menu.createForUser(user).getMenu(‘thisMenu’). The identifier is associated with the respective YAML file from which the menu data structure is created. Let’s summarise again:

  1. Very easy: adding or removing menu options and sub menus to the existing menus
  2. Very easy: adding or removing menus
  3. Not possible: adding other types of users

At this point, I was quite happy with the simplicity and flexibility of the design. We’ve made it both easy to extend menu options as well as menus themselves. My colleague, however, wasn’t happy. He insisted that the open-closed principle must also be applied to user types. And this is where it gets philosophical. Of course, it is possible to do that. But it requires significant changes and a further abstraction. We need to remove the authorisation implementation from the menu class, create an Authoriser interface and provide Authoriser classes for regular users and legacy users that implement Authoriser.

class Menu {
static create(authoriser: Authoriser) : Menu
public getMenu(menuIdentifier: string): MenuData
}

interface Authoriser {
boolean authorise(role: AclRole)
}

class RegularUserAuthoriser implements Authoriser {
constructor(user: User)
authorise(role: AclRole)
}

class LegacyUserAuthoriser implements Authoriser {
constructor(user: LegacyUser)
authorise(role: AclRole)
}

Why philosophical? Because, while this is a textbook implementation of the open-closed principle, we have never added any other user types in years. The system has only two types of users: regular users and legacy users. The likelihood of having other types of users in future is almost nil. This raises two questions: First, is the cost of extensibility and extra abstraction justified? This change obviously makes the code more complex. Second, how do you know what kind of extensibility will be required in future?

I would answer the first question with “no”. It is not worthwhile complicating the design to achieve extensibility if this extensibility is not needed. Doing so would constitute a YAGNI antipattern. YAGNI stands for “you aren’t gonna need it” and originates from the core principles of extreme programming (XP). According to XP, features should be implemented as simple as possible and without making unwarranted assumptions about future use cases. This is very much related to the KISS principle, which in turn has its foundation in philosophy: Occam’s razor and the law of parsimony. In practical terms: the simplest implementation for a given requirement is the best implementation.

If you paid attention, you might already see the dilemma. There seems to be a contradiction between YAGNI and the open-closed principle. If we design a class that is open for extension and closed for modification, this usually means we have to define additional interfaces that formalise the extensible behaviour. This is to say, the open-closed principle results in increased complexity, contradicting KISS, YAGNI and Occam’s razor. So, what should we do?

Consider the second question we have asked before: how do you know what kind of extensibility will be required in future? Simply speaking, if you don’t know, then don’t build it. Classes usually contain more than a sinlgle dependency and a single behaviour. Designing extensibility into each dependency and behaviour is a very bad idea, because it would make the design extremely complex. The open-closed principle should be applied in situations where the need for extensibility is either established or very likely. The “O” in SOLID must not be applied indiscriminately..

Contemplate the following quote of former US secretary of defense, Donald Rumsfeld:

There are known knowns. There are things we know that we know. There are known unknowns. That is to say, there are things that we now know we don’t know.. But there are also unknown unknowns. There are things we do not know we don’t know.

At first, this statement sounds a bit perplexing, but it makes perfect sense. It can be applied to our OOP problem as follows:

The known knowns are the features described in the functional and technical specifications. They are spelled out unambiguously and can therefore be translated directly into concrete implementations. The known unknowns are the features that we can predict, but their concrete implementation is unknown. This is where the open-closed principle applies. For example, if we write a printer spooler, we know that the spooler should work with all sorts of printers, although we don’t know the concrete printer models. Therefore, we provide an interface that can be implemented for any concrete printer model which he spooler then uses to perform its function. Finally, the unknown unknowns are the sort of features that we cannot predict at all.

As mentioned, designing extensibility for unknown unknowns results in unneeded complexity. The same is true for the known knowns since they are fixed. There is no need to design an interface for a class if we already know that there will be only one concrete implementation. Hence, the open-closed principle makes sense only for the known unknowns, namely the situations where feature extensions can be predicted with some degree of certainty.

Coding interviews – rad or fad?

As a developer, you probably have gone through one or more coding interviews. When applying for a developer job, you are expected to demonstrate some level of programming chops by solving algorithmic problems on a whiteboard or in an online code editor. This practice is not new. My first coding interview took place more than 25 years ago sitting at a lovely green text terminal. However, it has recently proliferated and became an integral and often time-consuming part of the interview process. Especially big American tech companies like Amazon, Apple, Facebook, Google and Microsoft are pushing the envelope. To land a developer job at one of these companies, you are now expected to be able to recite the finer points of an algorithm manual and produce solutions with O log(n) time complexity in a trice.

Does that sound just slightly ridiculous to you? Perhaps it is. The question one must ask is whether having candidates produce algorithms is actually a good indicator for success in the software development profession. I have been sitting at both ends of the interviewer’s table many times, and I am quite ready to doubt this implication. There isn’t much empirical evidence to support the thesis that people who score high on coding interviews also do well in their jobs. Actually, there is none. Even Google’s own study concluded that interview scores don’t correlate with job performance. Gayle Laakmann Mc Dowell, the author of the book “Cracking the Coding Interview” says: “No one really knows, but it’s very reasonable to assume that there is a link,” and “Absence of evidence isn’t evidence of absence.”

Sorry, that’s not good enough for me. Let’s be a little more scientific.

Perhaps we begin by determining what is actually measured by solving an algorithmic problem. The coding interview is akin to a school exam. It measures how good you are at applying textbook solutions to a given task. Just as in an exam situation, you can improve your score by studying hard. The domain is broad enough to provide sufficient variation in different fields from number theory and graph theory to combinatorics and set theory. Yet, algorithms themselves are very narrow as they deal with a specific solution to a specific problem. A successful coding interview demonstrates three things: 1. the candidate can write code, 2. the candidate has a grasp of algorithms and can memorize textbook solutions, 3. the candidate can reproduce and explain these solutions.

At first glance, this seems useful. These traits are surely expedient in typical development work. They’re kind of expected from developers. But does the coding interview also measure how well pronounced these traits in a particular applicant are? Can standardised interviews establish a framework for comparison? The answer is sadly no. One applicant might receive a familiar problem that he can solve and pass with flying colours. Another more talented applicant might have never before encountered the same problem and fails to solve it. A third applicant may get bogged down by anxiety. Yet another applicant may solve the problem, but produces bugs because of using an unfamiliar language. The result is influenced by many factors and it is notoriously unreliable.

This is not the only problem. There is a more serious one: the coding interview only probes a very narrow set of skills. Being able to produce algorithms is not sufficient to become a successful developer. For example, a developer also has to read and interpret requirements, communicate within a team and with business people, have knowledge of technologies and best practices, perhaps also have an understanding of certain industries. In this light, being able to memorise textbook algorithms seems somewhat less relevant. After all, you can always look up a manual when in need of an optimised algorithm for a specific problem. This is probably what most developers would do in their day-to-day work.

I remember a peculiar coding interview that took place 10 years ago on the phone before shared online code editors became a thing. I was asked to spell out an algorithm that produces the series of prime numbers. “No problem,” I said, “just let me google the sieve of Eratosthenes.” “No no, let’s just improvise,” said the interviewer, “it doesn’t have to be perfect.” So I scribbled down some similar, yet doubtlessly inferior code that mimicked Eratosthenes’ idea and read it out loud (awkwardly) on the phone. Something I would never do in an actual work situation. Yet, I passed the interview and got the assignment.

Is this a good predictor of professional performance? No, it isn’t. It is way too arbitrary and readily produces false negatives as well as false positives. There is a considerable amount of HR management literature that has identified good and bad predictors for work performance. Among the worst predictors are first impressions, school grades, and brain teaser questions, such as “how many golf balls can you fit into a phone booth?” Finding the answer to that is a lot like devising an algorithm for a geometry problem. You get the clue. Case in point: Max Howell, the author of the popular “Homebrew” package manager for macOS was (infamously) rejected in a Google interview, because he was not able to produce an algorithm for inverting a binary tree. Howell’s software is used by millions of Mac users and is now maintained by a team of 21 people. Yet, he wasn’t good enough for Google.

One of the best predictors for future job performance is past performance. Duh. It’s kind of obvious and also backed up by evidence in the form of empirical studies in management. Had Google considered past performance instead of algorithms, the company would now be richer by one accomplished engineer, who according to his own words cares more about user experience than about computer science. People often have special talents that evade the standardised interview process. They will not escape an experienced interviewer, however. The only problem with past performance is that data is not always available. For example, what about grad students, career changers, and people with little work experience? Well, the second most reliable predictor for job performance is cognitive ability, also known as “g factor” or general intelligence. The literature is again quite solid on this point.

It stands to reason that a standardised and culturally neutral IQ test provides a much better predictor for future performance. And by “much better” I mean an order of magnitude better. It is also less time-consuming than going through a series of algorithm/coding problems. So why are companies not using them? One reason is that in certain countries, such as the USA, IQ tests are seen as potentially discriminatory and could therefore be legally contestable. This is obviously a matter of policy, and well idiocy. Encountering an IQ test in a job interview appears to raise more eyebrows than encountering a esoteric programming problems. Another reason is that high quality standardised and culturally neutral IQ tests are somewhat difficult to develop. And new ones would have to be developed all the time to ensure high quality results and to prevent abuse. Yet another predictor for career success was recently (2013) suggested by Angela Lee Duckworth in a TED talk. She called it “grit”, or the “power of passion and perseverance” and subsequently received a lot of attention from the tech industry. The problem with “grit” is that as of now no reliable way of measuring it has been devised.

So, the question that springs to mind is: why do companies use coding interviews in the selection process if they already know that the resulting score is a poor predictor for career success. Frankly, I don’t know. If you’re a big tech HR manager, please comment and enlighten us. I can only speculate. Companies like Facebook, Google or Apple are swamped with applications and might have to create artificial barriers to filter applications and reduce the number of candidates to a manageable amount for round two. What does this artificial barrier achieve? Perhaps it is about grit. Only the ambitious candidates will pass, namely the ones that are willing to learn and memorise algorithm textbooks just for the interview, and just for getting the chance to land a job with that big tech company. It is reasonable to assume that someone who has the motivation to put in three or four weeks of cramming for an interview, is also motivated to put in hard work into their job. In this case, developer interviews could just as well require candidates to conjugate Latin declinations and cite Roman philosophers. The effect would be the same, although it would certainly raise many eyebrows.

Another plausible explanation is that companies nowadays tend to put processes over people. The decision making process, especially in large enterprises, is highly formalised. Instead of leaving the hiring decision to an experienced HR manager who relies on their personal knowledge and skills, it is relegated to an impersonal procedure that produces data. On one hand, this frees decision makers from personal accountability. On the other hand it provides an instrument that top management can manipulate at will. For example, if management should want to steer their engineering staff into a new direction, it could replace algorithm questions with machine learning questions. Whatever the reasons may be, we can be sure that thousands of smaller tech companies will follow suit and imitate the example of Google, Microsoft and others, even if they don’t understand their reasons and even if the adopted procedures aren’t fitting their own true needs.

In the end, I believe coding interviews are not totally useless. They are an effective means to engage the candidate in his field and simulate a work situation. The coding interview gives the interviewer a chance to observe how a candidate approaches technical problems. For example, it may reveal whether the candidate’s course of action is methodical, or whether they have exaggerated their familiarity with a certain technology. Under ideal circumstances, it can reveal a lot about how a developer thinks. However, since an interview is a special situation these indicators need to be evaluated carefully. For the benefit of all involved parties, the coding interview is best conducted in a casual way. An expanded problem space leaves the candidate with more choices and is is likely to provide more information. I don’t see any good reason, why coding interviews should be conducted like a university exam, however. If you can think of any, please let us know.

The code is the documentation

The first time I heard someone saying: “the code is the documentation”, I thought it sounded completely wrong, like a lazy excuse for not producing documentation. However, it kept me thinking and I realised that there is also truth in this statement. This paradoxical thought-provoking quality makes it a proper mantra for agile practitioners, because it expresses a fundamental agile value: “working software over comprehensive documentation”.

Before we go further into details, I should dismiss the notion that agile developers don’t write documentation or misconceive its worth. Nope. We still produce documentation. However, we also apply the following agile principle to it: “Simplicity, the art of maximising the amount of work not done, is essential.” It is expedient to minimise documentation by adhering to practices that reduce the need for it. In agile development, documentation takes on the role of accessory parts whereas the primary attention is given to the codebase. Or more succinctly:

“Truth can only be found in one place: the code.” (Robert C. Martin, Clean Code)

The codebase is the ultimate source of truth. It is referenced in case of doubt, when a question is either too detailed or if the documentation is out-of-date. The code provides insight where no other method of reference is available. With this in mind, it is evident that code should be written in a way that is well-structured and understandable. Self-documenting code reduces or disposes the need for external documentation. Knowledge is represented in a single artefact and there is no need to synchronise multiple sources. Unfortunately, most real-world codebases do not have these ideal qualities. There could be many reasons for that, but the most common reason is that software entropy has taken its toll over time, and that too little attention was paid to refactoring.

So, code quality, self-documenting code, and continuous refactoring go hand in hand. It is important to understand that the highest code quality is achieved through conceptual clarity. Conceptual clarity comes from good naming and  good structure. This is by far more important than coding style, naming conventions, formatting and other external features, although the latter do of course contribute to code quality. Naming and structure cannot be tested automatically. Unlike code style, conventions, and formatting, they require human perception and intelligence. Which is one more reason to adopt such practices as code reviews and pair programming.

Coming back to “the code is the documentation”, I think the best way to understand this phrase is as an abstract ideal that ought to be worked towards. In an ideal world, code doesn’t need additional documentation, because it is so beautifully clear that it can be understood by anyone without any prior knowledge. It answers all questions that might arise about the software. It clarifies the intentions of the programmer and it is therefore also easy to maintain and change. Obviously, this is really difficult to achieve in the real world, especially across a large codebase, but its self-documenting properties are quite likely the best measure of code quality.