Originally posted by Kimber Frye:
So, if only 2 of the item subclasses use the attribute a, it would still be okay to put it in the parent item class. This attribute would be unused in the third class.
Thanks
Usually when something lie this happens, the code is telling you that your inheritance relationships aren't quite right. You might consider introducing an "AItem" which extends Item, and is in turn extended by xitem and yitem. AItem would have an "a" attribute. zitem would extend Item directly, and zitem would have the "b" attribute. Now no classes have "extra" attributes.
An alternative is to make Item an interface rather than an abstract class, and have xitem, yitem, and zitem all implement that interface, and include only the attributes they need. You could still use the AItem class in this case, just as an implementation convenience.