Tuesday, 4 August 2026

Revisiting Refactoring -> Purpose - "Confidence in Code"

Martin Fowler's book "Refactoring - Improving the Design of Existing Code" (with contributions by Kent Beck), first published in 1999, is really interesting and deserves a revisit in the context of AI.

On the cover of the Addison-Wesley Second Edition, he is quoted as saying: 

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand".

Erich Gamma (one of the "Gang of Four" behind Design Patterns) remarks in the preface that refactoring began in "Smalltalk circles" and found its way into other programming language camps. 

He also emphasises its core role in framework development. 

"Frameworkers know that a framework won't be right the first time around—it must evolve
as they gain experience...The key to keeping code readable and modifiable is refactoring—for frameworks, in particular, but also for software in general." - Erich Gamma

Erich expands on the risk of refactoring - the fact it can set you back days or weeks and "refactoring becomes riskier when practiced informally or ad hoc".

Erich emphasises that a system is needed for successful refactoring: "To avoid digging your own grave, refactoring must be done systematically".

He mentions the core of the book is a "comprehensive catalog of refactorings".

He also relates a coding session with Kent Beck involving disciplined "one step at a time" refactoring and how we felt afterwards - 

"Not only did my confidence in the resulting code increase, I also felt less stressed."

Sunday, 2 August 2026

A Note on LSTM

LSTM, or long short term memory, seemingly paradoxically named, was co-invented by German computer scientist Sepp Hochreiter, who incubated it in his 1991 diploma thesis leading to its main publication in 1997. 

LSTM addresses the problem of numerical instability in training recurrent neural networks (RNNs) that prevent them from learning long sequences (the so-called vanishing gradient problem).

In 2007, he and others applied LSTM, optimizing the architecture, to very fast protein homology detection without requiring sequence alignment.

Protein homology detection is the process of identifying whether two proteins share a common evolutionary origin - one of the core problems in computational biology.  

Homology implies shared structure and shared function.


Saturday, 1 August 2026

Agentic Coding, IDE Debugging

You've built your software agentically. Now you want to (need to) debug it in an IDE.

You may need to add some extra settings.

OpenAI's Astra Solves More Maths Problems

Astra has solved 10 hard maths problems (published 1 August 2026) following on from its disproof of the Erdös unit distance conjecture (from combinatorial geometry) in May 2026.

A paper of almost 250 pages (inclusive of references) is available from OpenAI's website.

Defensive Perl

Perl is less fashionable than Python these days, but it is a very flexible language which excels in text processing.

Its flexibility allows a myriad of programming styles, however, so having a set of defensive techniques helps.

Here are some top tips:
  • Switch warnings on - use the minus-w command line flag -  #! perl -w
  • Learn and use perlpod - it looks a bit like this at the start of your file  =head1 NAME  myscript =cut
  • Always use strict; at the start of your program (this pragma restricts expressions that are hard to debug)
  • Qualify your variables with type prefixes (similar to "Hungarian" notation) e.g. my $sHeader for strings, my @aCodes for arrays, my %hCodesToDescriptors, and appropriate equivalents for common custom types
Recap on pragmas: A pragma is a module which influences some aspect of the compile time or run time behaviour of Perl, such as strict or warnings. From Perl 5.10 onward - custom pragmata are supported.

Happy Perling!

How Imports Work in Python

The syntax for import is as follows (keywords in quotes):

"import"  module [ "as" identifier ]

There is also a variation to use when testing proposed changes to Python:

"from " "__future__" "import" feature [ "as" identifier ]

The first thing import does is find an load the module. It then initialises the module.



Frozen Frames when Debugging Python

When running pdb, you will notice certain debugging frames as frozen.  This is typically when:
  • code is compiled C-extension code (e.g. importlib, asyncio, threading internals)
  • the debugger cannot step in or modify them
  • they are part of Python's frozen importlib bootstrap
For example, in the following:

<frozen importlib._bootstrap>
<frozen importlib._bootstrap_external>

The modules are embedded in the Python binary.

If you try ll in the Python debugger when compiled code is being processed, you will get the error: *** could not get source code.