Dan's crazy ideas #3 - Working with legacy code

Continuing from Dan’s crazy ideas #1 and Dan’s crazy ideas #2

Okay. This idea is CRAZY! As in, box? What box? That kind of crazy. You ready for it? Here goes:

Create a category of puzzle where the goal is to debug and fix someone else’s broken code.

Umm… Hello? This is Codin-GAME, as in fun! What’s so fun about debugging someone else’s mess?

Yeah, I know. Just give me a minute to explain. I think the idea has some merit.

Concept

Unless you live in a bubble, or you plan to become a full-time code competition participant, you will need to work with code written by other people… a lot! Puzzles geared around detangling unfamiliar syntax usage, paradigms, and algorithms can provide practice in this invaluable skill.

In addition, I can attest that I frequently pick up new techniques from looking at code written by others.

Proposal

To force the thou shalt fix the code, and avoid the I’m just going to rewrite this mess, I propose a new form of IDE / puzzle in which the majority of the code is read-only, and only a small subset of the program (1 - 10 lines?) is editable. The user is free to add / modify code in that window, and possibly another editable section elsewhere to enable addition of functions and classes.

This format could have many uses. Here are just a few:

  • Teaching: Illustrate a particular algorithm or technique.
  • Entertainment: Create some particularly clever, or stupid, or obscure, etc. code.
  • Competition: I think this would work particularly well in Clash of Code.

Clash of Code

I’d like to elaborate on this one a bit. One of the common problems with CoC is that the pool of puzzles is too small, and some of the better competitors have them mostly memorized (or worse, somehow automated).

If this form of puzzle were to be implemented as a CoC, then it would provide literally hundreds of puzzles. Pretty much every non-functional puzzle submission could be a candidate for a future debug puzzle. You could even automate the process by looking for sequential submissions where only a small change in the code causes a failing puzzle to pass.

A major drawback to this idea is that all competitors would need to compete in the same language, so that the competition is fair. They would probably need to agree on a language ahead of time. One proposal for how to do this is for each user to select a list of languages in which they are willing to compete, and then the server could select a puzzle from the intersection of competitors’ language selections.


Sooo… How crazy is it? Let me know what you think.

  • danBhentschel
5 Likes

That could be funny.

Instead of making the code read only, one could also make it an optimisation puzzle, the goal being to obtain code as close to the original as possible.

1 Like

We had a similar idea in the French chat.
You are given a code that nearly solves one of the community puzzles you already solved (if you already solved at least fifty of them).
The code is a bit wrong (for example, a variable is not declared, an operation is false…) and is obfuscated (lots of useless comments, variables with strange names, useless instructions…)
You have five minutes to correct the error and find the only puzzle solved by the code with only one try.

1 Like

I personally love the idea.

Some could argue that irl when you deal with legacy code, you can debug it. Here you have to print an error. That could remove a bit of fun.

1 Like

I like that idea. Much better than my proposal.

  • danBhentschel

Great idea, I already do that at work :wink:

Guess I am here to have fun and learn new techniques and algorithms, but in general i like it.

How would you port the same legacy flaws to different programming languages?

Anyhow, with some suggestions from this guide to write unmaintainable code it will be a real pleasure to see people despair finding a solution :smiley:

2 Likes