Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need help with design with classes, etc...

aris_hidalgo
Contributor
0 Likes
308

Hello Experts,

I am currently doing a report which gets data from several tables then processing it and showing it

via ALV. Now, I am kinda confused as to how to declare the classes meaning do I group

all the fetching of data to 1 class(e.g. method 1 to get data from MARA, method 2 to get data from marc, etc)

then create 1 class to process/combine the data and another class to display the data via ALV?

for example:

class data_definition abstract contains all the general data declarations

class get_data contains methods for fetching data and inherits data_definition class.

class process_data contains methods for combining and manipulation of data and inherits get_data class

class display_data contains all the SALV classes and inherits data_definition class

Please recommend a better option for my design.

Thank you guys and take care!

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
273

Hi,

I think it really depends on approach you choose. You can leave the design as it is, or group it all in one class. As long as you are working on same data, it must be visible in all classes (which you achieved by defining data_definition class). Alternatively to this you could create an interface and each class could implement it, this way global data would stay visible in all classes. Only interface components addressing would change a litte bit. As for fetching and processing data you can write separate methods for it, get_ , set_ respectively. Anyhow, I think important is to have clear understanding what your class is responsible for, so that logically data contained in it create some encapsulated entity.

Please also note that good practise for classes comunication would be using events instead of explicit call of public methods. You can consider that too. Also try to think the way as you would be comming back to this programm after a while. Is it clear for me enough? Do I understand exact purpose of each class, their methods? Do I have any data which are defined twice or three times (reduntant data)?

I think such questions will lead you to the answer: "Yes my approach is the best one I chose", or, "I have to think about better OO desing before starting my coding".

All in all it turns out that some things have to be changed during coding and sometimes it requires a small backward rebuilts.

Regards

Marcin

Hello Experts,

I am currently doing a report which gets data from several tables then processing it and showing it

via ALV. Now, I am kinda confused as to how to declare the classes meaning do I group

all the fetching of data to 1 class(e.g. method 1 to get data from MARA, method 2 to get data from marc, etc)

then create 1 class to process/combine the data and another class to display the data via ALV?

for example:

class data_definition abstract contains all the general data declarations

class get_data contains methods for fetching data and inherits data_definition class.

class process_data contains methods for combining and manipulation of data and inherits get_data class

class display_data contains all the SALV classes and inherits data_definition class

Please recommend a better option for my design.

Thank you guys and take care!

1 REPLY 1
Read only

MarcinPciak
Active Contributor
0 Likes
274

Hi,

I think it really depends on approach you choose. You can leave the design as it is, or group it all in one class. As long as you are working on same data, it must be visible in all classes (which you achieved by defining data_definition class). Alternatively to this you could create an interface and each class could implement it, this way global data would stay visible in all classes. Only interface components addressing would change a litte bit. As for fetching and processing data you can write separate methods for it, get_ , set_ respectively. Anyhow, I think important is to have clear understanding what your class is responsible for, so that logically data contained in it create some encapsulated entity.

Please also note that good practise for classes comunication would be using events instead of explicit call of public methods. You can consider that too. Also try to think the way as you would be comming back to this programm after a while. Is it clear for me enough? Do I understand exact purpose of each class, their methods? Do I have any data which are defined twice or three times (reduntant data)?

I think such questions will lead you to the answer: "Yes my approach is the best one I chose", or, "I have to think about better OO desing before starting my coding".

All in all it turns out that some things have to be changed during coding and sometimes it requires a small backward rebuilts.

Regards

Marcin