{"id":307137,"date":"2021-07-24T11:00:29","date_gmt":"2021-07-24T08:00:29","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/object-oriented-programming-is-dead-wait-really\/"},"modified":"2021-07-24T11:00:29","modified_gmt":"2021-07-24T08:00:29","slug":"object-oriented-programming-is-dead-wait-really","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/","title":{"rendered":"#Object-oriented programming is dead. Wait, really?"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a26221016fbe\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a26221016fbe\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#Is_coupling_functions_with_data_that_stupid\" >Is coupling functions with data that stupid?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#The_five_big_problems_in_object-oriented_programming\" >The five big problems in object-oriented programming<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#The_banana_gorilla_jungle_problem\" >The banana gorilla jungle problem<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#The_fragile_base_class_problem\" >The fragile base class problem<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#The_diamond_problem\" >The diamond problem<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#The_hierarchy_problem\" >The hierarchy problem<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#The_reference_problem\" >The reference problem<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#The_danger_of_the_single_paradigm\" >The danger of the single paradigm<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/buradabiliyorum.com\/en\/object-oriented-programming-is-dead-wait-really\/#The_big_question_are_we_on_the_cusp_of_a_new_revolution\" >The big question: are we on the cusp of a new revolution?<\/a><\/li><\/ul><\/nav><\/div>\n<p>&#8220;<strong>#Object-oriented programming is dead. Wait, really?<\/strong>&#8221;<br \/>\n<img decoding=\"async\" src=\"https:\/\/img-cdn.tnwcdn.com\/image?fit=796%2C417&amp;url=https%3A%2F%2Fcdn0.tnwcdn.com%2Fwp-content%2Fblogs.dir%2F1%2Ffiles%2F2021%2F07%2Fdead.jpg&amp;signature=5bdc47dce2b0412392ae90b7e79863ef\" \/><\/p>\n<p id=\"8960\">Programming in the 1960s had a big problem: computers weren\u2019t that powerful yet, and somehow they needed to<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/medium.com\/javascript-scene\/the-forgotten-history-of-oop-88d71b9b2d9f\">split the capacities<\/a><span>\u00a0<\/span>between data structures and procedures.<\/p>\n<p id=\"706b\">This meant that if you had a large set of data, you couldn\u2019t do that much with it without pushing a computer to its limits. On the other hand, if you needed to do a lot of things, you couldn\u2019t use too much data or the computer would take forever.<\/p>\n<p id=\"d407\">Then Alan Kay came aroun<span id=\"rmm\">d<\/span><span>\u00a0<\/span>in 1966 or 1967 and theorized that one could use encapsulated mini-computers that didn\u2019t share their data, but rather communicated through messaging. This way, compute resources could be used much more economically.<\/p>\n<p id=\"9def\">Despite the ingenuity of the idea, it would take<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/archive.org\/details\/byte-magazine-1981-08\/page\/n75\/mode\/2up\">until 1981<\/a><span>\u00a0<\/span>until object-oriented programming hit the mainstream. Since then, however, it hasn\u2019t stopped attracting new and seasoned software developers alike. The<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/www.linkedin.com\/jobs\/object-oriented-programming-jobs\/\">market<\/a><span>\u00a0<\/span>for object-oriented programmers is as busy as ever.<\/p>\n<p id=\"1e11\">But in recent years, the decade-old paradigm has received more and more<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/medium.com\/@cscalfani\/goodbye-object-oriented-programming-a59cda4c0e53\">criticism<\/a>. Could it be that, four decades after object-oriented programming hit the masses, <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/technology\/\" data-internallinksmanager029f6b8e52c=\"4\" title=\"Technology\" target=\"_blank\" rel=\"noopener\">technology<\/a> is outgrowing this paradigm?<\/p>\n<div>\n<h2 id=\"1c9e\" class=\"mc md gq bf me mf mg kl mh mi mj ko mk ml mm mn mo mp mq mr ms mt mu mv mw mx hn\"><span class=\"ez-toc-section\" id=\"Is_coupling_functions_with_data_that_stupid\"><\/span>Is coupling functions with data that stupid?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p id=\"944b\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">The main idea behind object-oriented programming is as simple as can be: you try to break a program in parts that are as powerful as the whole. It follows that you couple pieces of data and those functions that only get used on the data in question.<\/p>\n<p id=\"77ce\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Note that this only covers the notion of encapsulation, that is, data and functions that sit inside an object are invisible to the outside. One can only interact with the contents of an object through messages, typically called getter and setter functions.<\/p>\n<p id=\"de59\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">What is not contained in the initial idea, but is considered essential to object-oriented programming today, are inheritance and polymorphism. Inheritance basically means that developers can define subclasses that have all the properties that their parent class has. This wasn\u2019t introduced to object-oriented programming until 1976, a decade after its conception.<\/p>\n<p id=\"9dc1\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Polymorphism came to object-oriented programming<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"http:\/\/lucacardelli.name\/Papers\/OnUnderstanding.A4.pdf\">another decade later<\/a>. In basic terms, it means that a method or an object can serve as a template for others. In a sense it\u2019s a <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a>ization of inheritance, because not all properties of the original method or object need to be transmitted to the new entity; instead, you can choose to override properties.<\/p>\n<p id=\"9b94\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">What\u2019s special about polymorphism is that even if two entities depend on each other in the source code, a called entity works more like a plugin. This makes life easier for developers because they don\u2019t have to worry about dependencies at runtime.<\/p>\n<p id=\"8624\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">It\u2019s worth mentioning that inheritance and polymorphism aren\u2019t exclusive to object-oriented programming. The real differentiator is encapsulating pieces of data and the methods that belong to them. In a time where compute resources were a lot scarcer than today, this was a genius idea.<\/p>\n<h2 id=\"54b5\" class=\"mc md gq bf me mf mg kl mh mi mj ko mk ml mm mn mo mp mq mr ms mt mu mv mw mx hn\"><span class=\"ez-toc-section\" id=\"The_five_big_problems_in_object-oriented_programming\"><\/span>The five big problems in object-oriented programming<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p id=\"7906\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">Once object-oriented programming hit the masses, it transformed the way developers see code. What prevailed before the 1980s, procedural programming, was very machine-oriented. Developers needed to know quite a bit about how computers work to write good code.<\/p>\n<p id=\"f7f4\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">By encapsulating data and methods, object-oriented programming made software development more human-centered. It matches human intuition that the method<span>\u00a0<\/span><code>drive()<\/code><span>\u00a0<\/span>belongs to the data group<span>\u00a0<\/span><code>car<\/code>, but not to the group<span>\u00a0<\/span><code>teddybear<\/code>.<\/p>\n<p id=\"466e\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">When inheritance came around, that was intuitive, too. It makes perfect sense that<span>\u00a0<\/span><code>Hyundai<\/code><span>\u00a0<\/span>is a subgroup of<span>\u00a0<\/span><code>car<\/code><span>\u00a0<\/span>and shares the same properties, but<span>\u00a0<\/span><code>PooTheBear<\/code><span>\u00a0<\/span>does not.<\/p>\n<p id=\"180d\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">This sounds like a powerful machinery. The problem, however, is that programmers who only know object-oriented code will force this way of thinking on everything they do. It\u2019s like when people see nails everywhere because all they have is a hammer. As we will see below, when your toolbox contains only a hammer, that can lead to fatal problems.<\/p>\n<h3 id=\"6df1\" class=\"nx md gq bf me ny nz hr mh oa ob hu mk hv oc hx mo hy od ia ms ib oe id mw of hn\"><span class=\"ez-toc-section\" id=\"The_banana_gorilla_jungle_problem\"><\/span>The banana gorilla jungle problem<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p id=\"0bb9\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">Imagine you\u2019re setting up a new program, and you\u2019re thinking about designing a new class. Then you think back to a neat little class that you\u2019ve created for another project, and you realize that it would be perfect for what you\u2019re currently trying to do.<\/p>\n<p id=\"538a\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">No problem! You can reuse the class from the old project for your new one.<\/p>\n<p id=\"a7bf\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Except for the fact that this class may actually be a subclass of another class, so now you need to include the parent class too. Then you realize that the parent class depends on other classes as well, and you end up including heaps of code.<\/p>\n<p id=\"8f9e\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">The creator of Erlang, Joe Armstrong, famously<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/www.defprogramming.com\/quotes-by\/joe-armstrong\/\">proclaimed<\/a>:<\/p>\n<blockquote>\n<p class=\"p1\">The problem with object-oriented languages is they\u2019ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.<\/p>\n<\/blockquote>\n<p id=\"56ca\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">That pretty much says it all. It\u2019s fine to reuse classes; in fact, it can be a major virtue of object-oriented programming.<\/p>\n<p id=\"3aad\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">But don\u2019t take it to the extreme. Sometimes you\u2019re better off writing a new class instead of including masses of dependencies for the sake of DRY (don\u2019t repeat yourself).<\/p>\n<h3 id=\"ea6a\" class=\"nx md gq bf me ny nz hr mh oa ob hu mk hv oc hx mo hy od ia ms ib oe id mw of hn\"><span class=\"ez-toc-section\" id=\"The_fragile_base_class_problem\"><\/span>The fragile base class problem<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p id=\"f9e4\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">Imagine you\u2019ve successfully reused a class from another project for your new code. What h<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ens if the base class changes?<\/p>\n<p id=\"47b5\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">It can corrupt your entire code. You might not even have touched it. But one day your project works like a charm, the next day it doesn\u2019t because somebody changed a minor detail in the base class that ends up being crucial for your project.<\/p>\n<p id=\"2d08\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">The more you use inheritance, the more maintenance you potentially have to do. So even though reusing code seems very efficient in the short term, it can get costly in the long run.<\/p>\n<h3 id=\"1276\" class=\"nx md gq bf me ny nz hr mh oa ob hu mk hv oc hx mo hy od ia ms ib oe id mw of hn\"><span class=\"ez-toc-section\" id=\"The_diamond_problem\"><\/span>The diamond problem<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p id=\"c16b\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">Inheritance is this cute little thing where we can take properties of one class and transfer it to others. But what if you want to mix the properties of two different classes?<\/p>\n<p id=\"2a12\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Well, you can\u2019t do it. At least not in an elegant way. Consider for example the class<span>\u00a0<\/span><code>Copier<\/code>. (I borrowed this example, as well as some info about the problems presented here, from Charles Scalfani\u2019s<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/medium.com\/@cscalfani\/goodbye-object-oriented-programming-a59cda4c0e53\">viral story<\/a><span>\u00a0<\/span><em class=\"oj\">Goodbye, Object Oriented Programming<\/em>.) A copier scans the content of a document and prints it on an empty sheet. So should it be the subclass of<span>\u00a0<\/span><code>Scanner<\/code>, or of<span>\u00a0<\/span><code>Printer<\/code>?<\/p>\n<p id=\"b3f7\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">There simply is no good answer. And even though this problem isn\u2019t going to break your code, it comes up often enough to be frustrating.<\/p>\n<h3 id=\"32d4\" class=\"nx md gq bf me ny nz hr mh oa ob hu mk hv oc hx mo hy od ia ms ib oe id mw of hn\"><span class=\"ez-toc-section\" id=\"The_hierarchy_problem\"><\/span>The hierarchy problem<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p id=\"92c2\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">In the diamond problem, the question was which class<span>\u00a0<\/span><code>Copier<\/code><span>\u00a0<\/span>is a subclass of. But I lied to you \u2014 there is a neat solution. Let<span>\u00a0<\/span><code>Copier<\/code><span>\u00a0<\/span>be the parent class, and<span>\u00a0<\/span><code>Scanner<\/code><span>\u00a0<\/span>and<span>\u00a0<\/span><code>Printer<\/code><span>\u00a0<\/span>be subclasses that only inherit a subset of the properties. Problem fixed!<\/p>\n<p id=\"acf8\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">That\u2019s neat. But what if your<span>\u00a0<\/span><code>Copier<\/code><span>\u00a0<\/span>is only black-and-white, and your<span>\u00a0<\/span><code>Printer<\/code><span>\u00a0<\/span>can handle color, too? Isn\u2019t<span>\u00a0<\/span><code>Printer<\/code><span>\u00a0<\/span>in that sense a generalization of<span>\u00a0<\/span><code>Copier<\/code>? What if<span>\u00a0<\/span><code>Printer<\/code><span>\u00a0<\/span>is connected to WiFi, but<span>\u00a0<\/span><code>Copier<\/code><span>\u00a0<\/span>is not?<\/p>\n<p id=\"c9ea\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">The more properties you heap on a class, the more difficult it becomes to establish proper hierarchies. Really, you\u2019re dealing with clusters of properties, where<span>\u00a0<\/span><code>Copier<\/code><span>\u00a0<\/span>shares some, but not all properties of<span>\u00a0<\/span><code>Printer<\/code>, and vice versa. And if you try to stick that into hierarchies, and you have a big complex project, this might lead you to a messy disaster.<\/p>\n<h3 id=\"e964\" class=\"nx md gq bf me ny nz hr mh oa ob hu mk hv oc hx mo hy od ia ms ib oe id mw of hn\"><span class=\"ez-toc-section\" id=\"The_reference_problem\"><\/span>The reference problem<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p id=\"7bd8\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">You might say, alright, then we\u2019ll just do object-oriented programming without hierarchies. Instead, we could use clusters of properties, and inherit, extend, or override properties as needed. Sure, that would be a bit messy, but it would be an accurate representation of the problem at hand.<\/p>\n<p id=\"f716\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">There\u2019s just one problem. The whole point of encapsulation is to keep pieces of data safe from one another and thus make computing more efficient. This doesn\u2019t work without strict hierarchies.<\/p>\n<p id=\"89fc\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Consider what happens if an object<span>\u00a0<\/span><code>A<\/code><span>\u00a0<\/span>overrides the hierarchy by interacting with another object<span>\u00a0<\/span><code>B<\/code>. It doesn\u2019t matter what relationship<span>\u00a0<\/span><code>A<\/code><span>\u00a0<\/span>has with<span>\u00a0<\/span><code>B<\/code>, except that<span>\u00a0<\/span><code>B<\/code><span>\u00a0<\/span>is not the direct parent class. Then<span>\u00a0<\/span><code>A<\/code><span>\u00a0<\/span>must contain a private reference to<span>\u00a0<\/span><code>B<\/code>, because otherwise, it couldn\u2019t interact.<\/p>\n<p id=\"1678\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">But if<span>\u00a0<\/span><code>A<\/code><span>\u00a0<\/span>contains the information that the children of<span>\u00a0<\/span><code>B<\/code><span>\u00a0<\/span>also have, then that information can be modified in multiple places. Therefore, the information about<span>\u00a0<\/span><code>B<\/code><span>\u00a0<\/span>isn\u2019t safe anymore, and encapsulation is broken.<\/p>\n<p id=\"bf97\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Although many object-oriented programmers build programs with this kind of architecture, this isn\u2019t object-oriented programming. It\u2019s just a mess.<\/p>\n<h2 id=\"5337\" class=\"mc md gq bf me mf mg kl mh mi mj ko mk ml mm mn mo mp mq mr ms mt mu mv mw mx hn\"><span class=\"ez-toc-section\" id=\"The_danger_of_the_single_paradigm\"><\/span>The danger of the single paradigm<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p id=\"5f49\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">What these five problems have in common is that they implement inheritance where it\u2019s not the best solution. Since inheritance wasn\u2019t even included in the original form of object-oriented programming, I wouldn\u2019t call these problems inherent to object orientation. They\u2019re just examples of a dogma taken too far.<\/p>\n<p id=\"7991\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Not only object-oriented programming can be overdone, though. In pure<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/towardsdatascience.com\/want-to-get-started-in-functional-programming-enter-scala-ea71e5cfe5f8\">functional programming<\/a>, it\u2019s extremely difficult to process user input or print messages on a screen. Object-oriented or procedural programming is much better for these purposes.<\/p>\n<p id=\"eab8\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Still, there are developers who try to implement these things as pure functions and blow their code up to dozens of lines that nobody can understand. Using another paradigm, they could have easily reduced their code to a couple of readable lines.<\/p>\n<p id=\"6cf5\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Paradigms are a bit like religions. They\u2019re good in moderation \u2014 arguably, Jesus, Mohamed and Buddha said some pretty cool stuff. But if you follow them to the last little detail, you might end up making the lives of yourself and of people around you quite miserable.<\/p>\n<p id=\"2714\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">The same goes for programming paradigms. There\u2019s no doubt that functional programming is<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/towardsdatascience.com\/why-developers-are-falling-in-love-with-functional-programming-13514df4048e\">gaining traction<\/a>, whereas object-oriented programming has attracted some<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" class=\"el kg\" href=\"https:\/\/medium.com\/better-programming\/object-oriented-programming-the-trillion-dollar-disaster-92a4b666c7c7\">harsh criticism<\/a><span>\u00a0<\/span>in the last few years.<\/p>\n<p id=\"b66b\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">It makes sense to get informed about new programming paradigms and use them when appropriate. If object-oriented programming is the hammer that makes developers see nails wherever they go, is that a reason to throw the hammer out the window? No. You add a screwdriver to your toolbox, and maybe a knife or a pair of scissors, and you choose your tool based on the problem at hand.<\/p>\n<p id=\"585b\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">Functional and object-oriented programmers alike, stop treating your paradigms like a religion. They\u2019re tools, and they all have their use somewhere. What you use should only depend on what problems you are solving.<\/p>\n<h2 id=\"fd00\" class=\"mc md gq bf me mf mg kl mh mi mj ko mk ml mm mn mo mp mq mr ms mt mu mv mw mx hn\"><span class=\"ez-toc-section\" id=\"The_big_question_are_we_on_the_cusp_of_a_new_revolution\"><\/span>The big question: are we on the cusp of a new revolution?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p id=\"b927\" class=\"kh ki gq kj b hp my kl km hs mz ko kp kq na ks kt ku nb kw kx ky nc la lb lc gj hn\">At the end of the day, the \u2014 admittedly rather heated \u2014 debate of functional versus object-oriented programming boils down to this: could we be reaching the end of the era of object-oriented programming?<\/p>\n<p id=\"b1a5\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">More and more problems are coming up where functional programming is often the more efficient option. Think data analysis, machine learning, and parallel programming. The more you get into those fields, the more you\u2019ll love functional programming.<\/p>\n<p id=\"bd6d\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">But if you look at the status quo, there are a dozen offers for object-oriented programmers to one offer for functional coders. That doesn\u2019t mean you won\u2019t get a job if you prefer the latter; functional developers are still pretty scarce these days.<\/p>\n<p id=\"0477\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">The most likely scenario is that object-oriented programming will stay around for another decade or so. Sure, the avant-garde is functional, but that doesn\u2019t mean you should ditch object-oriented yet. It\u2019s still incredibly good to have in your repertoire.<\/p>\n<p id=\"0b13\" class=\"kh ki gq kj b hp kk kl km hs kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc gj hn\">So don\u2019t throw object-oriented programming out of your toolbox in the next few years. But make sure that it\u2019s not the only tool you have.<\/p>\n<div class=\"c-richText c-richText--large\"><em>This article was written by<span>\u00a0<\/span><span>Rhea Moutafis\u00a0<\/span>and was originally published on<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/towardsdatascience.com\/\">Towards Data Science<\/a>. You can read it<span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/towardsdatascience.com\/object-oriented-programming-is-dead-wait-really-db1f1f05cc44\">\u00a0here<\/a>.<\/span><\/em><\/p>\n<\/div>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong>\n<\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/thenextweb.com\/news\/object-oriented-programming-is-dead-syndication\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#Object-oriented programming is dead. Wait, really?&#8221; Programming in the 1960s had a big problem: computers weren\u2019t that powerful yet, and somehow they needed to\u00a0split the capacities\u00a0between data structures and procedures. This meant that if you had a large set of data, you couldn\u2019t do that much with it without pushing a computer to its limits&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":307138,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/img-cdn.tnwcdn.com\/image\/tnw?filter_last=1&fit=1280,640&url=https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/07\/dead.jpg&signature=1f6ecf2c87037910ee9abcfcef2eb9ca","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-307137","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/307137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=307137"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/307137\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/307138"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=307137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=307137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=307137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}