I have a few classes that I have to refactor and my particular concern is that they are marked as
Serializable. I know with 100% certainty that these classes are parsed out into a file and read back in later.
I am wondering what are some things I should be making sure I consider as I make changes?
If I remember correctly, when using the
Serializable attribute on a class, only the fields are parsed (I can't remember if access level matters). But what does this mean for auto-generated properties?
From my understanding the compiler creates an underlying field for you to ease the development process so wouldn't this mean that in modern code properties are in fact being parsed?
Also, if my memory serves correct, the fields behind auto-generated properties get some pretty weird names. Do these change with each build, or do they remain consistent unless you change the name of the property?
A few of these classes have fields which could be combined into more complex types. For example:
public float mouseX; public float mouseY; public float positionX; public float positionY; public float positionZ;
These can be simplified to
VectorN types such as:
public Vector2 mousePosition; public Vector3 position;
Since this is a really big difference between old and new versions, and it is way more than just a name change; what are some things I should really consider prior to making this change?
Moving Fields to new Classes
I do have a particular case where a class contains multiple functionalities that can be broken out into individual classes for better readability, reusability, and maintainability. If this step is taken, it is definitely a big change from the old version and I'm sure it can cause even bigger problems. What are things to consider with this type of change?
There are several classes that implement
ISerializable which should make everything a little easier to transition.
All in all, what are some other things that most do not think about on the first run until it all blows up?