Beschreibung
Use design patterns to step up your object-oriented ABAP game, starting with MVC! Want to create objects only when needed? Call objects only when required, minimizing runtime and memory costs? Reduce errors and effort by only coding an object once? Future-proof your code with a flexible design? Design patterns are the answer! With this guide, you'll get practical examples for every design pattern that will have you writing readable, flexible, and reusable code in no time!Highlights include:- MVC (model, view, controller) pattern-Singleton pattern-Factory pattern-Builder pattern-Observer pattern-Visitor pattern-Lazy initialization pattern-Template method-Strategy pattern-Decorator pattern-ABAP-specific examples-Anti-patterns
Highlights:
MVC (model, view, controller) pattern
Singleton pattern
Factory pattern
Builder pattern
Observer pattern
Visitor pattern
Lazy initialization pattern
Template method
Strategy pattern
Decorator pattern
ABAP-specific examples
Anti-patterns
Inhalt
... Design Pattern Categories ... 19
... How to Learn ... 20
1.1 ... Case Study: Read, Process, Display, and Post ... 28
1.2 ... Passing Select Options ... 33
1.3 ... Distributing Application Logic ... 34
1.4 ... Related Patterns ... 34
1.5 ... Summary ... 35
2.1 ... Case Study: Log Analysis ... 40
2.2 ... Related Patterns ... 47
2.3 ... Summary ... 47
3.1 ... Case Study: Jobs for Text Files ... 49
3.2 ... When to Use ... 66
3.3 ... Privacy ... 66
3.4 ... Summary ... 67
4.1 ... Case Study: FI Documents for Parties ... 69
4.2 ... Advantages ... 75
4.3 ... Related Patterns ... 75
4.4 ... Summary ... 76
5.1 ... Case Study: Logging Errors ... 77
5.2 ... Advantages ... 81
5.3 ... Related Patterns ... 81
5.4 ... Summary ... 82
6.1 ... Case Study: Vendor Balance ... 84
6.2 ... When to Use ... 88
6.3 ... When to Avoid ... 88
6.4 ... State Modification ... 89
6.5 ... Summary ... 89
7.1 ... Case Study: Item Clone ... 91
7.2 ... Changing Class Properties ... 95
7.3 ... Clone Operations ... 96
7.4 ... Related Patterns ... 96
7.5 ... Summary ... 97
8.1 ... Case Study: Subcomponents ... 99
8.2 ... Advantages and Disadvantages ... 106
8.3 ... Related Patterns ... 106
8.4 ... Summary ... 106
9.1 ... Case Study: Project Management Tools ... 109
9.2 ... Glue Code ... 118
9.3 ... Two-Way Adapters ... 118
9.4 ... Legacy Classes ... 122
9.5 ... Summary ... 122
10.1 ... Case Study: Messaging Framework ... 123
10.2 ... Advantages ... 131
10.3 ... Summary ... 131
11.1 ... Recursive Programming: A Refresher ... 133
11.2 ... Case Study: HR Positions ... 137
11.3 ... Advantages ... 144
11.4 ... Disadvantages ... 144
11.5 ... When to Use ... 145
11.6 ... Related Patterns ... 145
11.7 ... Summary ... 146
12.1 ... Case Study: Potential Customers ... 147
12.2 ... Redundant Code Prevention ... 152
12.3 ... Related Patterns ... 153
12.4 ... Summary ... 153
13.1 ... Case Study: User Exit ... 155
13.2 ... Advantages and Challenges ... 161
13.3 ... Related Patterns ... 162
13.4 ... Summary ... 162
14.1 ... Case Study: Bonus Calculation ... 166
14.2 ... When and Where to Use ... 168
14.3 ... Related Patterns ... 170
14.4 ... Summary ... 170
15.1 ... Case Study: Negative Stock Forecast ... 171
15.2 ... Disadvantages ... 181
15.3 ... When to Use ... 181
15.4 ... Related Patterns ... 182
15.5 ... Summary ... 182
16.1 ... Case Study: Enhancing an SAP Program ... 185
16.2 ... Static vs. Instance Containers ... 194
16.3 ... Sharing Variables ... 195
16.4 ... Variable Uniqueness ... 196
16.5 ... Related Patterns ... 196
16.6 ... Summary ... 198
17.1 ... Case Study: Sensitive Salary Information ... 199
17.2 ... When to Use ... 206
17.3 ... Related Patterns ... 207
17.4 ... Summary ... 207
18.1 ... Case Study: Purchase Order Approver Determination ... 209
18.2 ... Risks ... 217
18.3 ... Related Patterns ... 217
18.4 ... Summary ... 218
19.1 ... Case Study: SD Documents ... 221
19.2 ... When to Use or Avoid ... 229
19.3 ... Related Patterns ... 229
19.4 ... Summary ... 230
20.1 ... Case Study: Stock Movement Simulation ... 232
20.2 ... When to Use ... 241
20.3 ... Disadvantages ... 241
20.4 ... Summary ... 241
21.1 ... Case Study: Budget Planning ... 243
21.2 ... Risks ... 252
21.3 ... Redo ... 253
21.4 ... Summary ... 254
22.1 ... Case Study: Target Sales Values ... 256
22.2 ... Advantages ... 261
22.3 ... Disadvantages ... 261
22.4 ... Multiple Subjects ... 262
22.5 ... Related Patterns ... 263
22.6 ... Summary ... 264
23.1 ... Case Study: Address Builder ... 266
23.2 ... Extensions ... 274
23.3 ... Related Patterns ... 275
23.4 ... Summary ... 275
24.1 ... Case Study: Authorization-Based Class Behavior ... 277
24.2 ... Advantages ... 283
24.3 ... Related Patterns ... 284
24.4 ... Summary ... 284
25.1 ... Case Study: Sending Material Master Data ... 286
25.2 ... Advantages ... 291
25.3 ... Passing Data to the Strategy Object ... 291
25.4 ... Optional Strategies ... 293
25.5 ... Intermediate Abstract Classes ... 297
25.6 ... Related Patterns ... 302
25.7 ... Summary ... 302
26.1 ... Case Study: Average Transaction Volume ... 306
26.2 ... When to Use ... 318
26.3 ... Advantages and Risks ... 319
26.4 ... Degree of Abstraction ... 320
26.5 ... The “Hollywood Principle” ... 320
26.6 ... Summary ... 321
27.1 ... Case Study: Incoming Invoice Processing ... 323
27.2 ... When to Use ... 333
27.3 ... Related Patterns ... 334
27.4 ... Summary ... 335
A ... Object-Oriented Programming ... 339
B ... Subclass Determination ... 361
C ... Principles ... 371
D ... The Author ... 383