3 ms·
I'm totally not following here... How can multiple insert statements be considered duplication if they are inserting different things to different tables? My
by ora600 16y ago
I'm totally not following here...
How can multiple insert statements be considered duplication if they are inserting different things to different tables?
My apps have multiple insert statements. They also have multiple calls to "print". Do you count that as a duplication as well?
We can continue the discussion by email if you prefer. It is interesting to me, but we may be getting off topic.
- gnaritas 16y ago> How can multiple insert statements be considered duplication if they are inserting different things to different tables? Because they're all the same pattern of code. Whenever you see common patterns, you're missing an abstraction that can greatly simplify things. Why would I write 100 different insert functions when I can write one that generates itself dynamically using reflection over whatever object it is given? You only need one insert statement, it just needs to be smarter rather than static hand written code. You need only tag your objects with a little bit of metadata using attributes to give a generic insert/update/select/delete everything it needs to dynamically generate parameterized statements on the fly for every table in the db that you use. Put simply, the only thing I need to do to use a User table in an app is write something like the the following... class User : ActiveRecord<User> { [PersistentString(MaxLength=50, Required=true)] public string UserName; [PersistentString(MaxLength=50, Required=true)] public string Password; [PersistentString(MaxLength=5000)] public string About; public User(){} } And I'm done, I can now Find, FindAll, Save, Delete, Count, Sum, Min, Max, Avg, Count, Exists, Not Exists, etc... on those records without writing a line of SQL. All of these methods are inherited from the superclass and work on the table User. The same thing applies to view and stored procedures.