Is a circular dependency a code smell? (language agnostic)

844 views Asked by At

Let's say for example that I'm making a tile map editor.

We have the editor, which handles the drawing of the tiles, and we have the tileset which is used to determine what tiles are drawn.

The editor needs to depend on the tileset to know which tiles should be draw, and the tileset needs to depend on the editor to know the dimensions of the tiles to be drawn, as well as other minor details.

This creates tightly coupled code. Is this a code smell? If so, how do I resolve it?

Do I stuff everything into a large class? Do I use a mediator to communicate between the two classes?

1

There are 1 answers

0
Rick O'Shea On

Write your tile-set first complete with tests, then move on to the editor. In so doing you will have solved your problem without even considering it.