Replies: 14 comments 12 replies
-
Jackson is definitely the defacto library for JSON generation. Obviously the main issue I see is the Mars sim is underpinned by an object graph with many references. I don't know how they would be represented in JSON; there would need to be some form of global unique identifier. |
Beta Was this translation helpful? Give feedback.
-
However Jackson can require the addition of Annotations to the classes plus I'm not sure how good it is at referencing. |
Beta Was this translation helpful? Give feedback.
-
We could first transition to GSON. But @Urwumpe would say that GSON use reflection and is slow. Q: If Java reflection is going to be phased out in near future since it's based on |
Beta Was this translation helpful? Give feedback.
-
I agree, there is a lot of spaghetti coding with classes knowing the internals on others. Probably should try and enforce some package only scoped classes to enforce separation.Also I have noticed logic in base classes specialised for the subclasses. This is never good for maintenance.
|
Beta Was this translation helpful? Give feedback.
-
Yes. Sorry about the spaghetti codes as I was focused only on adding features without considering the best architecture that should have been deployed :D Do by all means refactor how it should be done in such a way that bring stability to the simulation. |
Beta Was this translation helpful? Give feedback.
-
What about approaching this as a Technical Debt project? Start capturing areas of improvements to reduce cohesion and increase separation as Improvement Issues as they are discovered. Each one could outline a proposed solution open for discussion. |
Beta Was this translation helpful? Give feedback.
-
I think the best approach is to create a new Project within the repo and create cards with potential changes/improvements/reworks. |
Beta Was this translation helpful? Give feedback.
-
We tried setting up projects in the past. It's just the mechanism doesn't seem to be as intuitive as we want and not having a nice UI with color template like other project management tools out there. But do by all means utilizing it to see how we may make the best use of that. |
Beta Was this translation helpful? Give feedback.
-
If we adopt Java 16, we could quickly switch to using Record for storing days for Java serialization. Minimal changes are needed. See https://inside.java/2021/03/12/simpler-serilization-with-records/ |
Beta Was this translation helpful? Give feedback.
-
How do you like adopting the use of microstream in mars-sim, a well developed, reliable java persistence framework out there ? See [intro](See https://www.infoq.com/news/2021/09/microstream-5-is-open-source/ They just made it open source and besides Java, they have an android version as well. I was told that it's quite lightweight. So we can use it to replace our heavy duty Inventory class. In future, we may use it for saving the physical health and the accomplishment of a person, as well building/vehicle maintenance history. There's also a module for writing the serialized data into a JSON format if needed. |
Beta Was this translation helpful? Give feedback.
-
I think its a bad idea to include a new framework now. It will break a lot, for minimal gains. Maybe it makes sense to test in a branch, how many changes are coming there, but I would recommend to first write a lot of unit tests for the Inventory class to ensure that the new framework underneath does not break the top-level stuff. Such tests are never a bad idea anyway and if the new framework turns out to improve things a lot, we can migrate easier to it without having to fear many bugs. |
Beta Was this translation helpful? Give feedback.
-
Microstreams are interesting but they are still a binary storage format like Serialization. If we are to move away from Serialization (I would like to) it needs to provide some benefit. The benefit I feel would be a non-binary format to allow tweaking. JSON would give us that BUT JSON does not support object graphs; and we have a complex object graph.
We probably need a separate Discussion on the future the the Inventory class. This undoubtedly would need a gradual transition and not a big bang; probably a set of Issues with a Project to cover them. |
Beta Was this translation helpful? Give feedback.
-
@mokun I saw last night a few imports for microstream creep into the code base. I think this work should be done on a dedicated branch to avoid breaking the master branch as I don't think it will be a quick piece of work. |
Beta Was this translation helpful? Give feedback.
-
Another library that we may use is Chronicle-Wire. Some said it can be a drop-in replacement of Java serialization. Don't know how easy it is for us to use it. See
It's capable of using various formats such as binary, yaml, json, etc for serialization |
Beta Was this translation helpful? Give feedback.
-
Currently we are using Java serialization for saving and loading the simulation session.
If we switch to JSON serialization, it will give us developers more debugging insights.
See this for one of the earliest discussion on using JSON for serialization.
@bevans2000, do you favor using Jackson for this ?
Beta Was this translation helpful? Give feedback.
All reactions