r/ExperiencedDevs • CTO @ Pylon • Jun 22 '24

Stories of "Intellectual Control" of code vs. "Statistical Control"?

I recently ran across this blog post:

https://www.georgefairbanks.com/ieee-software-v37-n3-may-2020-testing-numbs-us-to-our-loss-of-intellectual-control

The author defines intellectual control as having a model of the code in your head that's simpler than the code itself.

Statistical Control, on the other hand, is where you believe the code to be correct because the tests on the code are passing, but you don't actually understand the code itself.

Personally, I can remember numerous times where I refactored large swaths of code, maintaining confidence I hadn't broken existing behavior because the tests and types were passing, but I didn't actually have a compact mental model of the system as a whole. If someone had asked me to redesign the system I was refactoring, I wouldn't be able to do it since I didn't really understand it.

Also, this kind of underlies bus factors etc, where a person leaves the company and you have software systems that you now only have statistical control over, but not intellectual control any more. Often having to painfully regain intellectual control.

I'm curious to hear stories of teams that ran heavy on statistical control (maybe a catchall team that inherited orphan systems). Or maybe stories where you saw intellectual control slipping away and how it went.

50 Upvotes

14 comments sorted by

39

u/ashultz Staff Eng / 25 YOE Jun 22 '24

Complicated frameworks as are currently popular generally push you to statistical control rather than intellectual control. I've worked with a very low framework codebase where we understood all of it and could change it with confidence (we also wrote tests of course).

And I've come in to big spring/node/etc codebases where the existing devs basically treated it as witchcraft. In the spring case to the point of not understanding basic operations of the system. The framework let them create without actually knowing anything.

15

u/WiseHalmon Product Manager, MechE, Dev 10+ YoE Jun 22 '24

This has been the interesting thing to see for me with new devs that are thrown into large frameworks. They've only ever known the "do quick stuff" frameworks and then they get into the large frameworks that do everything for them and then when they either need to make something new or debug something in the middle or what would be a startup thing they have huge issues

12

u/koreth Sr. SWE | 30+ YoE Jun 22 '24

I have seen this too and it is baffling to me. To take Spring as an example because it’s the one I work with every day: Sure, the Spring ecosystem is huge and I don’t understand every nook and cranny. But a decent dev can read the code and understand how the core features work in the space of a few days, and that time is paid back in spades afterwards in the form of not having to bumble around with trial and error.

“Huh, I wonder how that works inside” was one of my reactions when I saw Spring for the first time, but most other devs I’ve worked with over the years seem to be content to treat it as a temperamental black box that is just going to require hours of fiddling around from time to time until they stumble on the right magic incantation. It is like pulling teeth to even get them to read the documentation, let alone any of the freely-available source code.

A little curiosity often pays massive dividends but I’m not sure how to instill that in people.

8

u/SituationSoap Jun 23 '24

I honestly continue to be shocked by the number of engineers I encounter who exhibit absolutely no critical thinking or curiosity about their job. Like, ever. I don't know how you get into this line of work without one or the other of those things.

1

u/Adept_Carpet Jun 23 '24

If your livelihood depends on a framework you might as well take a peek at the code, right?

It will always change how you code. You'll see which features are really robust, which calls are surprisingly expensive, useful but poorly documented parameters, etc.

Also the style and patterns used to create the framework are often some of the most effective for writing code on top of the framework and if you implement your libraries in a similar style they can feel like native components and reduce cognitive overhead for users of the library.

15

u/annoying_cyclist principal SWE, >15YoE Jun 22 '24

I agree with the author that both of these are important and on a well-functioning project the team has both. They're complementary concepts, addressing related but different concerns.

To me, intellectual control is table stakes for working effectively as an engineer or an engineering team, at least if you're above mid level. Much of what I think of as engineering is difficult or impossible if you don't have a good mental model of the system. Statistical control techniques are a force multiplier for intellectual control: automatically checking nitpicky implications of the mental model, speeding up QA processes, reducing defect rates, and lowering the bar somewhat for new teammates (you don't need to index as heavily on skill, judgement, and knowledge if you're not totally relying on engineers for the things statistical control gives you). I've seen successful teams that rely almost exclusively on intellectual control for the things statistical control can provide (I probably wouldn't voluntarily work on one at this point, they can be really stressful). I've never seen a successful team that relied almost exclusively on statistical control and didn't have at least a couple people with a decent mental model of the system they're working on.

10

u/oxleyca Principal Software Engineer Jun 22 '24

I don’t think these things are correlated. I’ve seen teams have poor mental model for systems they own (typically built by others who left) and terrible tests, and tests with good mental models.

Having a solid mental model doesn’t eliminate edge cases. You can have the best idea for programs flow and still find valuable bugs with a fuzzer or input enumeration.

That being said, it’s still a good exercise to think on what systems your team shares a good mental of and which ones lack.

1

u/PPatBoyd Jun 23 '24

A few other comments have reflected similar that the ideas aren't directly tied, and I think you're right that they aren't specifically correlated. My thinking is if framed as independent measures of engineering health, they can trade off of each other in practice with limited resources for addressing issues tracking the shifting needs of the business.

As measures of engineering health, intellectual control could be thought of as answering "how well do we understand our components to work well together in provable patterns?" More complexity in a system makes that harder to answer and simpler systems would push more complicated logic downstream, but the question isn't about trading off complexity to capability -- the question is about how well the engineers understand the systems, which changes over time with both the systems evolving and the teams changing.

Statistical control as a measure of health is the quantitative response to "How well are our systems running over time?" Test coverage, crash rates, test failures, test flakiness, bug rates, developer velocity, customer sentiment and usage data, etc on; data points in time and their rate of change. Low statistical control is flying blind.

Ideally we want both, but they're constantly in flux and maintaining each has costs that differ across problem spaces. Engineers will feel the pain of limited intellectual control or statistical control differently; limited intellectual control leads to FUD over legacy code or moving to a new language or framework, and the pain of limited statistical control will affect the rhythm of business and slow down the development cycle. The individual data streams of soft concrete individual problems that we need to make collective engineering and business decisions on; technical debt isn't solved, it's managed. Testing is the natural overlap when talking about these issues as a means for proving intellectual control and improving statistical control. A system with high intellectual control likely needs fewer tests to prove itself (e.g. with fewer correct ways to solve a given problem) and a system with low intellectual control relies on throwing more tests at the problem to improve statistical control.

If I were to categorize development with different levels of each I'd probably say:

  • Low intellectual and low statistical control is chaotic development -- this is a bad place to spend much time and will lead to burnout and attrition
  • High intellectual control and low statistical control is vibes-based development -- we can't prove we're heading in the right direction and our overall success is reliant on our beliefs being accurate
  • low intellectual control and high statistical control is data-driven development without a long-term vision -- the code factory realized
  • high intellectual control and high statistical control is the sustainable dream -- we can work quickly and respond effectively because we know how our systems work, how we want them to evolve, and we're alerted to issues quickly

3

u/ravixp Jun 23 '24

This is a great framework for thinking about this, and something that I plan to share with my team. One thing that I wish it addressed more is how intellectual and statistical control evolve with a team.

Intellectual control is necessary if you want to make changes to a system. A good test suite will help confirm that you didn’t change anything that you didn’t mean to change, but it won’t tell you whether a new feature works correctly, you have to write new tests for that.

Statistical control is a lot easier to scale, and a lot easier to measure, compared to intellectual control. You can tell everybody to run tests with every change, and you can measure your code coverage objectively, but it’s much harder to measure whether new engineers understand the design philosophy of the system.

Statistical control is also a lot easier to keep, because your test suite is a technical artifact, while your intellectual control of a system lives in people’s heads. Lose the wrong engineer and you can lose intellectual control over part of your system, and worse, you may not realize it until you actually need to update that part.

7

u/AncientPlatypus Jun 22 '24

It seems to me the author is conflating 2 very different things. There is absolutely no relationship between more tests and worse code.

In my experience teams without enough diligence to keep a good test suite are the same teams that write complex and brittle code.

If a team is having issues with bad code that’s a process problem in the code review, and having less testing would just let people be confidently wrong

6

u/[deleted] Jun 22 '24

An experienced developer should have a mental model of the system.

2

u/jakeStacktrace Jun 22 '24

For me, I have to know if the tests are actually ensuring my change is safe, because of their quality and they test the kinds of things that might break. At that level, I have a mental model of what the code is doing, or I wouldn't know enough about the tests to trust them. There is different levels too like performance and UAT, not just unit functionality to consider.

1

u/idontliketosay Jun 23 '24

If I understand, intellectual control is like Unix, or windows. I have a simplistic understanding of how that code works and I am able to run my code on the OS. As for statical control, tests, I find this works well for checking code is still compatible with the data, less so when I am adding a new feature.

0

u/wwww4all Jun 22 '24

It's called black box testing.

It's been a thing for decades.