in reply to Creating a Moose object and serializing it
I definitely think you are over-engineering this problem. I would consider an "if" in offset much simpler compared to the conceptual complexity of your coderef solution - much less thought necessary when reading your code. The coderef solution introduces the serialization problem. And additionally, you have replaced your "if" statement with a method call (_offset_sub), so you have made performance worse!
I can't see an advantage to the coderef solution (in this case).
To your real question: If the code differences between the circular and non-circular case were extensive, I might consider distinct classes (MyObj::Circular and MyObj::NonCircular with a common base class and where MyObj delegates/re-blesses to the apropriate subclass).
Good Day,
Dean
|
|---|