Jason Lee Hodges
Software Engineering from Scratch
A Comprehensive Introduction Using Scala
Jason Lee Hodges
Draper, UT, USA
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/9781484252055 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-5205-5 e-ISBN 978-1-4842-5206-2
https://doi.org/10.1007/978-1-4842-5206-2
Jason Lee Hodges 2019
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.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail 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.
For Hunter and Jax
During the writing of this book, my children asked me why I chose a nebula for the cover. I asked them, Do you know what a nebula is? They quickly and unequivocally boasted, Of course, its where stars are born! To which I replied, Exactly.
I hope that by reading this book a few stars are born.
Table of Contents
About the Author and About the Technical Reviewer
About the Author
Jason Lee Hodges
is currently a Software Engineering Lead at a high-growth unicorn technology start-up. He started programming when he was 11 years old and currently codes in Python, Java, Scala, Kotlin, TypeScript, and Rust on a daily basis. He believes Scala is the ultimate teaching language and that anyone who is willing to put in the work can learn to be a software engineer. You can reach Jason on Twitter @jasonleehodges.
About the Technical Reviewer
Toby Jee
is a Software Programmer currently located in Sydney, Australia. He loves Linux and open source projects. He programs mainly in Java, JavaScript, TypeScript, and Python. In his spare time, Toby enjoys walkabouts, reading, and playing guitar.
Jason Lee Hodges 2019
J. L. Hodges Software Engineering from Scratch https://doi.org/10.1007/978-1-4842-5206-2_1
1. Introduction
Perhaps second only to witnessing the birth of a child, in my opinion there is no experience closer to pure creation than through the arduous efforts and subsequent yield of software engineering. In regard to such efforts, I have found that, in many cases, the amount of fulfillment perceived by an individual is directly proportional to the level of difficulty that they were required to overcome. That is to say, the harder something is, the greater the feeling of accomplishment once you succeed. There is no doubt that software engineering is a difficult discipline to learn and its limits are never-ending. But there is nothing more fruitlessly frustrating than spending tireless hours of energy learning something just to find out that its applications are limited.
Thats how I have felt on several occasions when wading through the bottomless lakes of software engineering topics over time. Granted, no topic on its own was useless I was always able to extrapolate the theme and apply it in another area. However, the aim of this book is to spare you the misery of learning software engineering in a myriad of different ways that ultimately leaves the job of distilling the information usefully up to you. The following chapters will gently guide you through the landscape of computer science and software engineering methodologies and paradigms so that, once completed, you will have a holistic view of what is fundamentally relevant without wasting any time on what is not.
That being said, the study of software engineering takes a good amount of practice and self-discipline. It is advised that you read this book with a group and follow along together, hold each other accountable, help each other get unstuck, code with the examples (dont just read them), and go through all of the exercises. It is important that by the end of each chapter you can accomplish the easy stuff in your sleep without needing to look it up. If you progress through each chapter as such, by the end of this book you should feel confident enough in the software engineering skills youve gained to comfortably write simple programs in an efficient, performant, and scalable manner.
I have found that the most effective way to learn to be a software engineer is to start with a baseline of context. So, in this chapter you will be presented with an abridged history of programming in order to build this context. After which you will be briefly introduced to the Scala programming language and why it is the ultimate teaching language.
Brief History of Programming
In order to properly introduce software engineering, it is necessary to first define programming and how it was derived. So, what is programming and what is code? A program , in its most basic form, is a set of instructions that tells a machine what to do. That program is written using code which is a series of language constructs or symbols that are written to form meaning to the machine. It is extremely important to understand that, despite the complexity of modern software engineering, all programs are made up of a series of very basic instructions that when combined together create increasingly more complex functionality.
To demonstrate this, lets create a mental model of what a computer is and how it works. If you take the outer shell off of any computer and look inside, you will see a whole lot of wires and chips plugged into components that are soldered onto a variety of green silicon boards. But just like the complexity of software, the hardware can be boiled down to a series of basic components as well. For the purposes of this introduction, well boil down a computer to a simple, small, green silicon board and thats it. Not very useful yet. Next, lets add to this mental model of a computer the notion that a computer really only interprets a basic programs instructions in the form of whether or not a transistor on our green silicon board should allow electricity to flow through it or not. So, lets put a transistor on our board. Effectively, the transistor is an on/off switch. A very basic program would give the machine a series of combinations of on and off instructions in an attempt to accomplish something. Perhaps, for the sake of example, allowing electricity to flow through a transistor would turn on a tiny light bulb. So next, well add a light bulb to our model computer. By providing a series of on/off instructions, a programmer could communicate with that light in Morse Code, thereby providing meaning or application to their program. But, given a basic silicon electrical board with a transistor and a light bulb, how does the programmer provide the instructions to the machine?