IRelationPredicateBucket clarification

Posts   
 
    
spodgod
User
Posts: 14
Joined: 20-Sep-2007
# Posted on: 19-Oct-2007 16:55:18   

Hi - I wonder if anyone can clarify the difference between the IRelationPredicateBucket and RelationPredicateBucket objects? I was assuming that IRelationPredicateBucket was an interface class and so not meant to be directly instantiated, but many generated methods return an IRelationPredicateBucket directly (e.g. ENTITY1.GetRelationInfoENTITY2(); )

Can I use IRelationPredicateBucket objects instead of RelationPredicateBucket objects, and if not, can I just cast returned IRelationPredicateBucket objects directly to RelationPredicateBucket objects? Some general guidelines on this would be gratefully received ...

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Oct-2007 17:11:26   

Hi - I wonder if anyone can clarify the difference between the IRelationPredicateBucket and RelationPredicateBucket objects? I was assuming that IRelationPredicateBucket was an interface class and so not meant to be directly instantiated,

Exactly.

but many generated methods return an IRelationPredicateBucket directly (e.g. ENTITY1.GetRelationInfoENTITY2(); )

No, I think they return an object that implements that interface, or you can say of IRelationPredicateBucket type, but actually the object is instanciated from the class not the interface.

IRelationPredicateBucket myObject = new RelationaPredicateBuckrt();

Can I use IRelationPredicateBucket objects instead of RelationPredicateBucket objects, and if not, can I just cast returned IRelationPredicateBucket objects directly to RelationPredicateBucket objects?

You can use the interface to define return types or parameters. But Actually you should return an instance of a class that implements that interface.

In general stick with the class, if you don't have another class inheriting from the interface.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 21-Oct-2007 11:28:45   

We used interfaces for most classes, to be able to implement other classes with the same interface later on without having to change code internally. You can use both, it's up to you. instantiating an interface isn't possible, so you have to instantiate the class simple_smile but it's up to you what you want to use: interface or class, as the class implements the interface.

Frans Bouma | Lead developer LLBLGen Pro
spodgod
User
Posts: 14
Joined: 20-Sep-2007
# Posted on: 21-Oct-2007 13:23:03   

That clears things up. Thanks, as ever, for your speedy response simple_smile