<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator><link href="https://isiroca.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://isiroca.github.io/" rel="alternate" type="text/html" /><updated>2019-05-20T22:17:24+00:00</updated><id>https://isiroca.github.io/feed.xml</id><title type="html">IR</title><subtitle>Software Development</subtitle><author><name>Isi Roca</name></author><entry><title type="html">Docker</title><link href="https://isiroca.github.io/posts/docker/" rel="alternate" type="text/html" title="Docker" /><published>2018-10-11T00:00:00+00:00</published><updated>2018-08-11T13:06:00+00:00</updated><id>https://isiroca.github.io/posts/docker</id><content type="html" xml:base="https://isiroca.github.io/posts/docker/">&lt;h1 id=&quot;general-command-of-docker&quot;&gt;General Command of Docker&lt;/h1&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# create volume&lt;/span&gt;
docker volume create myvol

&lt;span class=&quot;c1&quot;&gt;# pull image from cloud/hub&lt;/span&gt;
docker pull &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;user]/image

&lt;span class=&quot;c1&quot;&gt;# build docker image tagged by -t with dockerfile in directory &lt;/span&gt;
docker build -t myimage &lt;span class=&quot;s2&quot;&gt;&quot;X:\MyDirWithDockerfile\&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# run iterativelly with tty /bin/bash as root user using docker image as container&lt;/span&gt;
docker run -it &lt;span class=&quot;s2&quot;&gt;&quot;myimagename or myimageid&quot;&lt;/span&gt; /bin/bash
&lt;span class=&quot;c1&quot;&gt;## example: docker run interactive image adc7e1e17105 with /bin/bash&lt;/span&gt;
docker run -it adc7e1e17105 /bin/bash

&lt;span class=&quot;c1&quot;&gt;# to resume after exit:&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## first check id with&lt;/span&gt;
docker &lt;span class=&quot;nb&quot;&gt;ps&lt;/span&gt; -a
&lt;span class=&quot;c1&quot;&gt;## then use &quot;id&quot; to resume without &quot;&quot; &lt;/span&gt;
docker &lt;span class=&quot;nb&quot;&gt;start&lt;/span&gt; -a -i &lt;span class=&quot;s2&quot;&gt;&quot;id&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# issue when doing: RUN ...build.sh&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## solution based on (https://github.com/docker/for-win/issues/1166) is to:&lt;/span&gt;
before RUN ...build.sh, add a:
RUN chmod +x ...build.sh

&lt;span class=&quot;c1&quot;&gt;# pushing image to cloud&lt;/span&gt;
docker login
docker tag myimage &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;user]/myimage
docker push &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;user]/myimage
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;docker-specifics-about-run&quot;&gt;Docker Specifics About Run&lt;/h1&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;c1&quot;&gt;# docker run /bin/bash in myimage &lt;/span&gt;
docker run -it myimage /bin/bash

&lt;span class=&quot;c1&quot;&gt;## ... as user myuser  &lt;/span&gt;
docker run -it -u myuser myimage /bin/bash

&lt;span class=&quot;c1&quot;&gt;## ... with volume myvolume in ...&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;### ... /home/myvolume&lt;/span&gt;
docker run -it -u myuser -v myvolume:/home/myvolume
&lt;span class=&quot;c1&quot;&gt;### ... /myvolume&lt;/span&gt;
docker run -it -v myvolume:/myvolume

&lt;span class=&quot;c1&quot;&gt;# connect to already run myimage&lt;/span&gt;
docker &lt;span class=&quot;nb&quot;&gt;start&lt;/span&gt; -ia &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;ps&lt;/span&gt; -a | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;myimage | awk &lt;span class=&quot;s1&quot;&gt;'{print $1;}'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;docker-specifics-about-removal&quot;&gt;Docker Specifics About Removal&lt;/h1&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;c1&quot;&gt;# remove containers manually&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## first get id of our containers (docker container ls - do not work somehow...)&lt;/span&gt;
docker &lt;span class=&quot;nb&quot;&gt;ps&lt;/span&gt; -a
&lt;span class=&quot;c1&quot;&gt;## now remove by our id (without &quot;&quot;)&lt;/span&gt;
docker &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;id&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# docker remove all containers&lt;/span&gt;
docker &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;ps&lt;/span&gt; -a -q&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# remove first from specific containers with mycontainer word in name&lt;/span&gt;
 docker &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;ps&lt;/span&gt; -a | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;mycontainer | awk &lt;span class=&quot;s1&quot;&gt;'{print $1;}'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# remove images with &amp;lt;none&amp;gt; name and force it (usually remove all images -.-)&lt;/span&gt;
docker rmi &lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;docker images -f &lt;span class=&quot;s2&quot;&gt;&quot;dangling=true&quot;&lt;/span&gt; -q&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt; -f
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Isi Roca</name></author><summary type="html">Docker settings, management and usage...</summary></entry><entry><title type="html">Solid Principles</title><link href="https://isiroca.github.io/posts/solid-principles/" rel="alternate" type="text/html" title="Solid Principles" /><published>2018-09-11T00:00:00+00:00</published><updated>2018-07-11T13:06:00+00:00</updated><id>https://isiroca.github.io/posts/solid-principles</id><content type="html" xml:base="https://isiroca.github.io/posts/solid-principles/">&lt;h1 id=&quot;solid-principles&quot;&gt;Solid Principles&lt;/h1&gt;

&lt;p&gt;SOLID is one of the most popular sets of design principles when doing OOD (Object Oriented Design). 
SOLID principles can also form a core philosophy for methodologies such as agile development or adaptive software development.&lt;/p&gt;

&lt;p&gt;The intention of these principles is to make software designs more understandable, easier to maintain and easier to extend.&lt;/p&gt;

&lt;p&gt;It’s a mnemonic acronym for the following five design principles:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Single Responsibility Principle&lt;/li&gt;
  &lt;li&gt;Open/Closed Principle&lt;/li&gt;
  &lt;li&gt;Liskov Substitution Principle&lt;/li&gt;
  &lt;li&gt;Interface Segregation Principle&lt;/li&gt;
  &lt;li&gt;Dependency Inversion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These 5 principles were introduced by Robert C. Martin (Uncle Bob), in his 2000 paper &lt;a href=&quot;https://web.archive.org/web/20150906155800/http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf&quot;&gt;Design Principles and Design Patterns&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;ssingle-responsibility-principlesrp&quot;&gt;S — Single Responsibility Principle(S.R.P)&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;“A class should have one, and only one, reason to change.”
Martin, Robert C. (2003). Agile Software Development, Principles, Patterns, and Practices. Prentice Hall. p. 95. ISBN 978-0135974445.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;
&lt;h3 id=&quot;benefits&quot;&gt;Benefits&lt;/h3&gt;
&lt;p&gt;It makes your software easier to implement and prevents unexpected side-effects of future changes.&lt;/p&gt;

&lt;h3 id=&quot;concepts&quot;&gt;Concepts&lt;/h3&gt;

&lt;p&gt;A module, class, or function should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;We have a class named Book.
We use a method called formatJson() to return the book as a JSON string.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Book&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
 
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getBook&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
 
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;formatJson&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;json_encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we want to change the output of the JSON string, or add another type of output to the class, we would need to alter the class to either add another method or change an existing method to suit.&lt;/p&gt;

&lt;p&gt;How can we solve it so that it complies with the Single Responsibility Principle?.&lt;/p&gt;

&lt;p&gt;We create a secondary class called JsonPageFormatter that is used to format the Page objects into JSON.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Book&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
 
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getBook&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
 
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;JsonPageFormatter&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;json_encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Doing this means that if we wanted to create an XML format we could just add a class called XmlPageFormatter and write some simple code to output XML.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;It is one of the basic principles most developers apply to build robust and maintainable software. You can not only apply it to classes, but also to software components and microservices.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;oopen-closed-principle&quot;&gt;O — Open-Closed Principle&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification”
Meyer, Bertrand (1988). Object-Oriented Software Construction. Prentice Hall. ISBN 0-13-629049-3.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;benefits-1&quot;&gt;Benefits&lt;/h3&gt;

&lt;p&gt;It promotes the use of interfaces to enable you to adapt the functionality of your application without changing the existing code.&lt;/p&gt;

&lt;p&gt;If we could follow this principle strongly enough, it is possible to then modify the behavior of our code without ever touching a piece of original code.&lt;/p&gt;

&lt;h3 id=&quot;concepts-1&quot;&gt;Concepts&lt;/h3&gt;

&lt;p&gt;We can make sure that our code is compliant with the open/closed principle by utilizing inheritance and/or implementing interfaces that enable classes to polymorphically substitute for each other.&lt;/p&gt;

&lt;p&gt;This simply means that a class should be easily extendable without modifying the class itself.&lt;/p&gt;

&lt;p&gt;We should always try to add new code instead of changing existing code.&lt;/p&gt;

&lt;h3 id=&quot;example&quot;&gt;Example&lt;/h3&gt;

&lt;p&gt;We have two different books and handle them with a switch case. 
Based on the type variable in the array we load in the correct book class to then echo the correct visual name.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ScienceBook&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Science'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$bookTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$bookDescription&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getbookTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; 
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;bookTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getBookDescription&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; 
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;bookDescription&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FictionBook&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Fiction'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$authorName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getAuthorName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;authorName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AllBooks&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$books&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$books&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Science'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getFirstName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;' '&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getLastName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Fiction'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAuthorName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we add a third book type then we would also need to change the existing switch case and thus break this principle.&lt;/p&gt;

&lt;p&gt;How can we solve it so that it complies with the Open-Closed Principle?.&lt;/p&gt;

&lt;p&gt;We created an interface which we use to extend each of the Book types. If we now add a third type, then we have no reason to change any existing code. We just add new code to add new functionality.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ScienceBook&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;bookTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;bookDescription&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;bookTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;' '&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;bookDescription&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FictionBook&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$authorName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; 
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;authorName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AllBooks&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$books&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; 
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$books&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$book&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;lliskov-substitution-principle&quot;&gt;L — Liskov Substitution Principle&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Let Φ(x) be a property provable about objects x of type T. Then Φ(y) should be true for objects y of type S where S is a subtype of T.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;benefits-2&quot;&gt;Benefits&lt;/h3&gt;

&lt;p&gt;The behavior of your classes becomes more important than its structure.&lt;/p&gt;

&lt;h3 id=&quot;concepts-2&quot;&gt;Concepts&lt;/h3&gt;

&lt;p&gt;The Liskov Substitution principle was introduced by &lt;a href=&quot;https://en.wikipedia.org/wiki/Barbara_Liskov&quot;&gt;Barbara Liskov&lt;/a&gt; in her conference keynote &lt;a href=&quot;https://doi.org/10.1145%2F62139.62141&quot;&gt;Data abstraction and hierarchy&lt;/a&gt; in 1987.&lt;/p&gt;

&lt;p&gt;Liskov Substitution Principle extends the Open/Closed Principle by focusing on the behavior of a superclass and its subtypes.&lt;/p&gt;

&lt;p&gt;The principle defines that objects of a superclass shall be replaceable with objects of its subclasses without breaking the application. That requires the objects of your subclasses to behave in the same way as the objects of your superclass.&lt;/p&gt;

&lt;p&gt;An overridden method of a subclass needs to accept the same input parameter values as the method of the superclass. That means you can implement less restrictive validation rules, but you are not allowed to enforce stricter ones in your subclass.&lt;/p&gt;

&lt;h3 id=&quot;examples-1&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;In this example we extend Square from Rectangle. The difference between a square and rectangle is that a square its sides are always the same size. So if we set height or width we need to change both height and width.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Rectangle&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setHeight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;height&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setWidth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;width&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Square&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Rectangle&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setHeight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;height&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;width&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setWidth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;height&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;width&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A solution to this example is to have an Abstract class where both will have different setters to calculate the sides and we have one general function which calculates the area.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;abstract&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AbstractShape&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;abstract&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Area&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Rectangle&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;AbstractShape&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setHeight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;height&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setWidth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;width&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Area&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;height&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Square&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;AbstractShape&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$sideLength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setSideLength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$sideLength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sideLength&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$sideLength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Area&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;int&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sideLength&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sideLength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;iinterface-segregation-principle&quot;&gt;I — Interface Segregation Principle&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Clients should not be forced to depend upon interfaces that they do not use.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;benefits-3&quot;&gt;Benefits&lt;/h3&gt;

&lt;p&gt;You can apply these principles also to microservices.&lt;/p&gt;

&lt;h3 id=&quot;concepts-3&quot;&gt;Concepts&lt;/h3&gt;

&lt;p&gt;The goal of the Interface Segregation Principle is to reduce the side effects and frequency of required changes by splitting the software into multiple, independent parts.&lt;/p&gt;

&lt;h3 id=&quot;examples-2&quot;&gt;Examples&lt;/h3&gt;

&lt;p&gt;We have an interface Book. We implement an Paper class. Then we have a problem, because an Paper is a book, but it can’t be download.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;download&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Ebook&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;download&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Paper&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;download&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;/* exception */&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We should solve this by creating a separate interface for digital books and paper books.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;DigitalBook&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;download&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;PaperBook&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;buy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Ebook&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;DigitalBook&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;download&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Paper&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;PaperBook&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;buy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;ddependency-inversion-principle&quot;&gt;D — Dependency Inversion Principle&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;High-level modules should not depend on low-level modules. Both should depend on abstractions.
Abstractions should not depend on details. Details should depend on abstractions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;benefits-4&quot;&gt;Benefits&lt;/h3&gt;

&lt;p&gt;Decouple your code from its direct dependencies.&lt;/p&gt;

&lt;h3 id=&quot;concepts-4&quot;&gt;Concepts&lt;/h3&gt;

&lt;p&gt;We have high level modules and low level modules. In simplest terms the high level modules are the ones we call directly and do all the high level business logic. Low level modules are classes that help our high level modules, this can be inserting data to a database or printing a date in the correct format.&lt;/p&gt;

&lt;p&gt;High-level modules, which provide complex logic, should be easily reusable and unaffected by changes in low-level modules, which provide utility features. To achieve that, you need to introduce an abstraction that decouples the high-level and low-level modules from each other.&lt;/p&gt;

&lt;p&gt;An important detail of this definition is, that high-level and low-level modules depend on the abstraction.&lt;/p&gt;

&lt;h3 id=&quot;examples-3&quot;&gt;Examples&lt;/h3&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Adapter&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Mysql&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Adapter&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'data from database'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Controller&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$adapter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Mysql&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$mysql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;adapter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$mysql&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;adapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In this example we can only pass an object of the database type.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Adapter&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Mysql&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Adapter&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'data from database'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Controller&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$adapter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__construct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Adapter&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$adapter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;adapter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$adapter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;adapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we can pass whatever implementation we want based on our Adapter interface.&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/SOLID&quot;&gt;SOLID&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Single_responsibility_principle&quot;&gt;Single responsibility principle&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Open-closed_principle&quot;&gt;Open-closed principle&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Liskov_substitution_principle&quot;&gt;Liskov_substitution_principle&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Robert C. Martin, &lt;a href=&quot;https://web.archive.org/web/20151128004108/http://www.objectmentor.com/resources/articles/lsp.pdf&quot;&gt;The Liskov Substitution Principle&lt;/a&gt;, C++ Report, March 1996&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Interface_segregation_principle&quot;&gt;Interface segregation principle&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Dependency_inversion_principle&quot;&gt;Dependency inversion principle&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Isi Roca</name></author><summary type="html">About the five Solid Principles.</summary></entry><entry><title type="html">Design Patterns</title><link href="https://isiroca.github.io/posts/patterns/" rel="alternate" type="text/html" title="Design Patterns" /><published>2018-08-11T00:00:00+00:00</published><updated>2018-09-11T13:06:00+00:00</updated><id>https://isiroca.github.io/posts/design-patterns</id><content type="html" xml:base="https://isiroca.github.io/posts/patterns/">&lt;h1 id=&quot;design-patterns&quot;&gt;Design Patterns&lt;/h1&gt;

&lt;h2 id=&quot;about-design-patterns&quot;&gt;About Design Patterns&lt;/h2&gt;

&lt;p&gt;Design Patterns are optimized, reusable solutions to the programming problems that we encounter every day. 
A design pattern is a description, or template, for how to solve a problem that can be used in many different situations. It’s not language-specific. A good design pattern should be implementable in most if not all languages, depending on the capabilities of the language.&lt;/p&gt;

&lt;p&gt;There are three basic kinds of design patterns:
Creational
Abstract Factory, Builder, Factory Method, Object Pool, Prototype, Singleton.&lt;/p&gt;

&lt;p&gt;Structural
Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy.&lt;/p&gt;

&lt;p&gt;Behavioral
Chain of responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template method, Visitor.&lt;/p&gt;

&lt;p&gt;Generally, the three groups above define how your program elements relate to each other, how they get created, and how they communicate with each other.&lt;/p&gt;

&lt;p&gt;Why use them?
Design patterns are well-thought out solutions to programming problems. Let’s draw a parallel with a real-world example.
Suppose you are standing at the base of a mountain and have been given the task of reaching its top by the end of the day. Assuming that you are unaware of the available routes to the mountain top, what will you do? Of course, you will start to climb up as per your own understanding. Your lack of knowledge about the right route makes it extremely difficult for you to decide the best possible route.
If somebody gives you a detailed map along with all possible routes, including the pros and cons of each, then you will be in a much better position to begin your journey and choose the right route.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Simply put a design pattern is a proven solution to solve design problems&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;singleton-design-pattern&quot;&gt;Singleton Design Pattern&lt;/h2&gt;

&lt;p&gt;Singleton is a creational design pattern, which ensures that only one instance of a class is created.&lt;/p&gt;

&lt;p&gt;Singleton may be used when:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;you need access to a shared resource.&lt;/li&gt;
  &lt;li&gt;access to a shared resource will be requested from multiple, separate parts of your program.&lt;/li&gt;
  &lt;li&gt;only one object can be instantiated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good example is a Logger, which is used in every part of the system to log some information. For example, in a social network, every activity of a user should be logged (login, logout, comment, posts, likes).
Instead of instantiating a new Logger instance over and over again for each activity type, it would be better to have a single instance and access it when needed. In other words, it is better to use the same Logger instance to log user logins, logouts, comments, posts, and likes, when necessary.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Singletons are intended to be used when a class must have exactly one instance, no more, no less.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;factory-method-design-pattern&quot;&gt;Factory Method Design Pattern&lt;/h2&gt;

&lt;p&gt;Factory Method is a creational pattern that defines an interface for creating an object, but lets subclasses decide which class to instantiate.&lt;/p&gt;

&lt;p&gt;The best time to use the factory method pattern is when you have multiple variations of a single entity. For example, let’s consider a program that creates different shapes. For this program, we need to define a ShapeFactory that will act as a common interface for creating shapes. Using this interface, each subclass will create the specific shape by implementing the ShapeFactory’s corresponding “create” method.&lt;/p&gt;

&lt;p&gt;To better understand the Factory Method concept, consider a real-world employment agency. The agency helps clients fill positions for their company. The client provides the hiring criteria and then leaves the details of assessing candidates to the agency. The hiring agency takes care of a potential candidate’s eligibility, skill, and experience verification to ensure that the candidate matches the hiring criteria. In this case, the hiring agency acts as the factory. It allows the client to create new objects without having to know the details of how they’re created.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;We create objects without exposing the creation logic to the client and refer to newly created objects using a common interface (employment agency).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The factory method pattern relies on inheritance, as object creation is delegated to subclasses that implement the factory method to create objects.&lt;/p&gt;

&lt;p&gt;The Factory Method is usually used when creating frameworks, which standardize the architectural model for a range of applications, but allow for individual applications to define their own objects and their instantiation.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;A Factory is a creator of objects that have a common interface.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;abstract-factory-design-pattern&quot;&gt;Abstract Factory Design Pattern&lt;/h2&gt;

&lt;p&gt;The Abstract Factory is a creational pattern, similar to the Factory Method pattern, with the key difference being that the Abstract Factory provides an interface for creating families of related or dependent objects without specifying their concrete classes.&lt;/p&gt;

&lt;p&gt;Often, designs start out using Factory Method and evolve toward Abstract Factory as more flexibility is needed.&lt;/p&gt;

&lt;p&gt;Imagine an application needs to run on different operating systems. In order to achieve this, we need to encapsulate the dependencies of our application. One approach is to have a “factory” object that has the responsibility of providing creation services for the entire platform family. Each time we need a new object for our application, we use the factory.
   This makes a class independent of how its objects are created (which concrete classes are instantiated).&lt;/p&gt;

&lt;p&gt;Consider a “factory” to create UI elements. The same factory can create buttons, textboxes, windows, and other elements for two operating systems - Windows and MacOS.
   When we want to create a new button, we do not instantiate a new button class for a particular operating system. Instead, we request the factory create a button, and the factory does so, considering the parameters of the operating system. The same applies for any other UI object. As a result, we get the object we need without getting into detail of how the objects are created.&lt;/p&gt;

&lt;p&gt;Basically, the Abstract Factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Because the service provided by the factory object is so pervasive, it is routinely implemented as a Singleton.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;builder-design-pattern&quot;&gt;Builder Design Pattern&lt;/h2&gt;

&lt;p&gt;The Builder design pattern is a creational pattern that separates the construction of a complex object from its representation. By doing so, the same construction process can create different representations.
   Simply said, it builds a complex object using simple objects and a step-by-step approach.&lt;/p&gt;

&lt;p&gt;For example, let’s say we need to build cars. Each car has many options. The combination of options would lead to a huge list of constructors for the Car class. To avoid this, we will create a builder class, CarBuilder. We will send each option step by step to the CarBuilder and then construct the final car with the correct options.
   This approach makes it flexible to add and remove options from the car.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Sometimes creational patterns are complementary: Builder can use one of the other patterns to implement which components are built.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;object-pool-pattern&quot;&gt;Object Pool Pattern&lt;/h2&gt;

&lt;p&gt;The Object Pool design pattern is useful when it is necessary to work with a large number of objects that are particularly expensive to instantiate, especially if each object is only needed for a short period of time.&lt;/p&gt;

&lt;p&gt;Instead of creating and destroying the expensive objects, the object pool pattern suggests reusing the already created objects.&lt;/p&gt;

&lt;p&gt;When a new object is needed, it is requested from the pool. If a previously prepared object is available it is returned immediately, avoiding the instantiation cost. If no objects are present in the pool, a new item is created and returned. When the object has been used and is no longer needed, it is returned to the pool, allowing it to be used again in the future without repeating the expensive instantiation process.&lt;/p&gt;

&lt;p&gt;For example, the Object Pool design pattern is used in the .NET Framework Data Provider for SQL Server. As SQL Server database connections can be slow to create, a pool of connections is maintained. When you close a connection, the connection is held in a pool from which it can be retrieved when requesting a new connection. This substantially increases the speed of making connections.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Object Pools are usually implemented as Singletons.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;prototype-design-pattern&quot;&gt;Prototype Design Pattern&lt;/h2&gt;

&lt;p&gt;The Prototype design pattern is a creational pattern that uses a prototype to create new objects by copying this prototype. In other words, instead of creating new objects, we clone them from the prototype.&lt;/p&gt;

&lt;p&gt;The pattern is used when object creation is resource expensive. By cloning new objects, we avoid the inherent cost of creating a new object in the standard way.&lt;/p&gt;

&lt;p&gt;Mitotic cell division, which results in two identical cells, is an example of the Prototype pattern. When a cell splits, two cells of identical genotype result. In other words, the cell clones itself.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Prototype is unique among the other creational patterns as it doesn’t require a class - only an object.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;adapter-design-pattern&quot;&gt;Adapter Design Pattern&lt;/h2&gt;

&lt;p&gt;The Adapter pattern is a structural design pattern that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code.&lt;/p&gt;

&lt;p&gt;For example, let’s consider you have an old class that implements some functionality needed in your new project. However, the way it is written is not compatible with the philosophy and architecture of the system currently being developed. In order to use the old class without rewriting the whole functionality from scratch, we can create an adapter, also called a wrapper, that translates, or maps, the old component to the new system.
   Your program will then call the wrapper, which will redirect to the corresponding methods in the old class.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The key idea in this pattern is to work through a separate Adapter that adapts the interface of an already existing class without changing it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;bridge-design-pattern&quot;&gt;Bridge Design Pattern&lt;/h2&gt;

&lt;p&gt;The Bridge pattern is designed to separate the abstraction from the implementations so they can be used and changed independently.&lt;/p&gt;

&lt;p&gt;Let’s look at an example to understand when this is useful and what this “confusing” definition means.
   Say you need to create a shape drawing application that should work on both Windows and MacOS.&lt;/p&gt;

&lt;p&gt;You could create a Shape interface, inherit from it the types of the shapes, like Rectangle or Circle, and then inherit from those to create the OS-specific implementations.
   The class hierarchy would look like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/design_patterns/20190517_122228.png&quot; alt=&quot;alt text&quot; title=&quot;Bridge Design Pattern&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, consider that you need to support more shape types and more OSes. That would lead to a significant number of classes being added - the number of types multiplied by the number of OS versions.&lt;/p&gt;

&lt;p&gt;So, basically, to support five shape types on three different OSes, you would need to write 5*3=15 implementations.&lt;/p&gt;

&lt;p&gt;However, the Bridge pattern suggests refactoring this into two separate hierarchies - one for platform-independent abstractions (Shapes), and the other for platform-dependent implementations (OSes).
   Here is the refactored diagram:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/design_patterns/20190517_122126.png&quot; alt=&quot;alt text&quot; title=&quot;Bridge Design Pattern&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The relationship between Shape and ShapeImplementation is the Bridge.&lt;/p&gt;

&lt;p&gt;This pattern is used in situations where it would be best to isolate the handling of the system-dependent stuff from the handling of the system-independent stuf&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The Bridge pattern is often confused with the Adapter pattern.
  Adapter makes things work after they’re designed;&lt;br /&gt;
  Bridge is designed up-front to let the abstraction and the implementation vary independently. Further, Adapter is retrofitted to make unrelated classes work together.
  In other words, an adapter is a patch. A bridge is put in place on purpose.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;composite-design-pattern&quot;&gt;Composite Design Pattern&lt;/h2&gt;

&lt;p&gt;The Composite pattern describes a group of objects that is treated the same way as a single instance of the same type of object.&lt;/p&gt;

&lt;p&gt;Composite should be used when clients ignore the difference between compositions of objects and individual objects.&lt;/p&gt;

&lt;p&gt;For example, when dealing with tree-structured data, programmers often must discriminate between a leaf-node and a branch. This makes code more complex, and therefore, more error-prone. 
   The solution is an interface that allows treating complex and primitive objects uniformly. 
   Other examples are menus that contain menu items, each of which could be a menu. Directories that contain files, each of which could be a directory.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The key concept is that you can manipulate a single instance of the object just as you would manipulate a group of them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;decorator-design-pattern&quot;&gt;Decorator Design Pattern&lt;/h2&gt;

&lt;p&gt;The Decorator design pattern allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.&lt;/p&gt;

&lt;p&gt;This is achieved by designing a new Decorator class that wraps the original class. This pattern is designed so that multiple decorators can be stacked on top of each other, each adding a new functionality.&lt;/p&gt;

&lt;p&gt;The goal is to make it so that the extended behavior can be applied to one specific instance, and, at the same time, still be able to create an original instance that doesn’t have the new behavior.&lt;/p&gt;

&lt;p&gt;This pattern is an alternative to subclassing, which refers to creating a class that inherits functionality from a parent class. As opposed to subclassing, which adds the behavior at compile time, “decorating” allows you to add new behavior during runtime, if the situation calls for it.&lt;/p&gt;

&lt;p&gt;For example, consider a window in a windowing system. Assume windows are represented by instances of the Window class, and assume this class has no functionality for adding scrollbars. 
   We could create a subclass ScrollingWindow that provides them, or create a ScrollingWindowDecorator that adds this functionality to existing Window objects. At this point, either solution would be fine.&lt;/p&gt;

&lt;p&gt;Now, assume one also desires the ability to add borders to windows. If we had used subclassing, then we have a problem, as we will need to create separate subclasses with the borders functionality for all possible types of windows.
   With the decorator solution, we simply create a new BorderedWindowDecorator and decorate any window we need during runtime.&lt;/p&gt;

&lt;p&gt;So, using decorator, we have the ability to add scrollbars and/or borders to any of our Windows objects.&lt;/p&gt;

&lt;p&gt;Notice that if the functionality needs to be added to all Windows, you could modify the base class and that will do. However, sometimes (e.g., when using external frameworks) it is not possible, legal, or convenient to modify the base class.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The I/O Streams implementations of both Java and the .NET Framework follow the decorator pattern by extending the base subclass to add features to the stream classes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;facade&quot;&gt;Facade&lt;/h2&gt;

&lt;p&gt;The Facade design pattern provides a unified interface to a set of interfaces in a subsystem, thus making a complex subsystem easier to use.&lt;/p&gt;

&lt;p&gt;A facade is an object that provides a simplified interface to a larger body of code, such as a class library.
    A facade can:
    - make a software library easier to use, understand, and test, since the facade has convenient methods for common tasks,
    - make the library more readable,
    - wrap a poorly designed collection of APIs with a single well-designed API.&lt;/p&gt;

&lt;p&gt;The Facade design pattern is often used when a system is very complex or difficult to understand because the system has a large number of interdependent classes or its source code is unavailable. This pattern hides the complexities of the larger system and provides a simpler interface to the client. It typically involves a single wrapper class that contains a set of members required by the client. These members access the system on behalf of the facade client and hide the implementation details.&lt;/p&gt;

&lt;p&gt;The $ in jQuery, which provides a simple interface to common operations, is an example of the Facade design pattern.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Adapter and Facade are both wrappers, but they are different kinds of wrappers. The intent of Facade is to produce a simpler interface, and the intent of Adapter is to design to an existing interface.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;flyweight-design-pattern&quot;&gt;Flyweight Design Pattern&lt;/h2&gt;

&lt;p&gt;The Flyweight design pattern efficiently supports a large number of objects.
   A flyweight is an object that minimizes memory usage by sharing as much data as possible with other similar objects; it is a way to use objects in large numbers when a simple repeated representation would use an unacceptable amount of memory.&lt;/p&gt;

&lt;p&gt;For example, when representing large text documents, creating an object for each character in the document would result in a huge number of objects that couldn’t be processed efficiently. Instead, for every character there might be a reference to a flyweight glyph object shared by every instance of the same character in the document; only the position of each character in the document would need to be stored internally.&lt;/p&gt;

&lt;p&gt;As another example, modern web browsers use this technique to prevent loading the same images twice. When a browser loads a web page, it traverses through all images on that page. The browser loads all new images and places them in the internal cache. For already loaded images, a flyweight object is created, which has some unique data-like position within the page, but the image itself is referenced from the cache.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;To enable safe sharing between clients and threads, Flyweight objects must be immutable. 
  Flyweight objects are by definition value objects. The identity of the object instance is of no consequence; therefore, two Flyweight instances of the same value are considered equal.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;proxy-design-pattern&quot;&gt;Proxy Design Pattern&lt;/h2&gt;

&lt;p&gt;The Proxy design pattern provides a placeholder for another object to control access to it.&lt;/p&gt;

&lt;p&gt;A proxy is a class functioning as an interface to something else, such as a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate.
   A proxy acts as a wrapper object that is being called by the client to access the real serving object behind the scenes. For the client, usage of a proxy object is similar to using the real object, because both implement the same interface.&lt;/p&gt;

&lt;p&gt;Possible Usage Scenarios
   Remote Proxy
   In distributed object communication, a local object represents a remote object. The local object is a proxy for the remote object, and method invocation on the local object results in remote method invocation on the remote object. An example would be an ATM implementation, where the ATM might hold proxy objects for bank information that exists in the remote server.&lt;/p&gt;

&lt;p&gt;Virtual Proxy
   In place of a complex or heavy object, a skeleton representation may be advantageous in some cases. When an underlying image is huge in size, it may be represented using a virtual proxy object, loading the real object on demand.&lt;/p&gt;

&lt;p&gt;Protection Proxy
   A protection proxy might be used to control access to a resource based on access rights.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;A proxy can:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;hide information about the real object from the client.&lt;/li&gt;
    &lt;li&gt;perform optimization like on-demand loading.&lt;/li&gt;
    &lt;li&gt;do additional housekeeping jobs like audit tasks.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;</content><author><name>Isi Roca</name></author><summary type="html">About main Design Patterns in Software.</summary></entry><entry><title type="html">Technical Books</title><link href="https://isiroca.github.io/posts/technical-books/" rel="alternate" type="text/html" title="Technical Books" /><published>2018-07-11T00:00:00+00:00</published><updated>2018-07-11T08:00:00+00:00</updated><id>https://isiroca.github.io/posts/tech-books</id><content type="html" xml:base="https://isiroca.github.io/posts/technical-books/">&lt;h1 id=&quot;technical-books&quot;&gt;Technical Books&lt;/h1&gt;

&lt;blockquote&gt;
  &lt;p&gt;Alice: Would you tell me, please, which way I ought to go from here?. 
 The Cheshire Cat: That depends a good deal on where you want to get to. 
 Alice: I don’t much care where. 
 The Cheshire Cat: Then it doesn’t much matter which way you go. 
 Alice: …So long as I get somewhere. 
 The Cheshire Cat: Oh, you’re sure to do that, if only you walk long enough. 
 (Alice’s Adventures in Wonderland - Lewis Carroll)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A books library for programmers.&lt;/p&gt;

&lt;p&gt;The goal of this library is to make you a more proficient developer. 
You’ll find books that have become timeless classics or I’ve found truly inspiring.&lt;/p&gt;

&lt;p&gt;This page is not meant to be comprehensive. The selection of books is opinionated.&lt;/p&gt;

&lt;p&gt;Contributing to this book library. Feel free to open a PR to contribute! Thanks.&lt;/p&gt;

&lt;h2 id=&quot;agile&quot;&gt;Agile&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Agile Software Development, Principles, Patterns, and Practices (by Robert C. Martin)&lt;/li&gt;
  &lt;li&gt;Practices of an Agile Developer: Working in the Real World (by Venkat Subramaniam)&lt;/li&gt;
  &lt;li&gt;Agile Principles, Patterns, and Practices in C# (Robert C. Martin Series)&lt;/li&gt;
  &lt;li&gt;The Scrum Field Guide: Agile Advice for Your First Year and Beyond (by Mitch Lacey)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;algorithms&quot;&gt;Algorithms&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;The Art of Computer Programming (by Donald Knuth)&lt;/li&gt;
  &lt;li&gt;Introduction to algorithms (by Cormen &amp;amp; Leiserson &amp;amp; Rivest &amp;amp; Stein)&lt;/li&gt;
  &lt;li&gt;Algorithms + Data Structures = Programs (by Niklaus Wirth)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;apis&quot;&gt;APIs&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Build APIs You Won’t Hate (by Phil Sturgeon)&lt;/li&gt;
  &lt;li&gt;Hands-On RESTful API Design Patterns and Best Practices: Design, Develop, and Deploy Highly Adaptable, Scalable, and Secure RESTful Web APIs (by Harihara Subramanian &amp;amp; Pethuru Raj)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;architecture&quot;&gt;Architecture&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Clean Architecture: A Craftsman’s Guide to Software Structure and Design (by Robert C. Martin)&lt;/li&gt;
  &lt;li&gt;Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems (by Martin Kleppmann)&lt;/li&gt;
  &lt;li&gt;Software Architect’s Handbook: Become a Successful Software Architect by Implementing Effective Architecture Concepts (by Joseph Ingeno)&lt;/li&gt;
  &lt;li&gt;Cracking the IT Architect Interview (by Sameer Paradkar)&lt;/li&gt;
  &lt;li&gt;Software Architecture Patterns (by Mark Richards)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;aws&quot;&gt;AWS&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;AWS Certified Solutions Architect (by Joe, Hisham, Tim, Biff, Kevin, John and Sean)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;best-practices&quot;&gt;Best Practices&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Clean Code: A Handbook of Agile Software Craftsmanship (by Robert Martin)&lt;/li&gt;
  &lt;li&gt;The Clean Coder: A Code of Conduct for Professional Programmers (by Robert Martin)&lt;/li&gt;
  &lt;li&gt;The Pragmatic Programmer (by Andrew Hunt)&lt;/li&gt;
  &lt;li&gt;Adaptive Code: Agile coding with design patterns and SOLID principles (by Gary McLean Hall)&lt;/li&gt;
  &lt;li&gt;Code Complete 2 (by Steve McConnell)&lt;/li&gt;
  &lt;li&gt;Foundations of Programming (by Karl Seguin)&lt;/li&gt;
  &lt;li&gt;The Art of Readable Code: Simple and Practical Techniques for Writing Better Code (by Dustin Boswell &amp;amp; Trevor Foucher)&lt;/li&gt;
  &lt;li&gt;A Philosophy of Software Design (by John Ousterhout)&lt;/li&gt;
  &lt;li&gt;Structure and Interpretation of Computer Programs (by Harold Abelson)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;c&quot;&gt;C&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;The C Programming Language (by Brian W. Kernighan &amp;amp; Dennis Ritchie)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;continuous-delivery&quot;&gt;Continuous Delivery&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation (by Jez Humble &amp;amp; David Farley)&lt;/li&gt;
  &lt;li&gt;Continuous Delivery Handbook : Non Programmer’s Guide to DevOps, Microservices and Kubernetes (by Stephen Fleming)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;continuous-integration&quot;&gt;Continuous Integration&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Continuous Integration: Improving Software Quality and Reducing Risk (by Paul M. Duvall)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;databases&quot;&gt;Databases&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;MySQL High Availability (by Charles Bell, Mats Kindahl &amp;amp; Lars Thalmann)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;ddd&quot;&gt;DDD&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Domain-Driven Design (by Eric Evans)&lt;/li&gt;
  &lt;li&gt;Domain-Driven Design (by Vaughn Vernon)&lt;/li&gt;
  &lt;li&gt;Domain-Driven Design: Tackling Complexity in the Heart of Software (by Eric Evans)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;devops&quot;&gt;DevOps&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;The DevOps Handbook: How to Create World-Class Agility, Reliability, and Security in Technology Organizations (by Gene Kim &amp;amp; Patrick Debois &amp;amp; John Willis, Jez Humble, John Allspaw)&lt;/li&gt;
  &lt;li&gt;Ansible for Devops: Everything You Need to Know to Use Ansible for Devops (by David Johnson)&lt;/li&gt;
  &lt;li&gt;DevOps with Kubernetes (by Hideto Saito &amp;amp; Hui-Chuan Chloe Lee &amp;amp; Cheng-Yang Wu)&lt;/li&gt;
  &lt;li&gt;Implementing Modern DevOps: Enabling IT organizations to deliver faster and smarter (by David Gonzalez)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;design-patterns&quot;&gt;Design Patterns&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Head First Design Patterns (by Elisabeth Freeman and Kathy Sierra)&lt;/li&gt;
  &lt;li&gt;Software Architecture Patterns (by Mark Richards)&lt;/li&gt;
  &lt;li&gt;Design Patterns: Elements of Reusable Object-Oriented Software (by ErichGamma, RichardHelm, RalphJohnson, and JohnVlissides, The GangOfFour)&lt;/li&gt;
  &lt;li&gt;Design Patterns in C# (by Steve Metsker)&lt;/li&gt;
  &lt;li&gt;Patterns of Enterprise Application Architecture (by Martin Fowler)&lt;/li&gt;
  &lt;li&gt;Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions (by Martin Fowler)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;docker&quot;&gt;Docker&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Docker Cookbook: Over 100 Practical and Insightful Recipes to Build Distributed Applications With Docker , 2nd Edition (by Ken Cochrane)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;java&quot;&gt;Java&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Java All In One (by Doug Lowe)&lt;/li&gt;
  &lt;li&gt;Effective Java (by Joshua Bloch)&lt;/li&gt;
  &lt;li&gt;Thinking in Java (by Bruce Eckel)&lt;/li&gt;
  &lt;li&gt;Think Data Structures: Algorithms and Information Retrieval in Java (by Allen Downey)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;javascript&quot;&gt;JavaScript&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;JavaScript: The Good Parts (by Douglas Crockford)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;laravel&quot;&gt;Laravel&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Laravel Code Bright (by Dayle Rees)&lt;/li&gt;
  &lt;li&gt;Laravel From Apprentice to Artisan (by Taylor Otwell)&lt;/li&gt;
  &lt;li&gt;Laravel Testing Decoded (by Jeffrey Way)&lt;/li&gt;
  &lt;li&gt;Laravel Design Patterns (by Arda)&lt;/li&gt;
  &lt;li&gt;Laravel Cookbook (by Christopher Pitt and Taylor Otwell)&lt;/li&gt;
  &lt;li&gt;Implementing Laravel (by Chris Fidao)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;machine-learning&quot;&gt;Machine Learning&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Machine Learning Algorithms (by Giuseppe Bonaccorso)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;management&quot;&gt;Management&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;The Manager’s Path (by Camille Fournier)&lt;/li&gt;
  &lt;li&gt;The Mythical Man-Month: Essays on Software Engineering (by Frederick P. Brooks Jr.)&lt;/li&gt;
  &lt;li&gt;Peopleware: Productive Projects and Teams (by Tom DeMarco &amp;amp; Timothy Lister)&lt;/li&gt;
  &lt;li&gt;The Deadline: A Novel About Project Management (by Tom DeMarco)&lt;/li&gt;
  &lt;li&gt;Software Estimation: Demystifying the Black Art (by Steve McConnell)&lt;/li&gt;
  &lt;li&gt;Unite the Tribes: Leadership Skills for Technology Managers (by Christopher Duncan)&lt;/li&gt;
  &lt;li&gt;Notes to a Software Team Leader (by Roy Osherove)&lt;/li&gt;
  &lt;li&gt;Making Things Happen: Mastering Project Management (by Scott Berkun)&lt;/li&gt;
  &lt;li&gt;Confessions of an Unintentional CTO: Lessons in Growing a Web App (by Jack Kinsella)&lt;/li&gt;
  &lt;li&gt;Practical Change Management for IT Projects (by Emily Carr)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;mathematics&quot;&gt;Mathematics&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Mathematical Foundations of Nature-Inspired Algorithms (by Xin-She Yang &amp;amp; Xing-Shi He)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;microservices&quot;&gt;Microservices&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Building Microservices (by Sam Newman)&lt;/li&gt;
  &lt;li&gt;PHP Microservices. Transit from monolithic architectures to highly available, scalable, and fault-tolerant microservices (by Carlos Perez Sanchez &amp;amp; Pablo Solar Vilarino)&lt;/li&gt;
  &lt;li&gt;Advanced Microservices: A Hands-On Approach to Microservice Infrastructure and Tooling (by Thomas Hunter Ii)&lt;/li&gt;
  &lt;li&gt;Microservices AntiPatterns and Pitfalls (by Mark Richards)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;php&quot;&gt;PHP&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Modern PHP (by Josh Lockhart)&lt;/li&gt;
  &lt;li&gt;Scaling PHP Apps (by Steve Corona)&lt;/li&gt;
  &lt;li&gt;Modular Programming with PHP 7 (by Branko Ajzele)&lt;/li&gt;
  &lt;li&gt;PHP the right way (by Josh Lockhart and the PHP community)&lt;/li&gt;
  &lt;li&gt;Mastering PHP Design Patterns (by Junade Ali)&lt;/li&gt;
  &lt;li&gt;DDD in PHP (by Carlos Buenosvinos)&lt;/li&gt;
  &lt;li&gt;PHP 7 Data Structures and Algorithms: Implement Linked Lists, Stacks, and Queues Using PHP (by Mizanur Rahman)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;python&quot;&gt;Python&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Python: Master the Art of Design Patterns (by Dusty Phillips)&lt;/li&gt;
  &lt;li&gt;Test-Driven Development With Python: Obey the Testing Goat: Using Django, Selenium, and JavaScript (by Harry J. W. Percival)&lt;/li&gt;
  &lt;li&gt;Python Data Structures and Algorithm. Improve the performance and speed of your applications (by Benjamin Baka)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;refactoring&quot;&gt;Refactoring&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Working Effectively with Legacy Code (by Michael Feathers)&lt;/li&gt;
  &lt;li&gt;Refactoring: Improving the Design of Existing Code (by Martin Fowler)&lt;/li&gt;
  &lt;li&gt;Software Design X-Rays: Fix Technical Debt with Behavioral Code Analysis (by Adam Tornhill)&lt;/li&gt;
  &lt;li&gt;Refactoring to Patterns (by Joshua Kerievsky)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;symfony&quot;&gt;Symfony&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;A Year With Symfony: Writing healthy, reusable Symfony2 code (by Matthias Noback)&lt;/li&gt;
  &lt;li&gt;Symfony Framework Deep Dive - Security (by Joshua Thijssen)&lt;/li&gt;
  &lt;li&gt;Mastering Symfony (by Sohail Salehi)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;soft-skills&quot;&gt;Soft Skills&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Soft Skills: The software developer’s life manual (by John Z. Sonmez)&lt;/li&gt;
  &lt;li&gt;The Phoenix Project (by Gene Kim, Kevin Behr and Kim Spafford)&lt;/li&gt;
  &lt;li&gt;Grokking Algorithms: An illustrated guide for programmers and other curious people (by Aditya Bhargava)&lt;/li&gt;
  &lt;li&gt;97 Things Every Programmer Should Know: Collective Wisdom from the Experts (by Kevlin Henney)&lt;/li&gt;
  &lt;li&gt;Code Simplicity: The Fundamentals of Software (by Max Kanat-Alexander)&lt;/li&gt;
  &lt;li&gt;Cracking the Coding Interview (by Gayle Laakmann McDowell)&lt;/li&gt;
  &lt;li&gt;Coders at Work: Reflections on the Craft of Programming (by Peter Seibel)&lt;/li&gt;
  &lt;li&gt;The Practice of Programming (by Brian W. Kernighan &amp;amp; Rob Pike)&lt;/li&gt;
  &lt;li&gt;Facts and Fallacies of Software Engineering (by Robert Glass)&lt;/li&gt;
  &lt;li&gt;The Passionate Programmer: Creating a Remarkable Career in Software Development (by Chad Fowler)&lt;/li&gt;
  &lt;li&gt;The Self-Taught Programmer: The Definitive Guide to Programming Professionally (by Cory Althoff)&lt;/li&gt;
  &lt;li&gt;The Problem With Software: Why Smart Engineers Write Bad Code (by Adam Barr)&lt;/li&gt;
  &lt;li&gt;The Full Stack Developer: Your Essential Guide to the Everyday Skills Expected of a Modern Full Stack Web Developer (by Chris Northwood)&lt;/li&gt;
  &lt;li&gt;The Best Software Writing I: Selected and Introduced (by Avram Joel Spolsky)&lt;/li&gt;
  &lt;li&gt;Joel on Software (by Avram Joel Spolsky)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;tdd&quot;&gt;TDD&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Test Driven Development: By Example (by Kent Beck)&lt;/li&gt;
  &lt;li&gt;Growing Object-Oriented Software, Guided by Tests (by Steve Freeman &amp;amp; Nat Pryce)&lt;/li&gt;
  &lt;li&gt;ATDD by Example: A Practical Guide to Acceptance Test-Driven Development (by Markus Gärtner)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;uxui&quot;&gt;UX/UI&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Don’t Make Me Think, Revisited: A Common Sense Approach to Web Usability (by Steve Krug)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;related-tech-books&quot;&gt;Related Tech Books&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Dilbert’s Guide to the Rest of Your Life: Dispatches from Cubicleland (by Scott Adams)&lt;/li&gt;
  &lt;li&gt;The Computational Beauty of Nature: Computer Explorations of Fractals, Chaos, Complex Systems, and Adaptation (by Gary William Flake)&lt;/li&gt;
  &lt;li&gt;Nine Algorithms That Changed the Future: The Ingenious Ideas That Drive Today’s Computers (by John MacCormick &amp;amp; Chris Bishop)&lt;/li&gt;
  &lt;li&gt;Technopoly (by Neil Postman)&lt;/li&gt;
  &lt;li&gt;Developer Hegemony (by Erik Dietrich)&lt;/li&gt;
  &lt;li&gt;Gödel, Escher, Bach: An Eternal Golden Braid (by Douglas Hofstadter)&lt;/li&gt;
  &lt;li&gt;World Without Mind (by Franklin Foer)&lt;/li&gt;
  &lt;li&gt;Algorithms of Oppression. How Search Engines Reinforce Racism (by Safiya Umoja Noble)&lt;/li&gt;
  &lt;li&gt;Weapons Of Math Destruction (by Cathy O’neil)&lt;/li&gt;
  &lt;li&gt;Automating Inequality: How High-Tech Tools Profile, Police, and Punish the Poor (by Virginia Eubanks)&lt;/li&gt;
  &lt;li&gt;Modern Monopolies: What It Takes to Dominate the 21st Century Economy (by Nicholas L. Johnson)&lt;/li&gt;
  &lt;li&gt;The Four: The Hidden DNA of Amazon, Apple, Facebook and Google (by Scott Galloway)&lt;/li&gt;
  &lt;li&gt;Ten Arguments for Deleting Your Social Media Accounts Right Now (by Jaron Lanier)&lt;/li&gt;
  &lt;li&gt;Who Owns the Future? (by Jaron Lanier)&lt;/li&gt;
  &lt;li&gt;You Are Not a Gadget: A Manifesto (by Jaron Lanier)&lt;/li&gt;
  &lt;li&gt;To Save Everything, Click Here: The Folly of Technological Solutionism (by Evgeny Morozov)&lt;/li&gt;
  &lt;li&gt;The Net Delusion: The Dark Side of Internet Freedom (by Evgeny Morozov)&lt;/li&gt;
  &lt;li&gt;The Filter Bubble: What The Internet Is Hiding From You (by Eli Pariser)&lt;/li&gt;
  &lt;li&gt;Technoutopia: How optimism ruined the internet (by Alex Warren)&lt;/li&gt;
  &lt;li&gt;What Algorithms Want: Imagination in the Age of Computing (by Ed Finn)&lt;/li&gt;
  &lt;li&gt;The Shallows: What the Internet Is Doing to Our Brains (by Nicholas Carr)&lt;/li&gt;
  &lt;li&gt;The Glass Cage: Automation and Us (by Nicholas Carr)&lt;/li&gt;
  &lt;li&gt;Utopia Is Creepy: and Other Provocations (by Nicholas Carr)&lt;/li&gt;
  &lt;li&gt;Superintelligence: Paths, Dangers, Strategies (by Nick Bostrom)&lt;/li&gt;
  &lt;li&gt;L’humanité augmentée. L’administration numérique du monde (by Eric Sadin)&lt;/li&gt;
  &lt;li&gt;La vie algorithmique. Critique de la raison numérique (by Eric Sadin)&lt;/li&gt;
  &lt;li&gt;Los dueños de internet: Cómo nos dominan los gigantes de la tecnología y qué hacer para cambiarlo (by Natalia Zuazo)&lt;/li&gt;
  &lt;li&gt;Guerras de internet: Un viaje al centro de la red para entender cómo afecta tu vida (by Natalia Zuazo)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;not-only-tech&quot;&gt;Not Only Tech&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Homo Deus: A Brief History of Tomorrow (by Yuval Noah Harari)&lt;/li&gt;
  &lt;li&gt;21 Lessons for the 21st Century (by Yuval Noah Harari)&lt;/li&gt;
  &lt;li&gt;Liquid Surveillance: A Conversation (by Zygmunt Bauman &amp;amp; David Lyon)&lt;/li&gt;
  &lt;li&gt;Liquid Modernity (by Zygmunt Bauman)&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Isi Roca</name></author><summary type="html">Technical Books Recopilation.</summary></entry></feed>