Quote:
You're not coupling nHibernate to your domain objects by using Mapping.Attributes. The Mapping.Attributes are metadata and it's not even in the NHibernate assembly.
Xml is just a trick around the same problem, except that it's not refactorable or typesafe (the trade-off)
I'm using NH1.2, and the only documentation I'm finding on mapping attributes as metadata is via the add-in "NHibernate.Mapping.Attributes". Unless I'm misunderstanding and there is some way to decorate the classes without introducing this assembly, it's not something we're interested in doing.
While I understand that this isn't the NHibernate assembly itself, for all intents and purposes, it could just as well be. Decorating the domain objects with attributes from this assembly tightly couples it to a very NHibernate-specific implementation and breaks cohesion. Should I want to move to some other ORM strategy, I'd want to and have to remove all of the attributes before I could even de-reference the mapping assembly. As long as they're mapped as metadata, I'd have to always deploy this assembly with my domain layer. Even if I'm doing something that doesn't require persistence, such as unit testing. In fact, I wager the reason this is a separate assembly to begin with is to minimize the number of nHibernate-centric dependency demands on your domain objects if one were to decide to go this route.
But to be clear, we're not following the "Active Record" pattern here, which is what that attribute tool is for. I'm getting the impression from your (miopic) insight that you've never developed an architecture outside of that methodology. And if that truly is the case, you're really in no position to criticize our standards as you've obviously never been in situation where it's been important for the persistence layer to remain agile. I realize the "Active Record" pattern is a good pattern for most applications. But then, most applications have a solid investment and commitment to the type of persistence they're going to leverage. This application is not one of them.
We have looked at and continue to look at other ORM, and object-relational database solutions. So, our persistence layer is a moving target. There has even been a lot of talk of different versions of the software that would be identical except for the persistence.
To be fair, your points about type safety and refactoring are valid. Those aren't really huge issues for us because we use code generation to help in maintaining the code integrity. If that wasn't the case, I can definitely see where the benefits you describe lie.
Your "suggestion" is noted, however. Should things stabilize and there's been a settlement on NHibernate, it becomes a much more comfortable and pragmatic move, even if it does break some principles of agile design and bleeds persistence-specific implementations where it technically doesn't belong.
Quote:
An interesting double-standard! No dependencies on ORM's but a dependency on a 3rd party code generator! Our standards are the opposite - no 3rd party code generators.
I didn't say it was 3rd party, but I see how you might have interpretted it that way, so I apologize for not being clear enough.
Proprietary = we own it. Or rather, we coded all of the code generation scripts in-house.
Even if we didn't own it, code-smith is a multi-purpose scripting engine, so editing a 3rd party script wouldn't be difficult or out of the question.
From your statement, I'm not sure you understand what a dependency is. We (and arguably anyone else using a code generator) are not dependent on code generation. If we felt we had a lot of time on our hands and we were craving some really mind-numbing work, we could hand code all of our classes, interfaces, hbm and table-creation files.
We opt to leverage code generation to save time, enforce consistency and eliminate human error.
The reason I mentioned it at all was because there was a question about why the cascading flag was set up the way it was. Since it was generated that way, I had no real good answer as to why that decision was made (that part of generation was written before I inherited that responsibility). Marcel's comment was helpful, and I've since tweaked the code generator to not do that anymore.