Clean ABAP
This skill provides comprehensive checking of ABAP code against Clean ABAP principles, based on the Clean ABAP style guide which adapts Robert C. Martin's Clean Code for ABAP.
How to Use This Skill
When checking ABAP code for Clean ABAP compliance:
- Read the code provided by the user
- Categorize issues by Clean ABAP sections (Names, Language, Constants, Variables, Tables, Strings, Booleans, Conditions, Ifs, Classes, Methods, Error Handling, Comments, Formatting, Testing)
- Identify violations with specific line references when available
- Provide actionable recommendations with code examples showing both the problem and the clean solution
- Prioritize issues by impact (critical, major, minor)
Check Categories
1. Names
Key Principles:
- Use descriptive names that convey content and meaning
- Prefer solution domain and problem domain terms
- Use pronounceable names
- Use snake_case consistently
- Avoid abbreviations unless necessary
- Use nouns for classes, verbs for methods
- Avoid noise words like "data", "info", "object"
- Pick one word per concept
- Avoid encodings (Hungarian notation, prefixes like iv_, rv_, lt_)
- Avoid obscuring built-in functions
Check for:
- Non-descriptive variable/method/class names (e.g.,
data1, temp, x)
- Inconsistent abbreviations across the code
- Mixed naming conventions (not snake_case)
- Noise words in names
- Hungarian notation or unnecessary prefixes (iv_, ev_, rv_, lt_, ls_)
- Method names that obscure ABAP built-in functions
2. Language
Key Principles:
- Prefer object orientation to procedural programming
- Prefer functional to procedural language constructs
- Avoid obsolete language elements
- Use design patterns wisely
Check for:
- Use of obsolete statements (unescaped host variables in SELECT, etc.)
- Procedural code that should be object-oriented
- Use of old-style MOVE instead of assignment
- TRANSLATE instead of to_upper()/to_lower()
- CREATE OBJECT instead of NEW
- Old-style READ TABLE instead of table expressions
3. Constants
Key Principles:
- Use constants instead of magic numbers
- Constants need descriptive names
- Prefer ENUM to constants interfaces
- Group related constants
Check for:
- Magic numbers or string literals in code
- Constants with non-descriptive names (c_01, c_x, etc.)
- Ungrouped constants that should be in BEGIN OF/END OF blocks
4. Variables
Key Principles:
- Prefer inline to up-front declarations
- Don't use variables outside their declaration block
- Don't chain up-front declarations
- Don't use field symbols for dynamic data access (modern ABAP)
- Choose the right loop targets (field symbols vs references vs values)
Check for:
- Up-front DATA declarations when inline would be clearer
- Variables used outside their declaration block scope
- Chained DATA declarations
- Unnecessary field symbols with ASSIGN
5. Tables
Key Principles:
- Use the right table type (STANDARD, SORTED, HASHED)
- Avoid DEFAULT KEY
- Prefer INSERT INTO TABLE to APPEND TO
- Prefer LINE_EXISTS to READ TABLE or LOOP AT
- Prefer READ TABLE to LOOP AT
- Prefer LOOP AT WHERE to nested IF
- Avoid unnecessary table reads
Check for:
- Tables with DEFAULT KEY
- APPEND TO when INSERT INTO TABLE is more appropriate
- READ TABLE ... TRANSPORTING NO FIELDS when LINE_EXISTS would be clearer
- LOOP AT ... EXIT when READ TABLE is intended
- Nested IF inside LOOP AT when WHERE clause would work
- Double reads (checking existence then reading again)
6. Strings
Key Principles:
- Use ` (backticks) to define string literals
- Use | (pipes) to assemble text
Check for:
- Single quotes for string literals
- String concatenation with && instead of string templates
7. Booleans
Key Principles:
- Use ABAP_BOOL for boolean types
- Use ABAP_TRUE and ABAP_FALSE for comparisons
- Use XSDBOOL to set boolean variables
- Consider if booleans are the right choice (vs enumerations)
Check for:
- Use of CHAR1 or other types instead of ABAP_BOOL
- Comparisons with 'X' and ' ' instead of ABAP_TRUE/ABAP_FALSE
- IF-THEN-ELSE to set boolean instead of XSDBOOL
- Boolean parameters that should be split methods
8. Conditions
Key Principles:
- Try to make conditions positive
- Prefer IS NOT to NOT IS
- Consider predicative method calls for boolean methods
- Consider decomposing/extracting complex conditions
Check for:
- Negative conditions that could be positive
- NOT IS instead of IS NOT
- Complex nested conditions that should be decomposed
- Long conditions that should be extracted to methods
9. Ifs
Key Principles:
- No empty IF branches
- Prefer CASE to ELSE IF for multiple alternatives
- Keep nesting depth low
Check for:
- Empty IF with logic only in ELSE
- Multiple ELSE IF that should be CASE
- Deeply nested IF statements (>3 levels)
10. Classes
Key Principles:
- Prefer objects to static classes
- Prefer composition to inheritance
- Don't mix stateful and stateless in same class
- Global by default, local only where appropriate
- FINAL if not designed for inheritance
- Members PRIVATE by default, PROTECTED only if needed
- Consider immutable instead of getter
Check for:
- Static classes that should be instance-based
- Deep inheritance hierarchies
- Mixed stateful/stateless methods
- Non-FINAL classes not designed for inheritance
- PUBLIC members that should be PRIVATE/PROTECTED
- Unnecessary getter methods for immutable data
11. Methods
Key Principles:
- Prefer instance to static methods
- Public instance methods should implement interfaces
- Aim for few IMPORTING parameters (<3)
- Split methods instead of OPTIONAL parameters
- RETURN, EXPORT, or CHANGE exactly one parameter
- Prefer RETURNING to EXPORTING
- Do one thing, do it well, do it only
- Keep methods small (3-5 statements ideal)
- Fail fast
- Omit RECEIVING, EXPORTING keywords when possible
- Omit self-reference ME when calling instance members
Check for:
- Static methods that should be instance methods
- Public methods not part of an interface
- Methods with >3 IMPORTING parameters
- Multiple OPTIONAL parameters (should be split methods)
- Multiple output parameters
- EXPORTING instead of RETURNING
- Long methods (>20 lines)
- Methods doing multiple things
- Unnecessary RECEIVING, EXPORTING keywords
- Explicit ME-> calls
12. Error Handling
Key Principles:
- Prefer exceptions to return codes
- Use class-based exceptions
- Throw CX_STATIC_CHECK for manageable exceptions
- Throw CX_NO_CHECK for unrecoverable situations
- Prefer RAISE EXCEPTION NEW to RAISE EXCEPTION TYPE
- Wrap foreign exceptions
Check for:
- Return codes instead of exceptions
- Use of message classes for error handling
- Old-style RAISE EXCEPTION TYPE
- Unwrapped foreign exceptions
- Catching generic CX_ROOT
13. Comments
Key Principles:
- Express yourself in code, not comments
- Comments are no excuse for bad names
- Write comments to explain why, not what
- Comment with ", not *
- Delete code instead of commenting it
- Use FIXME, TODO, XXX with your ID
- ABAP Doc only for public APIs
Check for:
- Obvious comments explaining what code does
- Comments compensating for bad names
- Commented-out code
-
- Comments without TODO/FIXME tags
- Manual versioning in comments
- Duplicate message texts in comments
14. Formatting
Key Principles:
- Use ABAP Formatter before activating
- No more than one statement per line
- Reasonable line length (120 chars)
- Single blank lines to separate (not more)
- Close brackets at line end
- Keep single parameter calls on one line
- Indent and snap to tab
Check for:
- Multiple statements per line
- Lines exceeding 120 characters
- Multiple consecutive blank lines
- Inconsistent indentation
- Chained assignments
15. Testing
Key Principles:
- Write testable code
- Test publics, not private internals
- Use given-when-then structure
- Few, focused assertions
- Use the right assert type
Check for:
- Untestable code (tight coupling, no dependency injection)
- Tests without clear given-when-then structure
- Multiple unrelated assertions
- Missing test classes for public methods
Output Format
Structure your analysis as follows:
# Clean ABAP Check Results
## Summary
- Total Issues: [count]
- Critical: [count]
- Major: [count]
- Minor: [count]
## Critical Issues
### [Category] - [Issue Title]
**Location:** Line [X] / Method [name]
**Problem:** [Description of what violates Clean ABAP]
**Recommendation:** [How to fix it]
**Anti-pattern:**
```abap
[problematic code]
Clean code:
[improved code]
Major Issues
[Same format as Critical]
Minor Issues
[Same format as Critical]
Positive Observations
- [Things done well according to Clean ABAP]
Overall Assessment
[Brief summary of code quality and main areas for improvement]
## Priority Levels
**Critical:** Issues that significantly impact maintainability, testability, or could cause bugs
- Magic numbers without constants
- Deep nesting (>3 levels)
- Methods with >5 parameters
- Empty IF branches
- Static classes without interfaces
- Return codes instead of exceptions
**Major:** Issues that reduce code clarity and violate Clean ABAP principles
- Non-descriptive names
- Hungarian notation/prefixes
- Long methods (>20 lines)
- DEFAULT KEY usage
- Commented-out code
- Multiple output parameters
**Minor:** Issues that are stylistic improvements
- Missing inline declarations
- String quotes instead of backticks
- Unnecessary ME-> references
- Formatting inconsistencies
## References
When you need detailed explanations or examples for specific Clean ABAP rules, consult these reference files:
1. **Complete Guidelines**: Read `@skills/clean-abap/references/CleanABAP.md` - the full Clean ABAP style guide with in-depth explanations, rationale, and code examples for all principles
2. **Quick Patterns**: Read `@skills/clean-abap/references/quick-reference.md` - condensed good/bad code examples for common patterns
3. **Review Checklist**: Read `@skills/clean-abap/references/checklist.md` - a checklist format for systematic code reviews
**When to consult references:**
- To provide accurate citations when explaining violations
- To show users the official reasoning behind recommendations
- To find specific code examples to illustrate points
- To answer follow-up questions about Clean ABAP principles
- When encountering edge cases not covered in the summary above
## Examples
### Example 1: Checking a Simple Method
**Input:**
```abap
METHOD calculate.
DATA: lv_result TYPE i,
lv_temp TYPE i.
lv_temp = iv_value1 + iv_value2.
IF lv_temp > 100.
lv_result = lv_temp * 2.
ELSE.
lv_result = lv_temp.
ENDIF.
ev_result = lv_result.
ENDMETHOD.
Output:
# Clean ABAP Check Results
## Summary
- Total Issues: 4
- Critical: 0
- Major: 2
- Minor: 2
## Major Issues
### Names - Hungarian Notation Used
**Location:** Method calculate
**Problem:** Variables use Hungarian notation prefixes (lv_, iv_, ev_) which adds no value and violates Clean ABAP naming guidelines.
**Recommendation:** Remove prefixes and use descriptive names.
**Anti-pattern:**
```abap
DATA: lv_result TYPE i,
lv_temp TYPE i.
Clean code:
DATA(result) = value1 + value2.
IF result > 100.
result = result * 2.
ENDIF.
Methods - EXPORTING Instead of RETURNING
Location: Method signature
Problem: Method uses EXPORTING parameter instead of RETURNING, preventing functional call style.
Recommendation: Use RETURNING parameter for single output value.
Anti-pattern:
METHOD calculate
IMPORTING iv_value1 TYPE i
iv_value2 TYPE i
EXPORTING ev_result TYPE i.
Clean code:
METHOD calculate
IMPORTING value1 TYPE i
value2 TYPE i
RETURNING VALUE(result) TYPE i.
Minor Issues
Variables - Up-front Declarations
Location: Lines 2-3
Problem: Variables declared up-front instead of inline, increasing distance between declaration and usage.
Recommendation: Use inline declarations with DATA( ).
Language - Procedural Style
Location: Lines 5-9
Problem: Could use COND for conditional assignment instead of IF-ELSE.
Recommendation: Use functional constructs.
Clean code:
METHOD calculate
IMPORTING value1 TYPE i
value2 TYPE i
RETURNING VALUE(result) TYPE i.
DATA(sum) = value1 + value2.
result = COND #( WHEN sum > 100 THEN sum * 2 ELSE sum ).
ENDMETHOD.
Overall Assessment
The code is functional but uses outdated ABAP patterns. Main improvements needed: remove Hungarian notation, use RETURNING instead of EXPORTING, prefer inline declarations, and use functional language constructs. After these changes, the code will be significantly cleaner and more maintainable.
1---2name: clean-abap3description: Check ABAP code for compliance with Clean ABAP principles. Use this skill when users ask to check, validate, review, or analyze ABAP code for clean code compliance, code quality, best practices, or adherence to Clean ABAP guidelines. Triggers include requests like "check this ABAP code", "is this clean ABAP", "review my ABAP for clean code", "validate ABAP against clean code principles", or "analyze ABAP code quality".4---5
6# Clean ABAP
7
8This skill provides comprehensive checking of ABAP code against Clean ABAP principles, based on the Clean ABAP style guide which adapts Robert C. Martin's Clean Code for ABAP.
9
10## How to Use This Skill
11
12When checking ABAP code for Clean ABAP compliance:
13
141. **Read the code** provided by the user
152. **Categorize issues** by Clean ABAP sections (Names, Language, Constants, Variables, Tables, Strings, Booleans, Conditions, Ifs, Classes, Methods, Error Handling, Comments, Formatting, Testing)
163. **Identify violations** with specific line references when available
174. **Provide actionable recommendations** with code examples showing both the problem and the clean solution
185. **Prioritize issues** by impact (critical, major, minor)
19
20## Check Categories
21
22### 1. Names
23
24**Key Principles:**
25- Use descriptive names that convey content and meaning
26- Prefer solution domain and problem domain terms
27- Use pronounceable names
28- Use snake_case consistently
29- Avoid abbreviations unless necessary
30- Use nouns for classes, verbs for methods
31- Avoid noise words like "data", "info", "object"
32- Pick one word per concept
33- Avoid encodings (Hungarian notation, prefixes like iv_, rv_, lt_)
34- Avoid obscuring built-in functions
35
36**Check for:**
37- Non-descriptive variable/method/class names (e.g., `data1`, `temp`, `x`)
38- Inconsistent abbreviations across the code
39- Mixed naming conventions (not snake_case)
40- Noise words in names
41- Hungarian notation or unnecessary prefixes (iv_, ev_, rv_, lt_, ls_)
42- Method names that obscure ABAP built-in functions
43
44### 2. Language
45
46**Key Principles:**
47- Prefer object orientation to procedural programming
48- Prefer functional to procedural language constructs
49- Avoid obsolete language elements
50- Use design patterns wisely
51
52**Check for:**
53- Use of obsolete statements (unescaped host variables in SELECT, etc.)
54- Procedural code that should be object-oriented
55- Use of old-style MOVE instead of assignment
56- TRANSLATE instead of to_upper()/to_lower()
57- CREATE OBJECT instead of NEW
58- Old-style READ TABLE instead of table expressions
59
60### 3. Constants
61
62**Key Principles:**
63- Use constants instead of magic numbers
64- Constants need descriptive names
65- Prefer ENUM to constants interfaces
66- Group related constants
67
68**Check for:**
69- Magic numbers or string literals in code
70- Constants with non-descriptive names (c_01, c_x, etc.)
71- Ungrouped constants that should be in BEGIN OF/END OF blocks
72
73### 4. Variables
74
75**Key Principles:**
76- Prefer inline to up-front declarations
77- Don't use variables outside their declaration block
78- Don't chain up-front declarations
79- Don't use field symbols for dynamic data access (modern ABAP)
80- Choose the right loop targets (field symbols vs references vs values)
81
82**Check for:**
83- Up-front DATA declarations when inline would be clearer
84- Variables used outside their declaration block scope
85- Chained DATA declarations
86- Unnecessary field symbols with ASSIGN
87
88### 5. Tables
89
90**Key Principles:**
91- Use the right table type (STANDARD, SORTED, HASHED)
92- Avoid DEFAULT KEY
93- Prefer INSERT INTO TABLE to APPEND TO
94- Prefer LINE_EXISTS to READ TABLE or LOOP AT
95- Prefer READ TABLE to LOOP AT
96- Prefer LOOP AT WHERE to nested IF
97- Avoid unnecessary table reads
98
99**Check for:**
100- Tables with DEFAULT KEY
101- APPEND TO when INSERT INTO TABLE is more appropriate
102- READ TABLE ... TRANSPORTING NO FIELDS when LINE_EXISTS would be clearer
103- LOOP AT ... EXIT when READ TABLE is intended
104- Nested IF inside LOOP AT when WHERE clause would work
105- Double reads (checking existence then reading again)
106
107### 6. Strings
108
109**Key Principles:**
110- Use ` (backticks) to define string literals
111- Use | (pipes) to assemble text
112
113**Check for:**
114- Single quotes for string literals
115- String concatenation with && instead of string templates
116
117### 7. Booleans
118
119**Key Principles:**
120- Use ABAP_BOOL for boolean types
121- Use ABAP_TRUE and ABAP_FALSE for comparisons
122- Use XSDBOOL to set boolean variables
123- Consider if booleans are the right choice (vs enumerations)
124
125**Check for:**
126- Use of CHAR1 or other types instead of ABAP_BOOL
127- Comparisons with 'X' and ' ' instead of ABAP_TRUE/ABAP_FALSE
128- IF-THEN-ELSE to set boolean instead of XSDBOOL
129- Boolean parameters that should be split methods
130
131### 8. Conditions
132
133**Key Principles:**
134- Try to make conditions positive
135- Prefer IS NOT to NOT IS
136- Consider predicative method calls for boolean methods
137- Consider decomposing/extracting complex conditions
138
139**Check for:**
140- Negative conditions that could be positive
141- NOT IS instead of IS NOT
142- Complex nested conditions that should be decomposed
143- Long conditions that should be extracted to methods
144
145### 9. Ifs
146
147**Key Principles:**
148- No empty IF branches
149- Prefer CASE to ELSE IF for multiple alternatives
150- Keep nesting depth low
151
152**Check for:**
153- Empty IF with logic only in ELSE
154- Multiple ELSE IF that should be CASE
155- Deeply nested IF statements (>3 levels)
156
157### 10. Classes
158
159**Key Principles:**
160- Prefer objects to static classes
161- Prefer composition to inheritance
162- Don't mix stateful and stateless in same class
163- Global by default, local only where appropriate
164- FINAL if not designed for inheritance
165- Members PRIVATE by default, PROTECTED only if needed
166- Consider immutable instead of getter
167
168**Check for:**
169- Static classes that should be instance-based
170- Deep inheritance hierarchies
171- Mixed stateful/stateless methods
172- Non-FINAL classes not designed for inheritance
173- PUBLIC members that should be PRIVATE/PROTECTED
174- Unnecessary getter methods for immutable data
175
176### 11. Methods
177
178**Key Principles:**
179- Prefer instance to static methods
180- Public instance methods should implement interfaces
181- Aim for few IMPORTING parameters (<3)
182- Split methods instead of OPTIONAL parameters
183- RETURN, EXPORT, or CHANGE exactly one parameter
184- Prefer RETURNING to EXPORTING
185- Do one thing, do it well, do it only
186- Keep methods small (3-5 statements ideal)
187- Fail fast
188- Omit RECEIVING, EXPORTING keywords when possible
189- Omit self-reference ME when calling instance members
190
191**Check for:**
192- Static methods that should be instance methods
193- Public methods not part of an interface
194- Methods with >3 IMPORTING parameters
195- Multiple OPTIONAL parameters (should be split methods)
196- Multiple output parameters
197- EXPORTING instead of RETURNING
198- Long methods (>20 lines)
199- Methods doing multiple things
200- Unnecessary RECEIVING, EXPORTING keywords
201- Explicit ME-> calls
202
203### 12. Error Handling
204
205**Key Principles:**
206- Prefer exceptions to return codes
207- Use class-based exceptions
208- Throw CX_STATIC_CHECK for manageable exceptions
209- Throw CX_NO_CHECK for unrecoverable situations
210- Prefer RAISE EXCEPTION NEW to RAISE EXCEPTION TYPE
211- Wrap foreign exceptions
212
213**Check for:**
214- Return codes instead of exceptions
215- Use of message classes for error handling
216- Old-style RAISE EXCEPTION TYPE
217- Unwrapped foreign exceptions
218- Catching generic CX_ROOT
219
220### 13. Comments
221
222**Key Principles:**
223- Express yourself in code, not comments
224- Comments are no excuse for bad names
225- Write comments to explain why, not what
226- Comment with ", not *
227- Delete code instead of commenting it
228- Use FIXME, TODO, XXX with your ID
229- ABAP Doc only for public APIs
230
231**Check for:**
232- Obvious comments explaining what code does
233- Comments compensating for bad names
234- Commented-out code
235- * comments instead of "
236- Comments without TODO/FIXME tags
237- Manual versioning in comments
238- Duplicate message texts in comments
239
240### 14. Formatting
241
242**Key Principles:**
243- Use ABAP Formatter before activating
244- No more than one statement per line
245- Reasonable line length (120 chars)
246- Single blank lines to separate (not more)
247- Close brackets at line end
248- Keep single parameter calls on one line
249- Indent and snap to tab
250
251**Check for:**
252- Multiple statements per line
253- Lines exceeding 120 characters
254- Multiple consecutive blank lines
255- Inconsistent indentation
256- Chained assignments
257
258### 15. Testing
259
260**Key Principles:**
261- Write testable code
262- Test publics, not private internals
263- Use given-when-then structure
264- Few, focused assertions
265- Use the right assert type
266
267**Check for:**
268- Untestable code (tight coupling, no dependency injection)
269- Tests without clear given-when-then structure
270- Multiple unrelated assertions
271- Missing test classes for public methods
272
273## Output Format
274
275Structure your analysis as follows:
276
277```
278# Clean ABAP Check Results
279
280## Summary
281- Total Issues: [count]
282- Critical: [count]
283- Major: [count]
284- Minor: [count]
285
286## Critical Issues
287
288### [Category] - [Issue Title]
289**Location:** Line [X] / Method [name]
290**Problem:** [Description of what violates Clean ABAP]
291**Recommendation:** [How to fix it]
292
293**Anti-pattern:**
294```abap
295[problematic code]
296```
297
298**Clean code:**
299```abap
300[improved code]
301```
302
303## Major Issues
304[Same format as Critical]
305
306## Minor Issues
307[Same format as Critical]
308
309## Positive Observations
310- [Things done well according to Clean ABAP]
311
312## Overall Assessment
313[Brief summary of code quality and main areas for improvement]
314```
315
316## Priority Levels
317
318**Critical:** Issues that significantly impact maintainability, testability, or could cause bugs
319- Magic numbers without constants
320- Deep nesting (>3 levels)
321- Methods with >5 parameters
322- Empty IF branches
323- Static classes without interfaces
324- Return codes instead of exceptions
325
326**Major:** Issues that reduce code clarity and violate Clean ABAP principles
327- Non-descriptive names
328- Hungarian notation/prefixes
329- Long methods (>20 lines)
330- DEFAULT KEY usage
331- Commented-out code
332- Multiple output parameters
333
334**Minor:** Issues that are stylistic improvements
335- Missing inline declarations
336- String quotes instead of backticks
337- Unnecessary ME-> references
338- Formatting inconsistencies
339
340## References
341
342When you need detailed explanations or examples for specific Clean ABAP rules, consult these reference files:
343
3441. **Complete Guidelines**: Read `@skills/clean-abap/references/CleanABAP.md` - the full Clean ABAP style guide with in-depth explanations, rationale, and code examples for all principles
3452. **Quick Patterns**: Read `@skills/clean-abap/references/quick-reference.md` - condensed good/bad code examples for common patterns
3463. **Review Checklist**: Read `@skills/clean-abap/references/checklist.md` - a checklist format for systematic code reviews
347
348**When to consult references:**
349- To provide accurate citations when explaining violations
350- To show users the official reasoning behind recommendations
351- To find specific code examples to illustrate points
352- To answer follow-up questions about Clean ABAP principles
353- When encountering edge cases not covered in the summary above
354
355## Examples
356
357### Example 1: Checking a Simple Method
358
359**Input:**
360```abap
361METHOD calculate.
362 DATA: lv_result TYPE i,
363 lv_temp TYPE i.
364
365 lv_temp = iv_value1 + iv_value2.
366 IF lv_temp > 100.
367 lv_result = lv_temp * 2.
368 ELSE.
369 lv_result = lv_temp.
370 ENDIF.
371
372 ev_result = lv_result.
373ENDMETHOD.
374```
375
376**Output:**
377```
378# Clean ABAP Check Results
379
380## Summary
381- Total Issues: 4
382- Critical: 0
383- Major: 2
384- Minor: 2
385
386## Major Issues
387
388### Names - Hungarian Notation Used
389**Location:** Method calculate
390**Problem:** Variables use Hungarian notation prefixes (lv_, iv_, ev_) which adds no value and violates Clean ABAP naming guidelines.
391**Recommendation:** Remove prefixes and use descriptive names.
392
393**Anti-pattern:**
394```abap
395DATA: lv_result TYPE i,
396 lv_temp TYPE i.
397```
398
399**Clean code:**
400```abap
401DATA(result) = value1 + value2.
402IF result > 100.
403 result = result * 2.
404ENDIF.
405```
406
407### Methods - EXPORTING Instead of RETURNING
408**Location:** Method signature
409**Problem:** Method uses EXPORTING parameter instead of RETURNING, preventing functional call style.
410**Recommendation:** Use RETURNING parameter for single output value.
411
412**Anti-pattern:**
413```abap
414METHOD calculate
415 IMPORTING iv_value1 TYPE i
416 iv_value2 TYPE i
417 EXPORTING ev_result TYPE i.
418```
419
420**Clean code:**
421```abap
422METHOD calculate
423 IMPORTING value1 TYPE i
424 value2 TYPE i
425 RETURNING VALUE(result) TYPE i.
426```
427
428## Minor Issues
429
430### Variables - Up-front Declarations
431**Location:** Lines 2-3
432**Problem:** Variables declared up-front instead of inline, increasing distance between declaration and usage.
433**Recommendation:** Use inline declarations with DATA( ).
434
435### Language - Procedural Style
436**Location:** Lines 5-9
437**Problem:** Could use COND for conditional assignment instead of IF-ELSE.
438**Recommendation:** Use functional constructs.
439
440**Clean code:**
441```abap
442METHOD calculate
443 IMPORTING value1 TYPE i
444 value2 TYPE i
445 RETURNING VALUE(result) TYPE i.
446
447 DATA(sum) = value1 + value2.
448 result = COND #( WHEN sum > 100 THEN sum * 2 ELSE sum ).
449ENDMETHOD.
450```
451
452## Overall Assessment
453The code is functional but uses outdated ABAP patterns. Main improvements needed: remove Hungarian notation, use RETURNING instead of EXPORTING, prefer inline declarations, and use functional language constructs. After these changes, the code will be significantly cleaner and more maintainable.
454```