Vladimir Ozerov wrote:This is almost exactly what Embeddables are used for.
In an application object model some objects are considered independent, and others are considered dependent parts of other objects. In UML a relationship to a dependent object is consider an aggregate or composite association. In a relational database this kind of relationship could be modeled in two ways, the dependent object could have its own table, or its data could be embedded in the independent objects table.
In JPA a relationship where the target object's data is embedded in the source object's table is considered an embedded relationship, and the target object is considered an Embeddable object. Embeddable objects have different requirements and restrictions than Entity objects and are defined by the @Embeddable annotation or <embeddable> element.
Originally posted by Rahul Bhattacharjee:
To my best of knowledge it has got nothing to do with performance.
Just curious to know that what made you think that it has something to do with performance.
Originally posted by praveen balaji:
As I mentioned above, the question is about performance.
Just for the record, there are several stylistic reasons for and against the use of "guard code" (Case 1). However, I'm interested in the performance implications.
Originally posted by Rahul Bhattacharjee:
Would you like modify a function with 10 exits/returns ,
knowing the fact that there are no JUnits for unit testing that piece ?
Originally posted by Amit A. Patil:
Case 2 is always good from maintenance and support point.
When some other developer is looking at your code there makes it easier for hiom if there is a single return in the method
Originally posted by Rahul Bhattacharjee:
I will go with Case II.I always prefer single return point for methods.