logoalt Hacker News

drfloyd51today at 1:33 AM2 repliesview on HN

Discover the laws in a current code base?

They are usually in the “tests” folder.

So anything capable of extracting unit tests is extracting “laws”.

One might consider the test name the text of a law. And the AI fills in the details.


Replies

actionfromafartoday at 9:04 AM

From the codebases I have seen the "laws" are scattered between unit tests and lots of little tests and assertions in the actual code, plus cultural norms and "do it like this" patterns.

But a good start could be found in the unit tests.

skissanetoday at 2:07 AM

I don’t think that’s right.

Unit tests check whether a specific code module is implemented correctly given its (implicit) specification.

Good “laws” are independent of the structure of the code.

Tests may be a useful source for inferring what the laws are, but much of the actual content of the tests aren’t “laws” at all.

show 1 reply