Skip to Content
0
Feb 05, 2011 at 05:27 PM

Public Read-Only Attributes

437 Views

I'm trying to pick up ABAP on my own by reading through various resources I've collected and writing my own programs. Unfortunately I don't have an experienced ABAP guru to ask questions of. I'm hoping someone can help me with the following:

Based on my other programming experience I know that it is very common for object attributes to be defined as private and then accessor/mutator (getter/setter) methods to be defined to provide access to the attribute.

In my study I noted that ABAP allows attributes to be made public but declared to be read-only. This would seem to permit a structure where accessor/getter methods are not needed (the attribute can be read externally) and one would only have to define a mutator/setter method.

My question: what is typically done in 'real-world' programs? Is there any reason why using read-only would be more or less preferred?

Thanks for any help that can be provided.