I am implementing a library that:
- Takes some input data (I put data structures and classes in the
parsing
package) - Stores the data in a structure (I put data structures and classes in the
storage
package) - Present the data in some meaningful way (
chart
package)
I divided my code this way because if I want to add another data representation (for example a table
package) I can reuse parsing
and storage
packages.
I am though worried about circular dependencies:
- My
Parser
should store input data in a dedicated data structure class,Record
, this means thatDataStorage
has to know how to get data from it and that Parser should know how data insertion is performed inDataStorage
class. - I am also concerned that the
chart
- and eventuallytable
as well - package should know a bit more about how to get data from myDataStorage
class.
Are my concerns valid? If yes, how could I solve the issue?
I was thinking to expose some Interfaces in a contracts
/interfaces
package in such a way that specific classes such as Record
and DataStorage
would implement them and there wouldn't be a circular dependency anymore.
Would this solution be considered a good practice or are there any better alternatives?