Category: Uncategorized

  • Dark Mode

    I finally pulled the trigger on dark mode. I tend to write many of my posts late at night, especially these days, so dark mode is much easier on the eyes for my own writing. I’m still fiddling with the formatting, but I aim to have a style that’s easy to read at night for long periods of time, if nothing else than for my own sake.

    It’s true that I don’t post frequently, but I regularly write without publishing because I feel it still helps me refine my thoughts. It’s common for me to write partial posts and sit on them for months before I refine what I want to say enough to actually publish it.

    That’s the best part of the process for me. I can choose to publish something, or not. Sometimes I do wish I could publish more, but there are occasions where I write things that I really shouldn’t post. But don’t worry. I’m still here.

  • Be Careful What You Post Online

    The political events in the last couple days have caused a firestorm of social media posts – some being quite extreme. I have heard reports of people being fired for their social media comments and a few organizations closely watching their employees for the same. Instead of my more heavily curated and edited posts, I wanted to talk about something more timely – not about the event itself, but about the importance of being careful with what we post online.

    At one of my previous companies, some coworkers of mine decided to set up a Slack server for talking about both work and non-work topics. It was the online water cooler and was a lot of fun. It connected us together by giving us our own space that was much more free than the tightly controlled official one. But the organizers were later fired for talking badly about another coworker in that server in private conversations. In that same investigation, another was fired for leaking proprietary information. He had merely copy-pasted some small code snippets to request help, but since some members of that server had left the company, it was technically true, if quite a stretch. Yet another was fired for reasons no one could determine and who seemed completely innocent.

    Being careful about what we post online goes beyond simply avoiding posting hot takes on social media, but being cognizant about anything we say anywhere, especially in writing. It is trivial to screenshot anything and send it to anyone else. It is also often not too difficult to link people’s real information with usernames, as we are rarely as anonymous as we think we are and the consequences of what we might post under a username may not come for a long time in the future.

    I know this may seem to fall in the box of Things Everyone Obviously Knows, but that’s only true if you look at the surface level. The events of this week have caused many people to post some pretty extreme takes and we can feel like we need to join in to counter the narrative from the other side, but this feeling is being engineered by algorithms designed to make us feel this way to maximize engagement, because nothing gets the internet going like anger at perceived injustice. Knowing this is true does not make us immune to that effect, but when you post something online, you never know who’s watching and even when posting under a username, you never know if you’ve accidentally left enough clues that can lead angry users to follow the trail to your real self.

    You have likely heard the best approach is to assume everything we say online could be made public, but it can go further than just what we say. The aforementioned coworkers also spun up a Discord server with a smaller sub-group that included a not-safe-for-work channel. That by itself was already a bad idea, but the choice to invite female coworkers to that server was immensely bad. Any one of them feeling uncomfortable would find immediate success with HR who would be more than willing to avoid a potential sexual harassment lawsuit. And without even posting in such a channel, merely being the owner of such a server, or possibly even just a member could be sufficient grounds for an HR that wants to go scorched earth.

    The Pros and Cons of this Blog

    One of the greatest joys in writing my blog posts is knowing people actually read them. I started this blog primarily for fun. I write when I feel about it on topics I am compelled to discuss, but because my only social media is LinkedIn, if that counts, and thus where I primarily link these posts, my readership mainly consists of my current manager as well as current and former coworkers. Former coworkers I have written about have told me they read the post and recognized it was about them, even though I was unaware they had ever seen anything I wrote. Current coworkers congratulated me on the birth of my daughter because they saw my blog announcement instead of the ones I made through our official channels. It can be surprising to see.

    So far, this has been a great thing. I enjoy seeing comments and messages from you all and I write with the expectation that the people I write about will see the post and know its about them. I write with the expectation HR, or the CEO might come by. And I write what I have usually said publicly already, reserving the real hot takes for my wife and her infinite wellspring of patience to listen to me.

    That means not only must I avoid controversial takes on political issues, but criticism towards my employer, current coworkers, customers of my employer, or details about internal operations that could technically be considered proprietary information. This may be my blog with my domain name – no moderators to avoid and no algorithm to feed, but posting safely requires quite an extensive list of things to avoid.

    My situation probably isn’t yours, but the same rules apply – when the internet firestorm is raging, it’s best to stay away so you don’t get burned. This doesn’t mean we should avoid talking about difficult topics or self-censoring our identity because some part of ourselves has been deemed “political,” but consider this – if everything you ever said online, publicly and privately, was revealed to the world under your real name, would you still look okay?

  • It’s a Girl!

    This week, my wife gave birth to our daughter. I don’t plan on posting pictures or turning this into a parenting blog, but if I start making references to parenthood, you’ll know why. I’m not in the habit of sharing life updates here, but those of you who haven’t seen me in a few years may be interested to know.

  • AI as Magic Fairy Dust

    AI is taking the world by storm. There’s nowhere on the internet you can go without stumbling into it. They call it the revolution of our time, the greatest invention since the Industrial Revolution. Be you supporter or skeptic, it’s hard not to get swept up by the wave of enthusiasm. But is it just the next worthless fad or does it actually live up to the hype?

    That has been a difficult question for me to try to answer. I’ve been sitting on this post for about 3 months trying to explain my feelings on it, but in summary, I can’t answer with a yes or no. I believe AI is currently under-utilized for its current capabilities while also being overhyped for what people want it to be able to do. I expect where AI is being under-utilized, the gap will eventually be filled in as experimentation continues, but the latter case is wishful thinking.

    I think there is a real danger in AI, not because I fear a superintelligence that will wipe out humanity, but because overly ambitious hype men, like Sam Altman, will drive everyone into making sky-high promises about multiplying developer productivity tenfold, diverting trillions of dollars away from other, better investments, while only yielding a fraction of the promised results.

    Most often, the AI conversation is centered around what we want AI to do and not grounded by its actual capability. AI is magic fairy dust that can be sprinkled anywhere to solve all of our problems. It is not only the silver bullet that solves all our problems in one domain, but the one that solves all problems in all domains.

    A few months ago, Tebra hosted a company event focused on AI, which was my primary motivation for this post. With our teams, we sat down and listed the current problems we were facing – a useful exercise that we had not done before. However, we then had to turn around and decide how we could use AI to solve those problems. This is what brings out the magic thinking. It’s actually rather akin to AI hallucinations. The LLM knows you want an answer, but an answer does not exist. How do you satisfy the requirements to provide an answer without data to support it? You make it up. How do you solve issues with AI while having no known way of doing so? You make it up.

    This doesn’t stop at the developer level though. CEOs make promises to boards and boards make promises to their investors that they will enhance productivity and company valuations in the same way and money flows to those who can make the most convincing sale. Those wanting more immediate effects will cut their workforce and demand their remaining workers increase productivity to cover the difference. 10x productivity becomes an expectation, a demand.

    I have yet to even discuss the actual capabilities of AI, because I think no matter how good they get, expectations and demands will far outpace reality. As we saw with the recent release of GPT-5, modest improvement is now a failure. These companies demand more of our expensive power and more of our increasingly dwindling water supply to meet the impossible expectations of their userbase. It’s hard not to see the parallels to cryptocurrency.

    Despite my scathing criticism, you may be surprised to find that I actually like AI. I read Anthropic’s paper on Claude Opus / Sonnet 4 and I’ve been using Claude Code a lot on my own projects. It’s been quite fun to experiment, but that’s because there’s no demand for maximum productivity, no expectation to fit it where it doesn’t belong. So, I often stand with the AI skeptics, not because I always agree with them, but because they’re the ones who still make me feel sane and grounded in reality.

    Here’s my prediction – nothing has changed fundamentally about the business of software. Success continues to be defined by our ability to deliver value to customers by fulfilling their needs. In all but the newest companies, it has never been predicated on speed of delivery, but instead an understanding of what to deliver. Using AI to deliver more is only meaningful if it meets the needs of the customer, thus it only widens the gap between top companies and the rest, assuming it does what it claims to do. Companies who already fail to deliver value will not find AI to be the savior they wish it to be.

    But if you’ve been tuning out the AI news because you see a valueless hype bubble, check again. The ground has shifted and these tools are more than chatbots now. It’s worth experimentation, even with valid skepticism.

    In the end, I believe AI will not be the differentiator of success, but merely the amplifier. It will eventually settle to become another tool in the toolbox, but the core fundamentals remain the same.

  • Being an Interviewer

    Recently, I’ve had the privilege (and sometimes burden) of conducting first-round interviews. After participating in quite a few, I thought I’d talk about my experience.

    Yes is the Default

    Interviews are a series of filters, with each a bit more granular than the last. The first round isn’t to determine if we should hire someone, it’s to filter out those who we clearly should not. Yes is my default answer, because I believe if we have to have a reason to be excited about a candidate, it significantly increases the likelihood of making a biased decision based on personal factors instead of objective ones. I have my own biases and a judgment call will undoubtedly be influenced by them, no matter how much I try to avoid it. Fortunately, relying purely on objective factors is not as difficult as it sounds, because most candidates who fail do so in ways that don’t require deliberation. The sole reason for almost every rejection is failing the code exercise.

    Programming is the Great Differentiator

    You might be shocked to find out that about 2/3 of candidates can’t complete a basic code exercise; I certainly was. We’re not asking candidates to balance a binary search tree here; we’re asking basic data structure problems about as difficult as FizzBuzz. The candidates we are interviewing all have senior titles and 8+ years of experience, yet a number of them have struggled to find the max value in an array, and one couldn’t even start because of the inability to use a for-loop. After seeing this, I requested we move the programming exercises to the start, because all else becomes irrelevant if they fail there. Moving them has helped us reject candidates earlier when it becomes clear they haven’t passed through our filter. All of our candidates had great looking resumes, fancy titles, and can easily recite their job history with a smile, but put them in front of an IDE and all pretense quickly falls away.

    I Don’t Want to Fail You

    Interviewing takes a lot of time out of my day, but it also takes far more energy than a regular meeting. I want that time and effort to be valuable to me as much as the candidate, so rejection feels like a waste to both sides. In a perfect world, I would say yes to every candidate and we could hire someone right away, because every day I have to spend doing more interviews is a day that takes my time, and especially my energy, away from other tasks. By being the first filter, outside of the recruiter screen, I am helping to save time for the rest of the team who will not have to do subsequent interviews. Our goal is to hire someone, not endlessly run interview loops, so the incentive for me to vote yes on a good candidate is there.

    We Can Move Fast

    The standard process to move a candidate to the next round is 3-5 business days, depending on the team’s schedule, but if we find a candidate we really love, we can and will shift whatever we need to for that person. We will move the entire team’s day around to make sure they can attend the interviews. We will move quickly and be highly communicative to make sure we don’t miss out on a great person when we like them enough. Moving at our normal pace does not mean we dislike a candidate, but simply being in the second round does not mean we will say yes; it simply means we have no reason to say no. We will not show our hand outright, but the speed at which we move can be an indirect indication of interest.

    Overall, I’ve enjoyed the opportunity to interview many candidates and improve my interviewing skills. I understand the privileged position it puts me in compared to our candidates and the power differential that can exist from it, so I aim to be sensitive to the challenges of those who are currently unemployed, even more so for those who have been laid off from Tebra. At the time of posting, my team is still hiring for a Senior Front End Engineer, for those who may wish to reach out.

  • Perception is Reality

    People make decisions on what they think is true, not on what actually is. We cannot make decisions with knowledge we don’t have and it’s not possible for anyone to know everything going on at all times. This might sound like an obvious observation, but in practice it can be easy to overlook and I’ve found it to be a useful framework to understand how decisions are made. Computers are unconcerned with what we think they should do, but when it comes to organizational decision making, reality is irrelevant; perception is reality.

    But why is this concept important? Because it can be the reason why what we expect to happen does not. When someone works hard for years, but never receives that promotion they’ve been after, they may be failing to build others’ perception of their work. Perception can decide who gets promoted, which projects get funding, or how bonuses are allocated, so there is a direct financial incentive and when times get difficult, as they are now, it can also be a determining factor for who gets laid off.

    When I first joined Tebra, at the time known as Kareo, my team was considered low performing. My focus has not only been on improving our software quality practices, but also to demonstrate the progress we’ve made to leadership and the organization at large. Since then, my manager, most of the team, and I have been promoted, and once we moved to work with a second team, replicated our results there as well. I certainly cannot take credit for all, or probably most of it, but the trust we’ve gained from the organization as a result of our growing reputation has paid great dividends.

    But rather than talk about the benefits of when perception is good, I think it’s more important to show the potential when it’s not, so here are a couple stories that taught me why perception matters.

    UNL TRIO Program

    One job I held during school was for TRIO, a federally funded program to assist underprivileged students. We were the department’s IT support. I was assigned to set up a help desk ticket system to better track our work. It was a larger project for our own use, so the other staff did not have much visibility into the work I was doing. One day, I happened to overhear a conversation between two of the senior staff members – “He’s clearly working on something. I see him working on his computer all the time, but I’m not actually sure what it is.”

    These kinds of questions sow the seeds of doubt that can grow into greater problems if left unchecked. If the value of my work is questioned, it could lead to debates on whether the position is worth having at all and defending the value of one’s job is not a good position to be in, particularly because you might not get the chance at all.

    So, I began to talk to the senior staff members about the project and how it could help us, which remediated their concerns and led to increased interest.

    But that one was pretty simple, so how about something with more drama.

    Sallie Mae

    Having been at Sallie Mae for three months, I was moved from the office in Boston to join a new team in Indianapolis. The developers were great, but the product owner was….not so much. I’ll call him Jeff, because he reminded me a lot of Jeff Bezos, who coincidentally ended up being my next employer.

    When I first met Jeff, it was clear that he was important. You could just tell by the way he walked and talked that he had the ear of important people and he was Not to Be Messed With, but I don’t kowtow to bullies and so it was inevitable that I ended up in my manager’s office having what would probably be one of the most important conversations of my career, which went something like this:

    Boss: “Hey, I heard there’s been some things going on. I’d like to hear from you. Can you tell me what’s been going on?”
    Me: *thinking for a second*
    Me: “So far everything’s been good. The team is getting me up to speed on the project and I’m settling in.”
    Boss: “Alright, sounds good. Don’t worry about anything then.”

    Jeff complained about me. And he did so not just once, but numerous times over the course of us working together, and not just to my manager, but to his manager too. My choice to ignore his complaints made it clear who the problem was and also made me realize that none of what I believed about him was true. His attempts failed because no one believed him. It’s not universal, but being nice and making friends usually results in far greater success than the contrary. Had I not made friends myself, it’s possible things could have gone very differently.

    Perception matters because information is limited and time is scarce, so important, career-altering decisions are sometimes made with the tiniest tidbit of information. So make sure it’s a good one.

  • Professionalism

    Back in January, I had a bicycle accident that shattered my left elbow, leaving me unable to ever fully extend it again. Part of my rehab required a brace to help my mobility. After being measured at the medical office, I was told it would take 2-3 weeks to get and that they would call me when it arrived. 6 weeks later and nothing. After calling in, I was told there were no updates and it took me walking into the clinic to finally discover they only just submitted the order that morning because they forgot about it until I called to ask where it was. Tim, the person who was in charge of my order, gave a sheepish sorry and said he would get it to me as soon as possible. Tim is not a professional.

    After filing a formal complaint, something I’ve never bothered to do before, I received a call from Cyrus who reviewed the paperwork, called their manufacturer on my behalf, and personally ensured I had it in my hands two days later. Cyrus is a professional.

    We are Tim. We may demand fancy titles, like Senior Software Engineer, and the money and respect to match, but shirk much of the responsibility that should come with it if we truly intend to be treated as actual professionals. We leave that to Cyrus. Professionalism doesn’t require fancy clothes, flashy titles, or a big office, nor is it incompatible with having nerdy hobbies and interests, but it is the set of standards, attitudes, and behaviors with which we work.

    Over the years, I’ve had a growing discontentment with the immaturity of many of my fellow engineers. One former coworker had to be told, at 30 years old, to do his chores by our older colleagues, because his coworker-roommates couldn’t resolve the issue at home and repeatedly brought it to the office. Others were fired for bullying an LGBT coworker because they failed to understand the toxic behaviors common online are not acceptable in the workplace. These may be more extreme examples, but they’re not complete outliers. I believe that we, collectively, have a lot of growing to do if we intend to be taken seriously as professionals.

    Here are a few concepts that I believe define a software professional.

    Know the Business & Know the Customer

    Understanding the industry your company is in and who their customers are is the foundation everything else is built on. This can be difficult when, if like me, you have worked for companies in wildly different industries, but it is no excuse. “We make ___ software for ___” is about all most of us know, which is inadequate. We need to know more.

    1. Who are the different types of users who use our software?
    2. What are the primary tasks each type of user wants to accomplish?
    3. What devices do they mostly use? What screen size?
    4. What difficulties do they have with our software?
    5. If they have a problem, what do they do?

    These are questions about the end-users of our product, but a team’s customers can also be internal. If your customers are other teams because, for example, you’re a platform team, then knowing how your product is used by those teams is important as well. But, anyone who works with a product for end-users should know the answer to these questions, even if their own work does not directly reach them.

    I think it’s unfortunate that there is often a large degree of separation between customers and engineers. It’s not scalable to allow completely open access, but the ability for customers to talk with the actual engineers would greatly help to understand those customers.

    Proactive Ownership

    Proactive ownership means taking an active role in improving our applications to fit customer needs. It means taking the time we need to do our work correctly, to our best ability, and spotting issues before they reach the customer. When we understand the business and the needs of our customers, whether they are end-users or other teams, we can better shape our applications to fit those needs and should do so without prompting.

    Proactive Ownership is the idea that we should actively seek solutions and understanding, that we should maintain and improve our applications, and that we should define and decide our process of doing work without waiting for managers or product owners to do so for us. “Here’s what I’m going to do,” over “what do you want me to do?”

    This can be a difficult shift in the way we work, because it’s dramatically different from the way we typically do things, but switching to this style empowers us to do better work, deliver high quality results to customers, and is the path to professionalism.

    Effective Communication

    English was always my best school subject, much to my chagrin. I never liked writing and always wished my best subject was something useful, like math, but over the years, I have come to enjoy it and realized that the ability to communicate effectively may be the most important skill of all.

    Most of us, frankly, cannot write. We fail to communicate effectively in any form, but writing is easier to criticize than someone’s social skills, so I choose to focus there. Our lack of communication skills alienates us from non-developers who do not think like we do, but it can be difficult to see when others have learned to simply work around our incapability and other developers communicate the same way.

    This is not something that can be fixed with a mentality shift, or working style, but is a skill gap, pure and simple and one I believe to be the most important in being a successful professional. If we were all 10% better at programming, nothing would change, but if we were all 10% better at communication, we could make an enormous impact.

    Write more.

    Conclusion

    A fancy office or title does not make one a professional, but it is the set of attitudes and behavior that defines professionalism. If we desire the respect and treatment that comes with being considered a professional, then we need to make substantial changes to the way we operate. Nerds can be professionals too, but only if we choose to be.

  • Delivering Value to Customers

    Something that has stood out to me in most of the organizations I’ve worked for is a high degree of inefficiency, both at a technical and process level. In my last post, I mentioned that, although I dislike bureaucracy, I’ve come to understand its necessity and the problems created by excessive avoidance of it. However, I am an optimizer by trade, and so when I see inefficiencies, I feel compelled to lessen or remove them. Much of my focus, and the topic of conversation I often bring up when talking to executives, revolves around speed of delivery. The natural follow-up question is: how do we achieve this? I typically provide answers that are specific to the organization’s problems, but now I’d like to outline my general philosophy behind it.

    Every company proclaims some variation of “we value our customers” and of course, they must. Customers are what an organization depends on to survive, so if I were to declare, “delivering value to customers is our number one priority” to company leadership, everyone would smile and nod along. If we weren’t doing so, our entire purpose as software developers would be rendered irrelevant. However, it’s important to consider what delivering value to customers truly means. Delivering value implies that a change was made to the application that either helps a customer solve a problem they couldn’t before, or it improves their ability to solve one they already are dealing with.

    The implication of this is that any change that does not provide value to the customer is waste. Therefore, we should optimize our ability to deliver maximum value to customers. It may seem like I’m stating the obvious – it might be comparable to saying that success in basketball involves scoring the most points, but it’s quite surprising to find that this core principle, whether in business or in sports, is often forgotten.

    What truly matters are the outcomes, not the output. Releasing many changes to customers does not necessarily mean that value has been added. Our industry may have moved on from horrendous measurements like lines of code produced, but as soon as the sole focus shifts to story points and JIRA tickets, we’re right back where we started.

    Nevertheless, our primary concern should be building the right thing rather than delivering it quickly.

    Our highest priority is to satisfy the customer through early and continuous delivery of valuable software

    – Agile Manifesto

    Neither I nor the Agile Manifesto discuss speed of delivery as a priority. This is not because speed of delivery doesn’t matter; it does, but focusing on it detracts from our primary goal of delivering value and shifts the emphasis towards merely delivering code. In other words, if we maximize our ability to deliver value, we get the speed for free.

    Developers will work as fast as they are able, as long as they are unconstrained. Therefore, I believe that the best approach for software development teams and organizations is to maximize their ability to deliver, while minimizing their constraints for doing so.

    Enter Lean

    These ideas have piqued my interest in exploring Lean and its origin, the Toyota Production System. For my next posts, I’m going to explore further, as I believe there is much to uncover there.

    Whether in business or basketball, success hinges on superior fundamentals. I believe that understanding these foundational elements is critical for the success of teams and organizations.

  • Learning the Value of Project Management

    I don’t like bureaucracy. I’ve typically considered it a hinderance to my work and so, over the years I’ve become quite adept at circumventing it – managing to fit in small requests outside of the process to get them resolved much more quickly. I’m not so crazy as to believe in having no process whatsoever, but I have, and continue to believe that minimizing the amount of process is necessary for speed of delivery. Up until recently, this viewpoint has worked well for me, but the limitations of this approach caused me to slam into a brick wall at full force, because what happens when there is no one to constrain me to a process? What happens when I am the bureaucracy?

    Over the past year, I’ve taken up leading a project from the ground up, starting from the basic concept and under the guidance of our technical leadership. We’ve spent the past year creating plans, deciding on a solution, and preparing ourselves for a full-scale rollout to the rest of the organization. The scope of this project includes all development teams and is on a much larger scale than I’ve worked in before, which has been exciting because it’s allowed me to be involved in spaces I have not been before and influence the direction of a project in a way I haven’t been able to before.

    Circumstances outside our control have caused a number of setbacks that have amounted to 6 months up to this point and my impatience to release grew as a result. And so, while my collaborator was on vacation, I decided that it was time to finally announce the project to the organization as a whole and begin the steps to roll it out. I recognized that it was not the ideal situation, but what I quickly learned was that the error was much more egregious. The reception I received was muted, as expected, but what I failed to understand was the firestorm I had created in the background. Despite holding myself out to answer questions and alleviate concerns, I was not included in these discussions by the managers. This is because I failed to understand how the organization operates.

    Understanding the communication pathways between teams is critical to the success of managers and senior technical leadership, but is otherwise kept out of sight for the rest of us, even if we attempt to poke our heads up to get a look. Having never encountered this space before, I think it is forgivable for my failure to understand this particular aspect, but something that is more important and less forgivable is my failure to value project management. When I sat down and reviewed the situation, the most stark difference existed between my and my collaborator’s understanding of where the progress of the project actually was.

    Since the start of the project, I had refrained from creating any tickets to track the work I was doing and instead relied on using sticky notes on my desktop. This system was one of the tricks I had to subvert having to create actual tickets while still ensuring nothing was lost – a shadow tracking system. It was a system that worked well for my day-to-day work which didn’t necessarily require in-depth tracking that might otherwise impact my team’s sprint, so it was useful, but where it fell apart was when I had to coordinate work with someone else. We managed to survive via weekly meetings that ensured any deviation was quickly corrected, but with him on vacation, this system broke down. Though the storm I had created was recoverable, it showed I still had much to learn. Had I followed proper procedures and created tickets to track and communicate the work, the situation could have been prevented completely.

    Going forward, I am searching for ways to merge my current philosophy of process minimalization with the need for project management, but I think I may be reaching a new horizon where these concepts are fundamentally incompatible, or at least at odds. The phrase, “what got you here won’t get you there” comes to mind and I look forward to uncovering a new paradigm.

  • Black Box Unit Testing – Making the Old New Again

    After my previous post, I began a journey to discover better ways of unit testing. I had come to the realization that I had been following the cargo cult and that we as an industry don’t seem to be very good when it comes to understanding and executing automated testing. Perhaps you would disagree, but never in my career so far have I experienced what I would consider a comprehensive automated test suite for any project I’ve yet been a part of, which is a shame because I think the value of automated testing is underrated.

    I am still well in the middle of my journey, but after searching for months, I finally stumbled on a path that has lead me to a better approach. The trigger for me was the book, Clean Craftmanship, which highlighted the solution to a number of questions I was unable to answer myself.

    A phrase I’ve begun to say with increasing frequency is, “do what adds value. Do what makes sense.” Value may be a nebulous concept that’s difficult to quantify, but most engineers can tell when they’re doing activities that don’t add value – following procedures because that’s the process rather than a clear, stated need for doing so. The default approach to testing is full of these valueless activities because we fail to understand how to write meaningful tests, so while nearly every engineer I’ve talked with understands the value of testing on paper, it’s little surprise when they abandon the act of actually writing them when they find themselves doing what seems, and is, not useful.

    Here’s what’s not useful:

    @Test
    public void testAdd() {
        assertTrue(5, add(2, 3));
    }
    
    public int add(int x, int y) {
        return x + y;
    }
    

    This is the typical, trivial example used to explain unit testing, but because it is so simplistic, it fails to be useful to anyone. So let’s create a better scenario; how do we test a multi-tier API that has a database?

    Let’s say we have a controller like this:

    public class DemoController {
        private final DemoService service;
    
        public DemoController(DemoService service) {
            this.service = service;
        }
    
        public Person getPerson(int id) {
             if(id < 1) {
                throw new IllegalArgumentException("IDs must be greater than 0.");
            }
    
            return service.getPersonById(id);
        }
    

    …that calls a service like this:

    public class DemoService {
        private final DemoDatabaseWrapper database;
    
        public DemoService(DemoDatabaseWrapper database) {
            this.database = database;
        }
    
        public Person getPersonById(int id) {
            return database.getPersonById(id);
        }
    

    …that calls a repository like this:

    public class DemoDatabase implements DemoDatabaseWrapper {
        private final NamedParameterJdbcTemplate template;
    
        public DemoDatabase(NamedParameterJdbcTemplate template) {
            this.template = template;
        }
    
        public Person getPersonById(int id) {
            String sql = "select * from person where Id = :id";
            MapSqlParameterSource map = new MapSqlParameterSource();
            map.addValue("id", id);
            return template.queryForObject(sql, map, BeanPropertyRowMapper.newInstance(Person.class));
        }
    

    There are a few guidelines we want to follow for testing these endpoints. I’ll summarize them here:

    1. Mock only in unit tests and only at the boundary layer. Overuse of mocks is bad, but not using them is also bad.
    2. Don’t mock what we don’t own. The behavior could change without us knowing and our tests could miss it.
    3. Test at the top level only. Do not isolate our code from itself.

    The first two are covered in plenty of articles, but the third is the most important and the concept I call Black Box Unit Testing.

    The Solution

    Black Box Unit Testing is my repackaging of the idea that test classes should not have a one-to-one relationship with the classes under test. We should look to test, exclusively, the behavior and not the implementation. The behavior is the foo in, bar out relationship; in other words, the black box.

    Tests in this style interact with the top level of the call stack and include all the concrete implementations of all layers, except for on the boundary with external dependencies, which are any services, databases, etc. that reside outside the project in question. These tests provide coverage for all levels of the application and still allow sending requests with any range of input we need to consider.

    The advantage of this approach is the ability to change the implementation without breaking the tests as long as the behavior is unchanged. Tests that do not follow this style with tightly constrain any changes and will likely be abandoned due to the tediousness of having to constantly fix them for even minor implementation changes. While it does guarantee useful tests, this approach makes it more difficult to write valueless ones.

    Let’s look at an example:

    class DemoApplicationTests {
    	private DemoController controller;
    	private AutoCloseable closeable;
    
    	@Mock
    	private DemoDatabaseWrapper database;
    
    	@BeforeEach
    	void setUp() {
    		closeable = MockitoAnnotations.openMocks(this);
    		controller = new DemoController(new DemoService(database));
    	}
    
    	@AfterEach
    	void tearDown() throws Exception {
    		closeable.close();
    	}
    
    	@Test
    	void negativePersonIdShouldThrowIllegalArgumentException() {
    		assertThrows(IllegalArgumentException.class, () -> controller.getPerson(-1));
    	}
    
    	@Test
    	void validPersonIsReturned() {
    		// Given
    		Person p = new Person();
    		p.setId(1);
    
    		given(database.getPersonById(anyInt())).willReturn(p);
    
    		// When
    		var person = controller.getPerson(1);
    
    		// Then
    		assertEquals(1, person.getId());
    	}
    }
    

    You may notice that this looks quite like what many people would call an integration test. Indeed, they are going to be similar in many cases using this approach, but with one critical difference – the integration tests use the real version of any external dependencies and will refrain from using any mocks.

    Black box unit tests do not preclude the use of integration tests, but in fact help to enable them. Partly due to their reliance on mocks, unit tests have notable weaknesses that make them insufficient if used as the exclusive testing method. Instead, they are a part of a greater testing infrastructure than includes integration, and likely even end-to-end tests as well. To see how integration tests might fit into this example, see the link to the code on GitHub down below.

    This style of testing isn’t new and I’m far from the first to suggest it, but it is a style that is not commonly known or used. There have been many iterations of the same attempts to teach the concept, but the style I first mentioned in the beginning of this post remains the prevailing one. I encourage you to try black box unit testing and that it can help you realize that writing automated tests is not only something you should do, but hopefully something you can actually enjoy doing.

    For more info, integration tests, and my detailed notes, the code is available on GitHub.