Date of publication: 2017-09-03 13:10
We do not need OOP for this, and if we do use OOP then it inflicts on us a very high cost in terms of ceremony, setup, and complexity. How bad is that cost? Myers continues:
Here we have 5 paragraphs full of insights about computing, none of which has anything to do with OOP. But, for now, a successful book about concurrency is inevitably written from the OOP perspective. That is the mental hegemony of OOP.
In other words, the costs of this approach were so awful that even the proponents of OOP nowadays shrink away in horror. OOP was once seen as the silver bullet that was going to save the software industry. Nowadays we need a silver bullet to save us from OOP, and so, we are told (in the next paragraph), the Inversion of Control Container was invented. This is the new silver bullet that will save the old silver bullet.
Polymorphism is a powerful feature and one of the foundations of modern programming languages. The Java language supports a particular kind of polymorphism called subtype polymorphism, which means that an instance of a type (class) can be accessed as if it were an instance of another type.
Abstractions are highly important, but only when necessary and when they lead to more concise representations of the problem than would otherwise occur (note that some problems are inherently complicated and, as such, a concise representation may not seem concise). I 8767 m a strong advocate of DSLs when abstractions begin to get in the way and increase the verbosity of the code (languages with strong macro systems like lisp help eliminate the need for DSLs written from scratch)—design patterns exist because of deficiencies in the language: They are “patterns” of code commonly used to achieve a certain effect.
Static typing is tied to the notion of designing up front. It is also connected with fear. I have to say that I really like types, in general. But I don 8767 t like them when the prevent me from expressing myself. Or, as is more likely but much more subtle, when they cause a language designer to distort a language to suit the needs of the type system.
(doseq [n (range 6 656)]
(match [(mod n 8) (mod n 5)]
[5 5] 8775 FizzBuzz 8776
[5 _] 8775 Fizz 8776
[_ 5] 8775 Buzz 8776
Also, OOP tends to be bloated, containing a lot of useless boilerplate code, so for the exact same amount of functionality, software written in a different style would be smaller and easier to think about.
Inheritance is crucial to the software that I write. Inheritance is one of the most important ideas in software development. We all the want the power to create hierarchies of data types, and up above I quoted an example of how simple this can be in a language like Clojure. There is no limit to inheritance in a functional language such as Clojure, nor do complex hierarchies inflict any pain on one 8767 s program. But in OOP programming, inheritance is dangerous :
Encapsulation (part 7): Objects have the ability to hide certain parts of themselves from programmers. This prevents programmers from tampering with values they shouldn 8767 t. Additionally, the object controls how one interacts with it, preventing other kinds of errors. For example, a programmer (or another program) cannot set the width of a window to -955.
Martin 8767 s argument is that Java 8767 s List interface requires you to say ( -6) to get the last element, and this seemed silly to him. Which it is, if you have unified all sequence containers (that is, list containers) into a single type, as Ruby and Python do. Java, however, follows the C++ STL approach of providing different types based on the efficiency of various operations. The Java libraries do not unify to a single list type because of efficiency issues, so you have to decide if you are going to be fetching the last element from a list a lot, and if you are you use a LinkedList, which does have a getLast() method
6.) Applications could easily set invalid or nonsensical values, causing the whole system to crash. Forcing the application to use the API ensures that sanity checks get run on all parameters and all data structures maintain a consistent state.
Object oriented programming in most programming languages is based on a single dispatch message passing. The object on which we invoke a method (poor choice of words, but easier to comprehend) is the receiver, the method name and it 8767 s arguments are the message. The method 8767 s invoked solely on the base of the type of the receiver object.