DEV Community

Cover image for The Spanish Empire of Abstraction strikes back 🇪🇸
Ignicion
Ignicion

Posted on Edited on

The Spanish Empire of Abstraction strikes back 🇪🇸

Halò a charaid! 😄

The Spanish did NOT go home. We stayed, refactored the whole thing, and now the French border patrol is asking us for immigration advice.

Turns out this puzzle isn't about Java or C++ or even Py/TS. It's about one simple abstraction:

interface Shape {
  color: string;
  canMove(direction: Direction, board: Board): boolean;
  blocks(other: Shape): boolean;
  interactsWith(other: Shape): Interaction;
}

class UShape implements Shape {
  constructor(public color: string) {}
  // ... you know the rest
}

class Puzzle {
  private shapes: Shape[] = [];

  addShape(shape: Shape) {
    this.shapes.push(shape); // ← arbitrary, baby
  }
}
Enter fullscreen mode Exit fullscreen mode

The French claimed "even a configurable in-memory list can't work". But that's because they were thinking in if (color === "black") blocks instead of polymorphism.

The cyclomatic complexity doesn't grow with the number of shapes. It stays at O(1) when you invert the dependency correctly.

TL;DR: List<Shape> exists. The Spanish Empire of Abstraction stands undefeated. 🇪🇸

Thanks for the fun puzzle — this is exactly the kind of thinking that separates "it works" from "it scales". Also, your Scottish Gaelic intro made my week. Tapadh leibh!

Nos vemos en el siguiente reto 🧩

Top comments (14)

 
francistrdev profile image
FrancisTRᴅᴇᴠ •

Hey. The post they deleted is most likely on their own accord. When post being deleted by moderation, it will not show that message that the comment is deleted. It will simply deleted out of existence (meaning you will never see it and there is no history to it).

I appreciate you pointing things out since it's been difficult for me to moderate on my own. I would be careful not to assume things on dev.to based on it's current status because it may turn out what you may not think nor it is not as bad as you think. It is open source after all, so you are welcome to see the codebase. Thanks!

Collapse
 
yosoyignicion profile image
Ignicion •

Yes, you can rest assured, thanks for your concern, mate.
😁
Thanks also to the moderators for moderating, the clarifiers for clarifying, and the programmers for programming. A message of peace: I was cooking when my comment was moderated.
🫡
No big deal, I understand it wasn't very informative and the automatic filters went off.
🤣
And I'm completely new here; I'm not interested in what happened in the past.
🤩
Sometimes only the present and the future you want to achieve matter. I appreciate the interaction; I'll get back to cooking in a little while better content.
🤗

Some comments may only be visible to logged-in visitors. Sign in to view all comments.