Paul David Hardy
North Strathfield, NSW, Australia
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-6710-3 . For more-detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-6710-3 e-ISBN 978-1-4842-6711-0
https://doi.org/10.1007/978-1-4842-6711-0
Paul David Hardy 2021
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Springer Science + Business Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, email orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC, and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Introduction
In 2015, the American SAP Users Group (ASUG) wanted my opinion on a new survey that had been put out by a company called CAST, which had analyzed about 70 large custom ABAP applications from organizations all across the United States and Europe and come to the conclusion that all that custom code was a load of old baloney, ludicrous, rubbish, hopeless, and fit only for the dustbin.
The clear implication was that the ABAP programmers who had written these applications could not touch their own nose, let alone write a program containing even one ounce of quality. Nonetheless, the programs workedthey solved the business problems they were created to solve.
How can this be? How can we get to the stage where 100 percent of code is no good and yet 100 percent of code appears to work? It is because the two things are unrelated to an extentbut only to an extent.
What is meant by the codes being no good is that the analyzed programs were big balls of mudprone to breaking for no apparent reason, and so complicated it would be impossible for any programmer other than the creator (and often even the creator) to understand what was going on and how to fix things or make a change. Sadly, this did not surprise me at all.
For Whom This Book Is Applicable
This book is aimed at all ABAP developers, whether they started yesterday or have been programming for 20 years. In fact, the ones who have been programming for 20-plus years probably need this book more, as a lot of them have fallen into bad habits or have never even heard of modern programming concepts like object-oriented programming or test-driven development.
Why This Book Was Written
If I were to boil this book down to one sentence, it would be: How did we get to the terrible situation where the vast majority of custom code is of poor quality, and what can we (realistically) do to solve this problem?
How Did We Get Here?
So the next question is, how did we get here? It is not because the programmers lack skill. Most programs usually start off perfect with no quality issues at all. Then, somehow, they get worse over time as more and more changes and additions are made.
I would say that programs degrade as a result of the false belief that code quality really does not matter at all. I imagine that in 99 percent of organizations, what the programmer is instructed to do is to make the exact change(s) required and ignore the fact that the program is (a) already a horrible mess or (b) your current change will make a fairly good program into more of a mess than it was before. The fact that you are actually making the problem worse over time is neither here nor there, as long as the requirement is met, really quickly.
Most management would say this approach is the only possible way to get things done. Time (and money) is always tight and getting tighter. Therefore, the idea is to make our changes as quickly as possible. In real life, over a protracted period quality code is actually cheaper than poor-quality code because the maintenance effort is so much lower, but that is a very difficult concept to convey.
How Do We Get Back?
Fear is always a killerwhen changing a program, if you find an obvious existing bug, do you fix it, even if that is not what you are actually supposed to be doing? In some companies, you could get sacked for that.
You probably have heard the following famous quote:
The only thing necessary for the triumph of evil is for good men to do nothing.
Edmund Burke (in a letter addressed to Thomas Mercer)
I could rephrase this as follows:
All it takes for poor quality to triumph is for good programmers to leave obviously bad code the way it is because they are scared of it.
This book is going to be about confronting and overcoming that fear, gradually increasing the quality of your code. This could be described as doing a favor to yourself, and to your colleagues both current and future. Robert C. Martin has an approach he calls The Boy Scout Rule regarding what to do with the area of code you have just fixed or enhanced:
Its not enough to write the code well. The code has to be kept clean over time. Weve all seen code rot and degrade as time passes. So we must take an active role in preventing this degradation.
The Boy Scouts of America have a simple rule that we can apply to our profession.
Leave the campground cleaner than you found it.
If we all checked-in our code a little cleaner than when we checked it out, the code simply could not rot. The cleanup doesnt have to be something big. Change one variable name for the better, break up one function thats a little too large, eliminate one small bit of duplication, clean up one composite if statement.