The book is on its third edition, it has had plenty of space as the must-read for every Ruby programmer, many great personalities in the software development community have commented, praised, written about this book (including Yukihiro “Matz” Matsumoto, the creator of Ruby) because a few years after Ruby was conceived the first edition was published, and as everything evolved, the book has done as well.
This time the background of the beginning of this language is presented, how Matz thought in terms of design and usage for building this language, it went from the approach machine-centered paradigm to a human-centered one. Ruby strives to be friendly to the programmer, and with that in mind, we can rely on a completely new style of software development, more strategically then tactic, easier to read, needlessly to add comments.
This piece has 22 chapters, and more than 700 pages; it covers the conception of the language, introduction to object orientation, basic syntax and semantics, working with strings, symbols, ranges, numbers, times and dates and of course our arrays, hashes and other Enumerables, also, goes over more advanced data structures like trees, graphs, sets, stacks and queues. It brings the difference between static and dynamic languages, testing, how to handle different data formats, how is related Ruby and web applications, and more stuff that you can leverage in order to cement draw Ruby fundamentals.
To me it was the longest book I’d ever had in my hands, quite hard to start to be honest but as soon as you pass the first pages you get caught, it refreshed me a ton of built in methods for the most important data structures, and when I say a ton, it’s about 80% of all what you need (very comfy way to read these methods on the book, and with the method description more friendlier) , so very well thought from the author perspective, not hard theory to digest, only practical examples and a few debates between 2 different points of view but nothing abstract.
I think is a good start for people who want to harden their programming skills because it covers many topics of software development, it doesn’t matter what language you come from, it works for processing text files, web development, graphical interfaces, some algorithms to get familiarized with.
Notes. ✍🏻
An object is an entity that serves as a container for data and also controls access to the data. Associated with the object is a set of attributes, which are essentially no more than variables belonging to the object.Also associated with an object is a set of functions that provide an interface to the functionality of the object, called methods.
It is a essential that any OOP language to provide encapsulation. The class may be thought of as the blueprint or pattern; The object itself is the thing created from that blueprint or pattern. A class is often thought of as an abstract type, a more complex type than, for example, an integer or character string.
Inheritance is a mechanism that allows us to extend previously existing entity by adding features to create a new entity. In short, inheritance is a way of reusing code. Easy effective code reuse has long been the Holy Grail of computer science, resulting in the invention decades ago of parameterized subroutines and code libraries.
Multiple inheritance he’s probably the most controversial area in OOP; one camp will point out the potential for ambiguity that must be resolved. It is conceivable that a new class could inherit from more than one class.
Diamond inheritance problem, so-called because of the shape of its inheritance diagram, with both super classes inheriting from a single common superclass.
The literal meaning of polymorphism is the ability to take on multiple forms or shapes. In its broadest sense, this refers to the ability to different objects to respond in different ways to the same message (or method invocation).
The first, inheritance polymorphism, is what most programmers are referring to when they talk about polymorphism.
When a class inherits from its superclass we know that any method present in the superclass is also present in the subclass.
The second kind of polymorphism Conway identifies is interface polymorphism.
This does not require any inheritance relationship between classes; It only requires that the interface of the object have met thoughts of a certain name.
A module consists of methods or constants that may be used as though they were actually part of the class or object; When a module is mixed in via the include statement this is considered to be a restrictive form of multiple inheritance.
By rivals are used to hold reference to objects.
A module is a collection of methods and constants that is external to the Ruby program.
The private level means that the method is accessible only within the class or its subclass.
Ruby is a dynamic language in the sense that objects and classes may be altered at runtime. Will be has the capability to construct and evaluate pieces of gold in the course of executing the existing statically coded program. This is perhaps the most difficult area a programmer will encounter in learning Ruby.
Everything is intuitive once you understand it.
Everything is true except false and nil.
many languages have some kind of for loop, as does Ruby. The question sooner or later arises as to whether the index variable can be modified.
Any object can be in principle converted to some kind of string representation; That is why nearly every quarter class has a to_s method.
A symbol is like a string in that it corresponds to a sequence of chapters. It is unlikely string in that each symbol has only one instance (just as a fixed number works). Therefore there is a memory or performance issue to be aware of.
The & notation allows us to pass a proc instead of an explicit attached block if we want. Because we use the & on an object that is not a problem interpreter tries to call to_call on that object. It will call it repeatedly, once for each element in the right. The collect method (part of innumerable) is a useful tool that proves to be a time and labor saver in many circumstances.
If you want to delete all instances of a certain piece of data, delete would do the job. The compact method (or it’s in place version compact!) removes nil values from an array, leaving the rest untouched.
The delete_if passes every element into the supply block and delete the elements for which the block evaluates to true. It behaves similarly to reject!, except that the latter can return when the array remains unchanged.
They reject method takes a block and produces a new array without the elements for which the block returns true.
Bear in mind that +, concat, and even +=always create a new array object. Also bear in mind that while « adds to the existing array, it happens a new array element (which may itself be an array).
What makes a collection enumerable ? Largely it is just the fact of being a collection. The module enumerable has the requirements that the default iterate each should be defined. Sequence as such is not an issue because even on unordered collection can have any generator.
And enumerator is basically an object that can be used for external or internal iteration. In internal iteration, we simply iterate over each item in the collection and execute the block for each item in the sequence; External iteration means that the code can grab the next item in the sequence “on demand”.
There are many other methods on Enumerable, and I cover most of them here. For convenience, I have divided them a little arbitrarily in four areas: searching and selecting, counting and comparing, iterating, and finally extracting and converting . The purpose of inheritance, of course, is to add or enhance functionality.
It’s not always necessary to use super in such a way, but it is often convenient. Every attribute and method of the point is reflected in the child.
The child can have additional attributes and methods, as you have already seen. The child can override or redefine any of the attributes and methods of the parents.
If we invoke a method on a subclass, the method for that class will be called if it exists. If it does not the method in the superclass will be called, and so on.
When we create a new structure template by calling Struct . New we may pass a string with the class name as the first argument. If we do come a new class is created where in class Struct itself, with the name passed in as the first parameter and the attributes given as the rest of the parameters.
Every time you invoke a method, you are sending a message to an object.