📜 ⬆️ ⬇️

The book "Ruby. Object Oriented Design

image Hi, Habrozhiteli! Most recently, we translated bestseller Sandy Metz.

The book is devoted to the design of object-oriented programs. This is not a tutorial, but a programmer's story about how to create program code. The book will teach you how to build software so that its high productivity does not decrease in a month or a year. It shows how to create applications that can be successful today and adapt to the requirements of the future.

After carefully reviewing this guide, you can: • Understand how to write quality OOP code in Ruby • Decide what should be a part of the Ruby class • Avoid tight connections between objects when you need to differentiate functionality • Define flexible interfaces between objects • Master duck typing • Effectively use inheritance, composition and polymorphism • Develop cost-effective tests • Improve any legacy Ruby code.

To whom this book will be useful


It is assumed that readers have at least the initial experience of creating object-oriented programs. In this case, it does not matter whether you consider your experience successful, the main thing is that you have a practice of working with any object-oriented language. Chapter 1 provides a brief overview of object-oriented programming and general concepts.
')
If you haven't done object-oriented design yet, but you want to learn, then before you start reading, you need to go through at least an initial programming course. The examples in this book suggest that you have already come across something similar. Experienced programmers can skip this step, but we recommend that most readers get some initial experience with writing object-oriented code.

This book uses the Ruby language for learning object-oriented design, but knowing Ruby is not necessary to master the concepts outlined. The publication provides sample code, and they are very simple. If you have programming experience in any object-oriented language, working with Ruby will not be difficult.

If you are used to working with object-oriented languages ​​with static typing, for example, with Java or C ++, it means that you already have the necessary knowledge to gain from reading this book. Ruby is a dynamic typing language, which simplifies the syntax of the examples and allows you to reflect the very essence of the design. Each concept from the book can be directly translated into the code of an object-oriented language with static typing.

How to read a book


Chapter 1 describes the general tasks of object-oriented design and the circumstances that require its use, gives a brief overview of object-oriented programming (OOP). This chapter seems to stand apart. It can be read first, last, or skipped, but if you are currently faced with a poorly designed application, be sure to read this chapter.

If you have experience writing object-oriented applications and do not want to waste time repeating the information that you already know, you can safely begin with Chapter 2. If you come across an incomprehensible term, go back and skim through the section “Brief Introduction in Object Oriented Programming ”in Chapter 1, where the general concepts of OOP, used in this book, are presented.

Chapters 2–9 explain the wisdom of object-oriented design.

Chapter 2, “Designing Classes with a Single Responsibility,” describes how to decide what should belong to a particular class.

Chapter 3, "Managing Dependencies," shows how objects work together. Chapters 2 and 3 focus on objects, not messages.

In Chapter 4, “Creating Flexible Interfaces,” the emphasis is shifted from design, where everything is built on the basis of objects, to message-based design. This chapter is about defining interfaces; It focuses on how objects communicate with each other.

Chapter 5, "Reducing costs through implicit typing," is devoted to implicit ("duck") typing. The chapter discusses the idea that objects of different classes can play common roles.

Chapter 6, “Getting Behavior Through Inheritance,” teaches the use of classical inheritance technologies.

In Chapter 7, "Separating Role Behavior Using Modules," classical inheritance technologies are used to create roles with implicit typing.

Chapter 8, “Combining Objects by Composing Composition,” reveals the techniques for creating objects through compositions and provides guidance on the choice between composition, inheritance, and role sharing using implicit typing.

Chapter 9, Designing Cost-Effective Tests, focuses primarily on test design; the code from the previous chapters of the book is used as illustrations.

Each of the chapters is based on the concepts disclosed in previous chapters, therefore, it is better to read them in order.

What is the use of this edition


For readers with different levels of preparation, the book will be in many ways useful. Those who are already familiar with object-oriented design, will think about something; perhaps, they will take a fresh look at the already familiar things and, quite possibly, will disagree with something. Since there is no ultimate truth in object-oriented design, challenging the principles (and arguing with the author of this book) will only improve the overall understanding of the subject. In the end, you must evaluate your own code constructions, conduct experiments and make the right choice.

Although the publication should be of interest to readers with different levels of preparation, it was issued with an eye on beginners. If you are a beginner, then this part of the introduction is for you. Understand the simple truth: object-oriented design is not magic. This is just an area you have not yet mastered. And since you are reading these lines, it speaks of your interest, and the desire for knowledge is the only condition for obtaining the benefits of reading this book.

Chapters 2–9 explain the principles of object-oriented design and provide clear programming rules, the meaning of which for a beginner will differ from the value for experienced programmers. Beginners need to follow these rules, not doubting their importance. Unconditional compliance with the rules will help to avoid major troubles until you have gained experience that allows you to make your own decisions. By the time the rules become annoying you, you will already have enough experience to draw up your own rules, and you will start moving up the career ladder as a designer.

about the author


Sandy Metz has been working on such projects for 30 years, the quality of which allows them to expand and improve. She is a software architect at Duke University, where her team solves real problems for clients with large object-oriented applications that have been maintained and developed for 15 years or more. Sandy seeks to create useful, non-trivial programs in extremely practical ways. The book "Ruby. Object-Oriented Design ”is a product of the generalization of many developments and the result of many years of debate on the subject of object-oriented design.

»More information about the book can be found on the publisher's website.
» Table of Contents
» Excerpt

For Habrozhiteley 25% coupon discount - Ruby

Source: https://habr.com/ru/post/317480/


All Articles