Code duplication squared

NetHack’s code quality isn’t of varying quality. Gradually one gets used to the different style of coding that pervades NetHack’s source code that is almost inevitable on code that has seen dozens of programmers over more than twenty years.

But sometimes, I still get surprised by the pearls of code that can be found in NetHack.

Here and here we see two parts of the code that are almost completely identical for about 100 lines.

What’s really funny about this is the comment in the middle of that code: “Okay, _you_ write this without repeating the code“.

Although that comment really is referring to the fact that this code – that deals with monsters resp. the player reading a scroll of earth – is made up of two quite similar parts, one for the player and for monsters.

~ by bhaak on 29. January 2010.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: