4 ms·
A major problem with doing data transformation in statically typed languages is that its easy to introduce issues during serialization and deserialization. If y
by topkai22 3y ago
A major problem with doing data transformation in statically typed languages is that its easy to introduce issues during serialization and deserialization. If you have an object
[{
name:”ex obj”
value:”a sample value”
extraProperty:”I’m important”
}]
And the code
class myDTO{
string name;
string value;
}
var myObjs= DerserializeFromFile<myDTO>(filepath)
SerializeToFile(myObjs, filePath2)
filepath2 would end up with without the extraProperty field.
You can also write code like
function PrintFullname(person) {
WriteLine(person.FirstName + “ “ + person.LastName)
}
And it will just work so long as the object has those properties. In a statically typed language, you’d have to have a version for each object type or be sure to have a thoughtful common interface between them, which is hard.
All that bring said, I generally prefer type safe static languages because that type system has saved my bacon on numerous occasions (it’s great at telling me I just changed something I use elsewhere).
- epgui 3y agoI think whether your comment is essentially true or not depends on the language and technology.
- somenameforme 3y ago"Most" (I mean "all", but meh - I'm sure there's some obscure exception somewhere) parsers will have the ability to swap between a strict DTO interpretation of some data, and the raw underlying data which is generally going to be something like a map of maps that resolves to strings at the leaf nodes. Both have their uses. The same can also be done easily enough by hand as well, if necessary.
- pharmakom 3y agoNo, it's not. You can write code in a statically typed language that treats the data as strings. The domain modelling is optional, just choose the level of detail that you need: 1. String 2. JSON 3. MyDTO If you do choose 3, then you can avoid serde errors using property based testing
- FrustratedMonky 3y agoEven with a Dynamic Type, it becomes real static type at some point when running, so why wait for the crash to happen at runtime?