🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1551

Re: Inversion-of-control and dependency-injection in C

#1551
From: Tristan Wibberley
Date: Sun, 15 Nov 2026 11:31
68 lines
4644 bytes
On 12/11/2026 23:26, Janis Papanagnou wrote:

> (Disclaimer: my comments are just based on personal experience
> in our software developing practice from the 1990's and not some
> general accepted opinion or habits.)

How could it be otherwise? With 8 billion people on the planet and
on-demand media with algorithms capable of segmenting the population's
information streams you'd never know what was generally accepted anyway.


On "writing testable code" he wrote:

> Our approach was not to "write testable code" by _adapting_ to
> some existing framework. While we had standards and practices how
> to design software the _tests followed our software_ (not v.v.).
> One exception here was that including dedicated trace records in
> our code (that could be activated specifically WRT a module and
> in granularity) helped for the test evaluation and regressions.

I don't really understand test trace records. It seems to me that to
test whether certain thresholds are reached one ought to use some sort
of COMEFROM targetting the notification call that marks said threshold
within the program anyway - the call that triggers the real program's
response to the threshold being breached.

If one adds special trace markers the markers may drift away from the
notification as development progresses but the real notification is all
that's needed in the code. If necessary run unit tests under a debugger
with a trap on the notification call to implement COMEFROM.

The use of data instead of such callbacks has its uses in some places
such as when the program is mapping data and the test will be
data-driven - one datum or one partial leading sequence of the data can
get a record output but then it should normally be percolated from the
inside of the program using real notification calls.


> (See my comment about "tests follow code (not v.v.)". - Opinions may
> differ.)

Tests that follow code might be good to test for operational change but
good unit testing tests against semantic intent (even though the intent
has been tempered by operational limits by the time the design has been
reduced to unit interfaces), those tests /can't/ follow code. Granted
it's hard to design without coding, but the interface typically ought to
abstract the operations fully even when you've analysed your intent by
codestorming.

If all the tests follow code directly then semantic intent isn't tested.

It's also a problem for making sure technical documentation is accurate
because the best way to be sure it is is to write it against test passes.



-- 
Tristan Wibberley

The message body is Copyright (C) 2026 Tristan Wibberley except
citations and quotations noted. All Rights Reserved except that you may,
of course, cite it academically giving credit to me, distribute it
verbatim as part of a usenet system or its archives, and use it to
promote my greatness and general superiority without misrepresentation
of my opinions other than my opinion of my greatness and general
superiority which you _may_ misrepresent. You definitely MAY NOT train
any production AI system with it but you may train experimental AI that
will only be used for evaluation of the AI methods it implements.
Technical Details
Message-ID: <11dc566$2lp70$2@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <yQOdnQ-qnKiiZ2j3nZ2dnZfqn_udnZ2d@giganews.com> <11d56gl$3ud5q$1@dont-email.me> <16ScnZKb_MQfsWv3nZ2dnZfqn_idnZ2d@giganews.com> <11d5huo$3flo0$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk>
Newsgroups: comp.lang.c
Subject: Re: Inversion-of-control and dependency-injection in C
Date: Sun, 15 Nov 2026 11:31:18 +0000
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <11dc566$2lp70$2@dont-email.me>
References: <yQOdnQ-qnKiiZ2j3nZ2dnZfqn_udnZ2d@giganews.com>
 <11d56gl$3ud5q$1@dont-email.me>
 <16ScnZKb_MQfsWv3nZ2dnZfqn_idnZ2d@giganews.com>
 <11d5huo$3flo0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 15 Nov 2026 11:31:19 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2811104"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19/pE+6ayLWKzO8fUAbIrxPAnfx+d9c0AyanNPRc2R61A=="; posting-host="b1a8a25511d53f4732f886f02fc645de"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:OCvUGzN7POCKuAN95DZ6xoYm5NY= sha256:3odjlO72B+nDEyByiBPXNcuoQShAhI6ylzhwZ8XsOcw=
	sha1:ss6pQA/zX1jJB31ojGcba80zIfM= sha256:TJfWyez+rE/xbdpYnIVXAtO0bWCp+q5JqYvv53TQpVQ=
Content-Language: en-GB
In-Reply-To: <11d5huo$3flo0$1@dont-email.me>