3 ms·
Generics can apply to classes, not just methods, as you can see in the typed lists included in the framework, you can use generic methods without them taking ge
by gnaritas 10y ago
Generics can apply to classes, not just methods, as you can see in the typed lists included in the framework, you can use generic methods without them taking generic params as you can get the generic param from the class itself resulting in vastly cleaner use of generics akin to the built in typed lists.
Look at a typed list, that's the "clean" way to use generics, note it looks nothing like your ORM's interface.
> In your Example `Dog` ends up being a .NET 1.0-style non-serializable bloated Active Record
Incorrect, active records are perfectly serializable, not the least bit bloated, and I'm not "forced" to do anything, I'm using the interface I prefer having worked with every pattern under the sun for nearly two decades including repositories and POCO's. You aren't showing me anything I don't know, I understand deeply what your lib does and why it works the way it works: I'm disagreeing because I disagree, not because I don't understand something.
> It's also not clear what DB connection is being used, what its life-cycle is and whether it's being reused across different types, how you can create transactions spanning multiple types, etc -
Of course it's not clear to you how everything else works when we've only seen a single select example, you're making all kinds of assumptions here without cause. None of those things are clear in yours either from the select example shown here. It's only clear when you go read your full page of examples; as I haven't given a full page of examples, this critique is just silly.
> in Micro ORM's its clear, you use the same db connection to query any Type.
Active record is a micro ORM as well, and I understand all of those semantics about my ORM just as you do about yours. Perhaps you should refresh yourself on what a micro ORM is.
> There's a reason why most modern Micro ORM's are mapping to clean disconnected POCO's and don't force unnecessary wrappers for legacy inhibitive abstractions like this.
Yes there is, preference of the ORM writers, nothing more. Your preference for POCO's is nor more or less good than someone else's preference for active records; I've written code in every ORM style and I'll take a good old active record pattern over a repository pattern every time because at the end of the day, it's just more pragmatic and allows me to get more work done in less time while writing better looking code.
Both patterns are valid patterns, your dismissal of non repository patterns is sophomoric. I've been there, I used to think repositories were so vastly superior, then I grew up and had to hire and train other people and found the ability to get others to understand what's going on overrides my obsession with OO perfections. Active records are practical, they're why Ruby on Rails got so huge so fast. Ignore this pattern at your own peril.
- mythz 10y agoYou're going to seriously try serialize active records? Are you going to ship them to your clients as well to deseiralize? coupled with all their server data logic implementations? Active Records aren't DTO's and this doesn't work in the real-world, you can of course try to force it, but then you'll just be fighting fires trying to workaround new runtime serialization and implementation coupling problems. > Of course it's not clear to you how everything else works when we've only seen a single select example It's not clear because it's hidden behind your active record wrapper so the call-site doesn't know anything about it or provide any way they can change it. > None of those things are clear in yours either from the select example shown here. It's absolutely clear since `db` is just the open ADO.NET DB Connection which the query is obviously using. Users don't need to know anything more about the Micro ORM to use transactions as it just works naturally with ADO.NET DB Transactions. > Yes there is, preference of the ORM writers, nothing more. It's the preference of devs with experience writing ORM's as to what provides the optimal, intuitive API with the least friction, max productivity and reuse. You can of course stick to creating a new ORM based on a custom Active Record pattern which you'll end up maintaining forever and no-one else will have experience using or want to use. So any of your code-bases using it will be stuck using a bespoke legacy DAL that will be unmaintained the second you stop maintaining it and move on to NIH'ing something else. > Active records are practical, they're why Ruby on Rails got so huge so fast. Ignore this pattern at your own peril. They're ignored in .NET because they provide no added value over what's already available, there's no peril to be avoided, they're worse in every way and have zero chance of returning with any meaningful impact in .NET.
- gnaritas 10y agoYou've succeeded in convincing me you that you have limited experience and an inability to see that the real world is much messier than your ideals. Do please stop trying to speak for .Net as if you represent the entire community, you don't, and you're just embarrassing yourself. In the real world, the corporate world, you'll find tons and tons of custom active record implementations because they always provide something external mapping libraries don't, context aware simplicity. So go pick up a Martin Fowler book on patterns and read what someone who actually knows what they're talking about says about it since you seem to think you've got it all figured out, it's obviously pointless trying to have a discussion with you.