17
How do you structure your models save/load code?
(lemmy.pe1uca.dev)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
mainly java dev here:
if i only have few classes i want to serialize/deserilize i implement the logic for that in the class, if they need special logic for that, and implement the serilizable interface. writing objects to somewhere or reading them from somewhere belongs in a different class.
if i have a lot of classes or use a framework like spring i'll employ whatever they offer for serilization and deserilization or more likely a databinding library like jackson.
other languages with classes or structs offer simmiliar options(pythons pickling and unpickling or the json package in their standardlib for example) so my approach would stay mostly the same.