Thank you.
What factors determine an objects performance?
That's not necessarily true. I wouldn't think of it as instantiating 3 different objects. Instead, look at it as aMatryoshka doll (aka Russian nesting doll). The only performance (or other) degradation you'll see will be what the parent objects had. For instance, instantiating A, B, and C as separate objects (assuming they weren't inherited from one another) would be worse than instantiating C alone, with inheritance.
I don't know if I explained that very well, but in the end, there won't be a whole lot of difference. I just wanted to clear up how you should consider inheritance and its affect to the system. Additionally, you may notice a performance hit depending on how classes are defined and/or objects are accessed. For instance, I believe explicit interface definitions have a minor performance hit (not that this affects your scenario). Also, if you have to do any casting, that will definitely be a performance hit, so try to avoid that when possible.
flanakin:
That's not necessarily true. I wouldn't think of it as instantiating 3 different objects. Instead, look at it as aMatryoshka doll (aka Russian nesting doll). The only performance (or other) degradation you'll see will be what the parent objects had. For instance, instantiating A, B, and C as separate objects (assuming they weren't inherited from one another) would be worse than instantiating C alone, with inheritance.
I don't know if I explained that very well, but in the end, there won't be a whole lot of difference. I just wanted to clear up how you should consider inheritance and its affect to the system. Additionally, you may notice a performance hit depending on how classes are defined and/or objects are accessed. For instance, I believe explicit interface definitions have a minor performance hit (not that this affects your scenario). Also, if you have to do any casting, that will definitely be a performance hit, so try to avoid that when possible.
Thanks for your help Michael.
I dont quiet understand what you mean by "explicit interface definitions", could you explain?
The way i have used Object A is:
ObjectA o = new ObjectA();
o.ObjectAAttribute = value1;
o.ObjectAAnotherAttribute = value5;
o.ObjectBAttribute = value2;
o.ObjectCAttribute = (int)value3;
Anexplicit inheritance implementation is done within the class definition. Some people make it a point to always do this, but I've heard it has a slight performance hit. Note that I haven't verified this, tho, so it may not be true. Based on your scenario, this isn't even a problem because you're not dealing with interfaces.
From what you've described, the only performance issue you really need to worry about is the overhead that each parent object provides. If they aren'ttrue parent objects (when looking at it from an OO purist standpoint), they should'nt be parent objects. What I mean by this is, if A is a cat, B is a dog, and C is a fish, don't inherit helper properties and methods they all may coincidentally use. Pull those out into separate classes. I don't know if this applies to you, tho, so you're probably fine.
Thanks for your help. The objects I believe are true parent objects.
Object A: Persons Details
Object B: Persons Answers to questions
Object C: Persons Status details
No helper properties or methods are being inherited only attributes.
Thanks.
0 comments:
Post a Comment