Clean ABAP: A Style Guide for Developers
- Length: 300 pages
- Edition: F
- Language: English
- Publisher: SAP Press
- Publication Date: 2020-11-24
- ISBN-10: 1493220268
- ISBN-13: 9781493220267
- Sales Rank: #1679134 (See Top 100 Books)
ABAP developers, are you looking to clean up your code? Then pick up this official companion to the Clean ABAP GitHub repository. This book is brimming with best practices, straight from the experts, to help you write effective ABAP code. Start by learning when to apply each clean ABAP practice. Then, dive into detailed code examples and explanations for using classes, methods, names, variables, internal tables, and more. From writing code to troubleshooting and testing, this is your complete style guide!
In this book, you’ll learn about:
a. Clean ABAP Concepts
What is clean ABAP and why is it important to write clean code? Understand clean ABAP concepts with insight from the experts, including special considerations for legacy code and performance.
b. Best Practices
Walk through the what, why, and how behind clean ABAP best practices. Learn to improve your code, including using classes and interfaces appropriately, handling method design and control flow, designing and running unit tests, and much more.
c. Practical Examples
See clean ABAP practices in action! Improve your understanding of how to write effective code. Use detailed examples for each best practice that demonstrate the difference between clean and messy code.
Highlights include:
1) Classes and interfaces
2) Methods
3) Names
4) Variables and literals
5) Internal tables
6) Control flow
7) Comments
8) Formatting
9) Error handling
10) Unit testing
11) Packages
Dear Reader Notes on Usage Table of Contents Preface Who This Book Is For How This Book Is Organized Acknowledgments Conclusion 1 Introduction 1.1 What Is Clean ABAP? 1.1.1 What Is Readability? 1.1.2 What’s the Story behind Clean ABAP? 1.2 How to Get Started with Clean ABAP 1.3 How to Handle Legacy Code 1.4 How to Check Code Automatically 1.5 How Does Clean ABAP Relate to Other Guides? 1.6 How to Engage with the Clean ABAP Community 1.7 Summary 2 The ABAP Language 2.1 Mind Legacy Code 2.2 Mind Performance 2.2.1 Mostly Harmless 2.2.2 Start Clean, Degrade Only Where Needed 2.2.3 Measure, Don’t Assume 2.3 Prefer Object Orientation to Procedural Programming 2.3.1 ABAP’s Programming Paradigm 2.3.2 The Difference between Function Groups and Classes 2.3.3 Differences in ABAP’s Object Orientation 2.3.4 If You Have No Choice 2.4 Favor Functional Language Constructs over Procedural Language Constructs 2.5 Avoid Obsolete Language Elements 2.6 Use Design Patterns Wisely 2.6.1 Too Many Singletons 2.6.2 Too Many Patterns Mixed 2.7 Summary 3 Classes and Interfaces 3.1 Object Orientation 3.1.1 Interfaces 3.1.2 Classes and Objects 3.1.3 State 3.2 Scope and Visibility 3.2.1 Global and Local Scope 3.2.2 Visibility 3.3 Constructors 3.3.1 Scope and Visibility 3.3.2 Dependency Injection 3.3.3 Static Creation Methods 3.3.4 Creational Patterns 3.3.5 Instantiation 3.4 Summary 4 Methods 4.1 Object-Oriented Programming 4.1.1 Static and Instance Methods 4.1.2 Public Instance Methods 4.1.3 Method Redefinition 4.2 Parameters 4.2.1 How Many Input Parameters Are Too Many? 4.2.2 Optional Input Parameters 4.2.3 Preferred Input Parameters 4.2.4 Boolean Input Parameters 4.2.5 EXPORTING Parameters 4.2.6 RETURNING Parameters 4.2.7 CHANGING Parameters 4.2.8 Pass-by-Value and Pass-by-Reference 4.3 Method Body 4.3.1 Do One Thing 4.3.2 Descend One Level of Abstraction 4.3.3 Keep Methods Small 4.3.4 Fail Fast 4.3.5 CHECK versus RETURN 4.4 Calling Methods 4.4.1 Passing Input Parameters 4.4.2 Capturing Output Parameters 4.4.3 The CALL METHOD Construct 4.4.4 Optional Parameter Name 4.4.5 Self-Reference 4.5 Summary 5 Names 5.1 Good Naming 5.1.1 Descriptive Names 5.1.2 Domain Terms 5.1.3 Plural or Singular? 5.1.4 Abbreviations 5.1.5 Naming Classes and Methods 5.1.6 Noise Words 5.1.7 Term Consistency 5.1.8 Design Patterns in Code 5.1.9 Hungarian Notation and Prefixes 5.2 ABAP Peculiarities 5.2.1 Group of Objects with Possible Name Collisions 5.2.2 snake_case versus camelCase 5.3 Affixes: Prefixes, Suffixes, and Infixes 5.3.1 The Musts 5.3.2 Helpful Affixes 5.3.3 Affixes That Don’t Bring Value 5.4 Dealing with Legacy Code 5.5 Summary 6 Variables and Literals 6.1 Variables 6.1.1 Declaring Variables 6.1.2 Branches and Scope 6.1.3 Declaration Chaining 6.1.4 Looping Variables 6.2 Constants 6.2.1 Proper Use of Constants 6.2.2 Enumeration Classes 6.2.3 Constant Grouping 6.3 Strings 6.3.1 String Literals 6.3.2 String Building 6.4 Booleans 6.4.1 When to Use Booleans 6.4.2 XSDBOOL for Inline Decisions 6.5 Regular Expressions 6.5.1 Simple Regular Expressions 6.5.2 Basic Checks 6.5.3 Complex Regular Expressions 6.6 REDUCE 6.7 Summary 7 Internal Tables 7.1 Using the Right Table Category 7.1.1 Standard Tables 7.1.2 Sorted Tables 7.1.3 Hashed Tables 7.2 Avoiding DEFAULT KEY 7.3 INSERT INTO TABLE and APPEND TO 7.3.1 APPEND Statement 7.3.2 INSERT Statement 7.4 Verifying the Existence of a Row 7.4.1 READ TABLE 7.4.2 LOOP AT 7.4.3 LINE_EXISTS 7.5 Retrieving Table Contents 7.5.1 LOOP AT 7.5.2 READ TABLE 7.6 LOOP AT WHERE and Nested IF 7.6.1 Nested IF 7.6.2 LOOP AT … WHERE 7.7 Identifying Unnecessary Table Reads 7.8 Block Processing of Table Rows and Single Row Operations 7.9 DESCRIBE TABLE and Table Function LINES 7.9.1 DESCRIBE TABLE 7.9.2 LINES 7.10 Summary 8 Control Flow 8.1 IFs 8.1.1 IF Branches 8.1.2 Keep It Understandable 8.2 Nesting Depth 8.3 Conditions 8.3.1 Try to Make Conditions Positive 8.3.2 IS NOT or NOT IS 8.3.3 Complex Conditions 8.4 CASE 8.4.1 CASE or IF 8.4.2 CASE or SWITCH 8.4.3 Multiple Uses of the Same CASE 8.5 Do 1 Times 8.5.1 Pseudo Loops for Control Flow 8.5.2 Refactoring 8.6 Summary 9 Comments 9.1 Express Yourself in Code 9.2 Comment Placement and Usage 9.3 Comments to Avoid 9.4 FIXME, TODO, and XXX Comments 9.5 Special Comments: ABAP Doc, Pragmas, and Pseudo Comments 9.6 Summary 10 Formatting 10.1 Consistency in Coding Style 10.2 Optimizing for Reading 10.3 The Pretty Printer 10.4 Number of Statements Per Line 10.5 Line Length 10.6 Condensing the Code 10.7 Blank Lines 10.8 Alignment of Assignment Statements 10.9 Alignment of Variable Declarations 10.10 Placement of Closing Brackets 10.11 Formatting Method Parameters 10.11.1 Single Parameter Calls 10.11.2 Line Break Multiple Parameters 10.11.3 Placement of Parameters 10.11.4 Indenting Parameters 10.11.5 Vertical Alignment of Parameter Values 10.11.6 Breaking Calls to a New Line 10.11.7 Indents and Using the Tab Key 10.11.8 Indentation of Inline Declarations 10.12 Summary 11 Error Handling 11.1 Messages 11.2 Return Codes 11.2.1 Exceptions versus Return Codes 11.2.2 Handling Failures 11.3 Exceptions 11.3.1 Exceptions Are for Errors 11.3.2 Class-Based Exceptions 11.3.3 CX_STATIC_CHECK 11.3.4 CX_NO_CHECK 11.3.5 CX_DYNAMIC_CHECK 11.4 Raising and Catching 11.4.1 Exception Superclass 11.4.2 Raising Exceptions 11.4.3 Catching Exceptions 11.4.4 When to Dump 11.5 Summary 12 Unit Testing 12.1 Test Classes 12.1.1 Test Class Properties 12.1.2 Test Class Scope 12.1.3 Test Helper Classes 12.1.4 Executing Tests 12.2 Test Methods 12.2.1 Test Fixture Methods 12.2.2 Given-When-Then Style 12.3 Class under Test 12.4 Naming 12.5 Assertions 12.5.1 Writing Effective Assertions 12.5.2 Checking Expected Exceptions 12.5.3 Unexpected Static Exceptions 12.5.4 Custom Assertions 12.5.5 Constraints 12.6 Test Doubles 12.6.1 Dependency Inversion and Test Doubles 12.6.2 ABAP Object-Oriented Test Double Framework 12.6.3 More ABAP Test Tools 12.7 Test Seams 12.8 Principles 12.8.1 Test-Driven Development 12.8.2 Clean Test Properties 12.8.3 Test Coverage 12.9 Summary 13 Packages 13.1 General Package Concepts 13.1.1 Use Cases 13.1.2 Reuse Levels 13.1.3 Cohesion 13.2 Package Concepts in ABAP 13.2.1 Package Types 13.2.2 Encapsulated Packages 13.2.3 Package Interfaces 13.2.4 Best Practices 13.3 Package Design Options 13.3.1 Side-by-Side Application Hierarchies 13.3.2 Layer-Based Hierarchies 13.3.3 Translation Relevance Split Hierarchies 13.4 Package Checks 13.4.1 What Are Package Checks? 13.4.2 Manual Execution of Package Checks 13.4.3 Automated Execution of Package Checks 13.4.4 How to Fix Package Check Errors 13.4.5 Best Practices 13.5 Consequences of Poor or No Package Strategy 13.6 Summary 14 How to Implement Clean ABAP 14.1 Common Understanding among Team Members 14.2 Collective Code Ownership 14.3 Clean Code Developer Initiative 14.4 Tackling the Broken Window Effect 14.4.1 Static Code Check 14.4.2 Metrics 14.4.3 Code Coverage 14.5 Code Review and Learning 14.5.1 Code Review Prefix 14.5.2 Style Guide 14.5.3 Make It Visible 14.5.4 Feedback Culture 14.6 Clean Code Advisor 14.7 Learning Techniques 14.7.1 Kata 14.7.2 Dojo 14.7.3 Code Retreat 14.7.4 Fellowship 14.7.5 Pair Programming 14.7.6 Mob Programming 14.7.7 Habits 14.8 Continuous Learning in Cross-Functional Teams 14.8.1 Profile of a Team Member 14.8.2 Cross-Functional Teams 14.8.3 Multipliers: Need for Topic Experts in the Team 14.8.4 Need for Community of Practice 14.9 Summary A The Authors Index Service Pages Legal Notes
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.