trickster321
Programmer
Hi all,
I'm trying to write some code to compare two complex objects, by which I mean objects that contain other objects that contain other objects and so on (I guess that makes them composite objects). I need to know what differences there are either in the properties of each object or in the child objects and the child object properties.
For example, I have a Product object that has a property of users that is a collection of user objects, now each user has a property of addresses which is a collection of address objects and so on. Is there a design pattern that can be applied to compare two product objects?
I work in .NET and C# so was thinking whether I can apply reflectance to analyse my object properties first and then use that information somehow in the comparison.
Any advice gratefully received as at the moment I'm having to iterate over the object tree on both objects comparing each property as I go. This seems to be a lot of hard work for something that feels like it should be a relatively straight forward object comaprison.
Rick Edwards
I'm trying to write some code to compare two complex objects, by which I mean objects that contain other objects that contain other objects and so on (I guess that makes them composite objects). I need to know what differences there are either in the properties of each object or in the child objects and the child object properties.
For example, I have a Product object that has a property of users that is a collection of user objects, now each user has a property of addresses which is a collection of address objects and so on. Is there a design pattern that can be applied to compare two product objects?
I work in .NET and C# so was thinking whether I can apply reflectance to analyse my object properties first and then use that information somehow in the comparison.
Any advice gratefully received as at the moment I'm having to iterate over the object tree on both objects comparing each property as I go. This seems to be a lot of hard work for something that feels like it should be a relatively straight forward object comaprison.
Rick Edwards