Jacquie Barker
Beginning Java Objects
From Concepts to Code
3rd ed.
The Apress logo.
Jacquie Barker
Fairfax, VA, USA
ISBN 978-1-4842-9059-0 e-ISBN 978-1-4842-9060-6
https://doi.org/10.1007/978-1-4842-9060-6
Jacquie Barker 2000, 2005, 2023
Standard Apress
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.
This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
To my husband, best friend, and love of my life, Steve, who supports me each and every day in more ways than he can possibly imagine.
Preface
Welcome to the third edition of Beginning Java Objects (BJO)! Since the first edition of BJO was published back in November 2000 and the second edition in 2005, Ive been delighted by the many emails and positive reviews that Ive received from readers who found my book to be a perfect jump start into Java and object-oriented (OO) programming . So many beginning Java books dive into a discussion of the language itself without properly grounding readers in how to think and structure an application from the ground up to take full advantage of object-oriented principles; Im delighted that youve chosen BJO to get started on your Java journey.
My book is based on timeless principles that are language version independent, which means that it neednt be revised every time a new version of Java is released. What do change, sometimes seemingly in the blink of an eye, are third-party technologies used in conjunction with the core Java language, and so weve replaced material that went into detail regarding outdated technologies with a single chapter (Chapter ) that explains conceptually how to move forward with building an application that achieves proper modeldata layerpresentation layer separation.
Weve also included mention of some of the significant enhancements to the Java language as of versions 8 through 17 (the newest version due out as of the time of writing of the third edition).
As always, I welcome reader feedback and hope to hear from you at jacquie.barker@gmail.com.
Best regards,
Jacquie
Introduction
This is a book, first and foremost, about software objects: what they are, why they are so magical and yet so straightforward, and how one goes about structuring a software application to use objects appropriately.
This is also a book about Java: not a hard-core, everything there is to know about Java book, but rather a gentle yet comprehensive introduction to the language, with special emphasis on how to transition from an object model to a working Java applicationsomething that few, if any, other books provide.
Goals for This Book
My goals in writing this book (and, hopefully, yours for buying it) are to
Make you comfortable with fundamental object-oriented (OO) terminology and concepts.
Give you hands-on, practical experience with object modeling, that is, with developing an object-oriented blueprint that can be used as the basis for subsequently building an object-oriented software system.
Illustrate the basics of how such an object model is translated into a working software applicationa Java application, to be specific, although the techniques that youll learn for object modeling apply equally well to any OO language.
Help you become proficient as a Java programmer along the way.
If youre already experienced with the Java language (but not with object fundamentals), its critical to your successful use of the language that you learn about its object-oriented roots. On the other hand, if youre a newcomer to Java, then this book will get you properly jump-started. Either way, this book is a must-read for anyone who wishes to become proficient with an OO programming language like Java.
Just as importantly, this book is
not meant to
Turn you into an overnight pro in object modeling: Like all advanced skills, becoming totally comfortable with object modeling takes two things: a good theoretical foundation and a lot of practice! I give you the foundation in this book, including an introduction to the Unified Modeling Language (UML) , the industry standard for rendering an object-oriented blueprint of a software application. (UML was first adopted as a standard for modeling objected-oriented software systems in 1997 and is still relevant today.) That being said, the only way youll really get to be proficient with object modeling is by participating in OO modeling and development projects over time.
My book will give you the skills, and hopefully the confidence, to begin to apply object techniques in a professional setting, which is where your real learning will take place, particularly if you have an OO-experienced mentor to guide you through your first industrial-strength project.
Teach you everything youll ever need to know about Java: Java is a very rich language, consisting of hundreds of core classes and literally thousands of operations that can be performed with and by these classes. Also, new versions of the Java language are released by Oracle Corporation every year or so, but the good news is that key Java features needed to represent a software problem in a proper object-oriented way have not changed over the years. If Java provides a dozen alternative ways to do something in particular, I explain the one or two ways that I feel best suit the problem at hand, to give you an appreciation for how things are done. Nonetheless, youll definitely see enough of the Java language in this book to prepare you for a role as a professional Java programmer.
Armed with the foundation you gain from this book, youll be poised and ready to appreciate a more thorough treatment of Java such as that offered by one of the many other Java references that are presently on the market or a deeper review of object modeling techniques from an in-depth UML reference. Well make recommendations for such books in Chapter .
Why Is Understanding Objects So Critical to Being a Successful OO Programmer?
Time and again, I meet software developersat my place of employment, at clients offices, at professional conferences, on college campuseswho have attempted to master an object- oriented programming language (OOPL) like Java by taking a course in Java, reading a book about Java, or installing and using a Java integrated development environment (IDE) such as Eclipse , IntelliJ IDEA , NetBeans , or BlueJ . However, there is something fundamentally missing from virtually all of these approaches: a basic understanding of what objects are all about and, more importantly,