Unit of work suggestion..

Posts   
 
    
Posts: 1268
Joined: 10-Mar-2006
# Posted on: 03-Aug-2006 23:44:40   

In using selfservicing, there are many methods which take a transaction parameter.

If they are not inside another transaction, you can pass null.

So, when I went to use a Unit of Work, I got to the Commit() function, which takes a transaction object. I passed it null. I of course got some wild and crazy null reference exception deep in the code.

I am suggesting: 1) The UOW object check the parameter for null and throw a meaningful exception. or 2) The UOW object contain an overload of commit that takes NO parameters.

I am guessing due to other issues, you would selection option 1. Anyway, might save some questions/problems in the future. (Also, if you choose 1, you could put additional text in the parameter description that pops up in VS)

Just a thought!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 04-Aug-2006 08:44:43   

The UoW needs a transaction to do its job so you have to pass one. Of course I can check for null, but that won't help you anyway: you then will get another kind of exception, but the results are the same.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 1268
Joined: 10-Mar-2006
# Posted on: 04-Aug-2006 13:40:00   

Yeah, just thought the 'hint docs' could help show that and a more helpful exception would be nice.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 04-Aug-2006 14:29:05   

A general question: if you see a method and all overloads accept a parameter Foo, and the reference manual doesn't say you can pass null for Foo, do you then simply try to pass null, or not? simple_smile I never pass null to a method if it's not allowed by the docs. A signal that null isnt allowed is when the parameter is in every overload of a method. (there are a lot of methods in the framework, and not always check for all kinds of input values which might make it go wrong, only when the caller could intentionally pass null because it would otherwise complicate the usage of the method. )

Frans Bouma | Lead developer LLBLGen Pro
Posts: 1268
Joined: 10-Mar-2006
# Posted on: 04-Aug-2006 22:35:35   

A general question: if you see a method and all overloads accept a parameter Foo, and the reference manual doesn't say you can pass null for Foo, do you then simply try to pass null, or not?

The question is this - if you are using a framework/generated code - and LOTS of methods take a parameter called Foo of Type FooType - and nearly ALL, if not all those methods the Foo parameter is optional - then when you see it on a method - I do think - optional!

I am cool with whatever you want to do - as I love the product. Just thought it would be an easy 'hint change' and parameter check!

Thanks for your replies.