Make the Maze Self-Contained
Maze Self-Contained. To make your
Maze class more self-contained, you may augment it with
.dump() methods that will delegate processing to their respective counterparts in the
serializer module. However, doing so without any modifications would inevitably lead to the dreaded circular dependency, which Python doesn’t allow.
The most elegant solution is to break the two-way dependency in one direction. Since you want to call the serializing code from within your class, removing all
Maze class references from the
serializer module is the only option.
Notice that you renamed the function to convey its purpose more accurately by emphasizing its new interface. This change must also cascade down to the
serialize() function, while
decompress() remain intact.
With this update,
serialize() have compatible function signatures once more. You’ll modify your deserializing code in a similar way by getting rid of the dependency on
Maze from both
Become a Member to join the conversation.