For a design patterns class, the instructor asked my team to develop an application that supports drawing and persisting glyphs, very similar to the WYSIWYG editor from GoF.
My team decided to use a Layered architecture, with descending layers: Presentation, Controller, Logic, Persistence.
The Logic maintains a collection of glyph representations, their respective positions, and some shape-unique properties. The instructor suggested we use the Builder pattern to create uniform persistence mechanism, as CSV and XML are required persistence formats.
The problem comes about when we attempt to design the Builder within the Persistence layer. Because we're using Layers, the Persistence layer is not permitted to know about Glyph types explicitly, let alone cast them from their abstract form to their individual shapes. This has me scratching my head as for what to even pass each Builder as its constructor.
The next problem is that its hard to generalize the types that the Builder takes. Rectangles have properties that Lines don't.
I'm having a lot of trouble grasping how to do this. I understand the Builder pattern, but something just isn't clicking. Am I misusing the pattern, or am I not fitting it to the problem correctly?
Edit: The instructor didn't say we have to load the persisted formats back in. My ending solution should obviously make this easy, but for my current problem, I'm only focused on saving.