Book
Object-Oriented Programming
Object-Oriented Programming with Java and Python — Every useful program you have ever used — the app that tells you when your laundry is ready, the game on your phone, the website where you pay a bill — is built out of objects: small, self-contained pieces of software that each know something and can do something, and that cooperate by sending one another messages. This book teaches you to think in objects and to build with them, in the two languages that the world uses most for exactly that purpose: Java and Python.
Overview
Chapters 1 to 3 set up your workbench (VS Code, the Java Development Kit and Python, on Windows, macOS or Linux), teach the development environment and the debugger, and build the first classes: objects, strings, types, conditionals and loops. Chapters 5 to 7 add arrays and lists, input, exceptions and files, documentation and testing, interfaces, inheritance, polymorphism and access control. Chapters 9 to 11 cover collections and generics, graphical user interfaces and events, and the Model–View–Controller pattern. Chapters 13 to 15 treat iterators and immutability, threads and their dangers, and networking with sockets, ending with a team project.
Chapters 4, 8, 12 and 16 are Evaluation and Discussion chapters. Each closes one quarter of the book by solving complete problems in full — every problem restated, designed on paper, programmed in both languages, tested, run, and explained — with the tempting wrong solutions shown and taken apart, and a “check yourself” variant at the end of every problem.
Throughout, one small business grows chapter by chapter: Profitina Laundry, a laundry shop whose customers, orders, services, machines and receipts become classes, interfaces, collections, windows, threads and network services as the book goes on. Each chapter also has a Profitina in Practice section that shows where the same ideas appear in a real product.
Every program in this book was compiled and run before its output was printed. The programs are collected, chapter by chapter, in the accompanying Code folder, with a README in every chapter folder that explains how to run each one in a terminal and in VS Code on Windows, macOS and Linux.
Inside the Book
- Objects, Programs, and Your First Workbench
- The Development Environment: Editing, Running, and Debugging
- Classes, Objects, Strings, Types, Conditionals, and Loops
- Evaluation and Discussion I: From a Plain Specification to a Tested Class
- Arrays, Lists, Input, Exceptions, and Files
- Documentation, Testing, and Interfaces
- Inheritance, Polymorphism, and Access Control
- Evaluation and Discussion II: Recursive Structures, Robust Classes, and Class Hierarchies
- Collections and Generics
- Graphical User Interfaces and Event Handling
- The Model–View–Controller Pattern
- Evaluation and Discussion III: Predictive Text with Lists, Maps, Trees, and a Keypad
- Iterators, Immutability, and More Collections
- Threads, Races, Deadlock, and Livelock
- Sockets, Networking, and the Team Project
- Evaluation and Discussion IV: Iterators, Concurrency, Networking, and the Whole Book
Profitina · profitina.com

