Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Billy McCafferty



S#arp Architecture upgraded to ASP.NET MVC Preview 3

S#arp Architecture has been upgraded for compatibility with ASP.NET MVC Preview 3 and Spring.NET 1.1.2..  A big thanks goes out to Adam Cooper and Frank Laub for assisting with this effort.  S#arp Architecture, an architectural framework for developing applications with ASP.NET MVC, Spring.NET and NHibernate, may be found at http://www.codeplex.com/SharpArchitecture.

Billy McCafferty



Comments

alexandr said:

int  x1,x2;

int z1,z2;

x1/z1=x2/z2;

cout<<"1"<<endl;

cout<"0"<<endl;

# June 10, 2008 8:51 AM

Steve Gentile said:

Thanks for the update Billy

# June 10, 2008 7:10 PM

Luis Abreu said:

Hello again Billy.

I've got one more question regarding your implementation of the Equals method in the PersistentObjectWithTypeId. In the current release, you have something like this:

public override sealed bool Equals(object obj) {

           PersistentObjectWithTypedId<IdT> compareTo = obj as PersistentObjectWithTypedId<IdT>;

           return (compareTo != null) &&

                  (HasSameNonDefaultIdAs(compareTo) ||

               // Since the IDs aren't the same, either of them must be transient to

               // compare business value signatures

                   (((IsTransient()) || compareTo.IsTransient()) &&

                    HasSameBusinessSignatureAs(compareTo)));

       }

I'm having some problems on agreeing with this part:

(((IsTransient()) || compareTo.IsTransient())

You'll end up comparing business IDs if any of the objects is transient. Is this really a good idea when you think about NHibernate? Here's a quick example. Suppose you've got  a service that contains a list of items you're going to save to the db. The service has a method that receives objects and adds them to an internal list untill a specific time, and then it will simply call SaveOrUpdate over all those items. It's not really a reallistic example, but lets assume that it will only save the items on the list from30 to 30 seconds.

Now lets also assume that the service ends up receiving two objects of the same type, A and B. A is transient; B is not. BOth have the same business signature (this is not something that happens often, but I've seen in the past).  

Lets also say that adding an item to the "saving list" is only possible if the item isn't there already (and this is done by calling the equals method over each element on the list).

When the service receives A (the transient object) we add it to the list since there isn't any item with the same siganture there. After receiving B (non transient, ie, it has already been persisted on the db), we call Equals over all other elements to see if there's any item on the list. With the previous implementation of equals, we'll get true so this means that B won't be added to the list.

Now, if when I save all the items on the DB i call the SaveOrUpdate method, I'll end up duplicating elements, each one with a different ID.

What I'm saying is that the business comparison should only be allowed if both objects are transient.

What do you think?

# June 13, 2008 7:36 AM

The ASP.NET MVC Information Portal said:

Pingback from  The ASP.NET MVC Information Portal

# June 18, 2008 3:38 PM

Mike said:

Hello Billy,

I'm using the S#arp Architecture for an inhouse system at work and It's working out great!

Will the current version work with preview 4 as is? or do you have an update in the works?

Thanks!

Mike

# July 23, 2008 10:21 AM

Billy McCafferty said:

I'll likely be publishing an update later this evening, thanks for the interest.

Billy

# July 27, 2008 3:13 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!

Our Sponsors

Proudly Partnered With