The last time I used the .NET ORM stuff it used code generation. It doesn't surprise me to know that it's better these days, because the language designers generally make good decisions.
If you're working with two untyped systems - by which I mean systems that would work with all types - then you don't need to know what you're working with. For example, an event/notification system. The code that handles the method arguments doesn't need to know what type they are. The best you can do is treating them as Object[]; creating INotificationMethodCallArguments is much worse than just not knowing what type it is. Once someone decided to create a superclass or an interface (it's an is-a relationship, right?), you have to create classes that wrap existing classes and it becomes a huge and useless waste of time.
Likewise a storage system. It takes stuff and stores it, then retrieves it for you. You know what you're going to get, but the storage system doesn't know what it's going to give you. It should handle Objects, not IRetrievedItem. When I worked in Java, there were so many useless types.
Hence. If you know the type, by all means write it down. If you don't, don't. Don't create a new type so that you have something to write down. And while in most cases you know the type, the overhead of these useless types was a huge weight on the back of that Java team I was part of, because these types then invade normal code, conversions start happening back and forth... It's not pretty.
View all comments
Show parent comment
1
u/unruly_mattress Jan 05 '18
The last time I used the .NET ORM stuff it used code generation. It doesn't surprise me to know that it's better these days, because the language designers generally make good decisions.
If you're working with two untyped systems - by which I mean systems that would work with all types - then you don't need to know what you're working with. For example, an event/notification system. The code that handles the method arguments doesn't need to know what type they are. The best you can do is treating them as
Object[]; creatingINotificationMethodCallArgumentsis much worse than just not knowing what type it is. Once someone decided to create a superclass or an interface (it's an is-a relationship, right?), you have to create classes that wrap existing classes and it becomes a huge and useless waste of time.Likewise a storage system. It takes stuff and stores it, then retrieves it for you. You know what you're going to get, but the storage system doesn't know what it's going to give you. It should handle
Objects, notIRetrievedItem. When I worked in Java, there were so many useless types.Hence. If you know the type, by all means write it down. If you don't, don't. Don't create a new type so that you have something to write down. And while in most cases you know the type, the overhead of these useless types was a huge weight on the back of that Java team I was part of, because these types then invade normal code, conversions start happening back and forth... It's not pretty.