tocano@lemmy.todaytoProgramming@programming.dev•What should semantic diffs highlight: The change or its effect?English
4·
19 hours agoThe most obvious option: highlight what changed, the whole string. If you changed the string from interpolated to non-interpolated, the meaning of the whole string changed; it is no longer a method to concatenate variables, it has become a literal string.
Same for the example of single to double quotes. In some languages, double quotes are only used in specific contexts, so its use changes the meaning of the code. The post seems to dismiss this fact too easily.
Usually my models only store data, meaning the files that contain them don’t have much code. The decision also depends on the tools you are using and who you are working with. I would fallback to the rule of separation of responsabilities and write a new class for the purpuse of serializing the model (which could and should also serialize similiar models). This way is universal in any language and can easily be understood by future you and colleages.