Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Classes and Subclasses or alternative.

Hi all,

I have the following 'issue': I want to create / update / retrieve BP relationships. My idea is to create a superclass with all general data for a relationship like Partner 1 & 2, type of relationship (employer-employee, husband-wife etc.). So far so good, but now it comes. All relationships have different attributes (created in CRM with Easy Enhancement Workbench, comparable to customer includes).

Does it make sense to create a subclass per relationship type, because based on that different logic has to be processed. Or put all these attributes, whether they belong to relationship type A, or B, in the same superclass?

Normally I would say the second option is better / more logical and put them all in ONE (super)class, but since every relationship is a specialization of the superclass due to all the different attributes, it would also make sense to create a new subclass for every relationship type. I actually want to avoid, using IF statement within the class (IF relationship A, ELSEIF relationship B, etc.), because when creating a new relationship type, I would have to change the superclass over and over again.




If you've general methods, then subclassing.

There is a school of thought, however, that all public methods should be implementations of an interface - this is known as coding to an interface. It can, give more flexibility, at the expense of greater complexity.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question