[ovirt-devel] Implementing equals & hashCode methods

Yevgeny Zaspitsky yzaspits at redhat.com
Sun May 25 12:33:31 UTC 2014


Hi All, 

Recently I reviewed a patch that adds a new business entity to the engine. 
The entity class has the following members: 

    * id 
    * data center id 
    * name 
    * type 
    * some other properties that do not belong to the entity key 

The equals & hashCode methods were implemented in a way that include all members. 
I asked the patch author to change that, so it'll include only business key (data center id, name and type), which define the entity uniqueness. 
Also I found that many other business entities are implemented in a similar way (include all class members in equals & hashCode). 

I'm a new to oVirt, so I'd like to ask your opinion on the issue. 


    1. Do you agree with my approach on equals & hashCode. 
    2. If you agree with my approach in general, should we implement it in the new introduced code or should we adhere to the old convention even we do not agree with it? 
    3. Should we re-factor the old code (it might be dangerous as we do have enough unit test coverage)? 

Thanks in advance, 
Yevgeny 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/devel/attachments/20140525/e74c2427/attachment-0001.html>


More information about the Devel mailing list