Comments (3)
An interesting case. Some prefix or suffix would definitely fix this.
Consider these prior thoughts:
An alternative to Hungarian prefixes might be adding a more elaborate name. For example, we could call the types transport_change_row
and transport_changes_table
. Or in reverse call the attribute collected_transport_changes
.
This is similar to the classical interface-vs-class-name conflict, that goes like this: "I have a data_provider
interface and a single data_provider
class that implements it. Which of the two do I rename, and how, to avoid a name conflict?"
Extracting the types to another development object, such as a local interface local_types
would fix the syntax error. Similarly, extracting the types to the data dictionary would probably also fix it - unless the global table type's name would again be transport_changes
.
If this conflict appears often, it may justify using extensive prefixing. If it is seldom, we need to weight whether it is acceptable to prefix 2,048 types and members only to avoid 16 name clashes, and probably 16 more unforeseen ones in the future.
Java-vs-ABAP comarators have repeatedly pointed out that Java distinguishes the two with typesetting the first character, as in DataProvider
(the class) vs. dataProvider
(the private attribute). However, porting this to ABAP only justifies something like a very general t_
prefix for any type-like declaration, to be used for all classes, interfaces, data elements, structures, table types etc. It does not justify some elaborate schema such as mtt
in your example, which also encodes the context (m
for "member") and type (first t
for table).
Also consider how prefixing again introduces misunderstandings. In many SAP teams, mt_
would be a "tabular class attribute", and tt_
a local table type definition, making mtt_
a confusing mixture of non-mixable concepts.
from styleguides.
I just made a pull-request to make some examples how to avoid name clashes like you describe it. Maybe we can extend it to also cover the type vs. variable conflict.
For your example above you basically gave the solution already.
- The type describes a change_request.
- The variable makes it more specific as a transport_change_request.
So it is a matter of coming from the more generic to the more specific. And as always, naming is not easy. ;-)
CLASS zcl_tms_transport DEFINITION
PUBLIC
CREATE PUBLIC .
PUBLIC SECTION.
" ...
PRIVATE SECTION.
TYPES:
BEGIN OF change_request,
change_request_key TYPE key,
transport_request TYPE trkorr,
date_quality_assurance TYPE lxeexphead_impdate,
END OF change_request.
TYPES:
change_requests TYPE SORTED TABLE OF
change_request WITH UNIQUE KEY change_request_key.
DATA transport_change_requests TYPE change_requests . "syntax error gone
" ...
ENDCLASS.
from styleguides.
Since there was no further discussion here after #101, this issue can be considered closed.
from styleguides.
Related Issues (20)
- Strategy for handling dependencies to system releases HOT 4
- Text on logo not readable in dark mode (Code Review Guide) HOT 3
- [Exploit the test tools] Add CL_AUNIT_AUTHORITY_CHECK to the list? HOT 6
- [Consider decomposing complex conditions] bad use case example HOT 1
- German Translation: Typo HOT 1
- Use assert class instead of ASSERT HOT 12
- Are comments bad or not?
- [Use CHANGING sparingly, where suited] Is it ok to use IMPORTING REF instead of CHANGING? HOT 7
- New rule: prefer inferring types HOT 1
- Abap Exception categories HOT 3
- Use READ-ONLY sparingly - new abap command FINAL HOT 2
- How to add sample code to Clean ABAP? HOT 1
- Unclear explanation of [Use LOCAL FRIENDS to access the dependency-inverting constructor] HOT 5
- Follow rules when abbreviating HOT 1
- "Dead" link at section "split-method-instead-of-boolean-input-parameter" HOT 3
- Chapter "Avoid abbreviations" HOT 7
- [Prefer RAISE EXCEPTION NEW to RAISE EXCEPTION TYPE] In defense of RAISE EXCEPTION TYPE HOT 6
- Prefer ENUM to constants interfaces HOT 1
- [Use | to assemble text] Is a caveat needed in case of translatable texts? HOT 7
- "New rule" Tables > Prefer a Table Expression to READ TABLE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from styleguides.