Hi !
I'm planning to add MDX support to my newborn lib and I would like to define a Chunk class that avoids code redundancy. My goal is abstraction and ease of use&reading, not performances (but when there is no big trade-off they are of course always welcome).
The Chunk must be able to parse any number of primitives or Marshalable objects. Marshalable is an interface with 2 read&write methods, I took it from Dr Super Good's WC3Utilities.
My implementation seems to work, but it looks a bit verbose and not very elegant. Any ideas to improve it ?
Chunk class :
https://github.com/Koward/jM2lib/blob/master/src/jm2lib/blizzard/common/types/Chunk.java
Example with MDX Version chunk :
https://github.com/Koward/jM2lib/blob/master/src/jm2lib/blizzard/wc3/mdx/VersionChunk.java
Here's another example using a nested class to define chunk's content :
Note : this one is a WoW chunk but the principle is the same
https://github.com/Koward/jM2lib/blob/master/src/jm2lib/blizzard/wow/legion/AFID.java
EDIT : I changed my classes a lot since I created this post and I don't think it's that verbose anymore, but help would always be good.
I'm planning to add MDX support to my newborn lib and I would like to define a Chunk class that avoids code redundancy. My goal is abstraction and ease of use&reading, not performances (but when there is no big trade-off they are of course always welcome).
The Chunk must be able to parse any number of primitives or Marshalable objects. Marshalable is an interface with 2 read&write methods, I took it from Dr Super Good's WC3Utilities.
My implementation seems to work, but it looks a bit verbose and not very elegant. Any ideas to improve it ?
Chunk class :
https://github.com/Koward/jM2lib/blob/master/src/jm2lib/blizzard/common/types/Chunk.java
Example with MDX Version chunk :
https://github.com/Koward/jM2lib/blob/master/src/jm2lib/blizzard/wc3/mdx/VersionChunk.java
Here's another example using a nested class to define chunk's content :
Note : this one is a WoW chunk but the principle is the same
https://github.com/Koward/jM2lib/blob/master/src/jm2lib/blizzard/wow/legion/AFID.java
EDIT : I changed my classes a lot since I created this post and I don't think it's that verbose anymore, but help would always be good.
Last edited: