cancel
Showing results for 
Search instead for 
Did you mean: 

Helper Class Hierarchy for WDA

IanStubbings
Active Participant
0 Kudos

Hi

I am working on a project that requires several WDA apps and therefore wish to house all common methods in one class. Each WDA has it's own assistance class and methods particular to that WDA but I wish to access common methods from a 'superclass' of these assistance classes.

My question is how to call the common methods.

Since my assistance class already has a superclass - cl_wd_assistance - I am currently creating an instance of my common methods class in the constructor of the assistance class. I am thinking I should be using an interface somehow but am unclear on the reason behind it.

Has anyone setup a hierarchy of classes to support a multi WDA project?

Cheers

Ian

Accepted Solutions (1)

Accepted Solutions (1)

alejandro_bindi
Active Contributor
0 Kudos

Haven't had this need myself but did you try to make the superclass (which has the common functionality) inherit from CL_WD_COMPONENT_ASSISTANCE, and then defining each subclass in the corresponding WDA? I don't know if WDA does some validation which forces any class defined as Assistance class to inherit directly from CL_WD_COMPONENT_ASSISTANCE (I'm not at the system now), but such a validation would make no sense...

What I mean is to:

1 - Create the superclass e.g. ZCL_SUPER from SE24 (if you didn't yet) and manually define CL_WD_COMPONENT_ASSISTANCE as its superclass.

2 - Create each subclass e.g. ZCL_SUBxx from SE24 (if you didn't yet) and manually define ZCL_SUPER as their superclass (instead of CL_WD_COMPONENT_ASSISTANCE).

3 - Manually define each ZCL_SUBxx class as the assistance class of each component (instead of creating the class while defining as SE80 allows).

So this would leave you with this hierarchy:


CL_WD_COMPONENT_ASSISTANCE
   \
    \
     ZCL_SUPER
       \
        \
         ZCL_SUB01
         ZCL_SUB02
         ...
         ZCL_SUBxx

Since all the ZCL_SUBxx classes would be still inheriting (indirectly) from CL_WD_COMPONENT_ASSISTANCE, they should be allowed to be defined as Assistance classes...let me know if this works.

Regards

Edited by: Alejandro Bindi on Jan 28, 2009 11:39 PM

I may add however, you should use inheritance when you can define (conceptually) that any subclass is a special type of the superclass...exceptions are less common.

IanStubbings
Active Participant
0 Kudos

Thanks Alejandro.

I hadn't considered the super->super approach. I will try it out and let you know how it works out.

Cheers

Ian

IanStubbings
Active Participant
0 Kudos

Works like a charm!

Many thanks.

Answers (0)