Application Development 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: 

Think of Object...

Former Member
0 Kudos

Hi all,

I am still new in object oriented programming. Recently, I am working a Barcode Labeling program.

Could anyone here advice me how should I design this in OOP way.

I understand that I need to think and list down all the objects. But I just confusing what kind of object should I apply here.

Printer? Barcode? Scanner? Classification?

Kindly show me some example. Thanks.

4 REPLIES 4

Former Member
0 Kudos

Hi myahsam,

The only advice i can give you here is any entity which has attributes and can perform some actions can be treated as object.

So if the barcode has some attributes it can be an object. also if this object requires to perform some actions there can be methods in the class for the object.

so you can have classes for all object types.. may be some classes are inherited because the child has some attributes of the parent.. for example... printer and scanner can have some similar attributes...

Regards,

Kinshuk

0 Kudos

Hi Kinshuk,

Really thanks for your input.

It is good if someone can give me some realistic example in coding as well. I am looking forward for it.

Thank you.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Myahasam

I have found the documentation of an ABAP-OO application that I developed a few years ago.The current task of the customer was to collect timesheet data (transaction CATS ) from its employees and transfer then to the corresponding segments of so-called assessment cycles (transaction KSU3: update receivers in tabstrip Receiver Tracing Factor ). The receivers were the cost centers of a cost center hierarchy (transaction KSH3 ).

For this the customer had to take into account certain time-dependencies in the CATS data as well as in certain infotypes (0027). All this was done manually by exporting the CATS data to Excel, aggregate them, do the calculation and finally transfer them to the cycle segments.

The application should automate this task meaning that they run the report in dialog for a given period (e.g. 01-03/2008) and the report displays:

- the calculated and aggregated data for the cycle segments

- error log in case of missing data (e.g. in the infotype)

How many object can we identify given this (brief) description? The following listing shows the object composition as well:

  • Controller class

    • class CL_DBSEL_CATS (used for CATS selection)

    • Model class

      • CATS Exception class (explained below)

      • Employee class (including interface IF_PT_EMPLOYEE)

      • Allocation Cycle class

    • View class

The report was created according to the MVC model, i.e. the "frame" report was build by the controller class, the entire business logic was located in the model class and the view class was responsible for displaying the ALV lists.

The criteria from the selection-screen were fed to CL_DBSEL_CATS and the returned CATS data were used as input for the model class.

The model class did all the calculations and aggregations.

The allocation cycle class was responsible for reading the cost center hierarchy and the entire handling of the cycles (including DB update) which is not quite trivial.

What was the purpose of the CATS exception class?

The customer wanted to exclude CATSDB records based on certain criteria, e.g.

- exclude all records for a certain employee (PERNR)

- exclude records for a certain order

- exclude records for a certain period

Within the model class I used the following coding to check these exceptions:


LOOP AT me->mt_records INTO ls_record.
  
  IF ( me->exception->is_ignored( is_record = ls_record ) = abap_true ).
    CONTINUE.
  ENDIF.
  ...
ENDLOOP.

The CATS exception class contained a single method IS_IGNORED which returned 'X' if a CATSDB record should be ignored from the allocation.

The beautiful thing about this design was that during the development the customer came up with more and more exception rules. These rules were hidden behind the CATS exception class and nothing changed for the model class because the single method IS_IGNORED always remained the same.

When designing objects always think in terms of responsibilities.

During the development I saw that within the model class I had coding dealing with very specific details about the required infotype 0027.

Question: Does the model class need to know infotype details?

Answer: No. So I moved the coding into the employee class and add a GET method to this class which was then called by the model class.

I hope I could give you some ideas about designing object, a topic where I am still a beginner.

Further reading: [Head First Design Patterns|http://oreilly.com/catalog/9780596007126/]

Regards

Uwe

0 Kudos

Hi Uwe,

Sincerely thanks to you. You always giving me inputs whenever I posted questions.

Please post again, if you have others example as well.

Greatly appreciate it. Thanks.