{"id":133,"date":"2019-11-10T23:38:14","date_gmt":"2019-11-10T23:38:14","guid":{"rendered":"http:\/\/erikscode.space\/?p=133"},"modified":"2019-11-10T23:40:40","modified_gmt":"2019-11-10T23:40:40","slug":"designing-public-interfaces-the-right-way","status":"publish","type":"post","link":"https:\/\/erikscode.space\/index.php\/2019\/11\/10\/designing-public-interfaces-the-right-way\/","title":{"rendered":"Designing Public Interfaces the Right Way"},"content":{"rendered":"\n<p>Interfaces define the ways objects interact with each other. Properly designing interfaces not only help conceptualize a system, but aid in testing and maintainability of our systems.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">What Are Interfaces?<\/h2>\n\n\n\n<p>This article is going to go beyond the concept of just using the principle of least privilege. We&#8217;re learning about this in the context of <strong>good design<\/strong> so you can write <strong>maintainable <\/strong>and <strong>testable<\/strong> code. The examples in this article are going to be in C# because I believe the syntax is optimal for explaining these concepts, but the concepts themselves transcend languages and apply to all OOP designs.<\/p>\n\n\n\n<p>For now, put aside the idea of <code>interface<\/code> as a programming language construct; right now we&#8217;re going to use it in its regular sense. An &#8220;interface&#8221; is the point in which two entities meet and interact. For example, your kitchen sink&#8217;s interface is the hot and cold handles plus the faucet.<\/p>\n\n\n\n<p>There are two entities: the sink and you. The sink provides a lot of functionality, but most of it is hidden from you. For example, you don&#8217;t need to know how the sink magically summons the water it spits out of the faucet; you don&#8217;t need to know how the sink is heating that water; and you definitely don&#8217;t need to know how the sink drains the water after it&#8217;s washed over your hands and dishes.<\/p>\n\n\n\n<p>All you need to know as a user of the sink is how to turn the water on and off, and which dial gives you what kind of water. You, the calling entity, don&#8217;t know the inner workings of the sink, the subject entity. To put this back into a programming point of view, the sink interface&#8217;s functional signature would take in the hot and cold dials as arguments and return water.<\/p>\n\n\n\n<p>Imagine if you had to know everything about plumbing just to wash your hands. Not only is this unrealistic, but it makes changing things nearly impossible. If the city implemented a new draining system, you&#8217;d have to relearn how that works before you can soak your dishes.<\/p>\n\n\n\n<p>Likewise, this is exactly what happens when you have objects that are too tightly coupled. The calling object that knows too much about its subject is like the plumber washing their hands. The <code>public<\/code> interface of an object needs to be simple, and needs to change as infrequently as possible.<\/p>\n\n\n\n<p>That last sentence is basically the main concept behind designing good interfaces: public interfaces should rarely, if ever, change.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Let&#8217;s Do an Example<\/h2>\n\n\n\n<p>Like I said at the beginning of this article, our examples will use the C# programming language. I think the syntax for objects and their interfaces is the best one to illustrate the necessary examples.<\/p>\n\n\n\n<p>We&#8217;re going to make a very simple command line RPG style fighting simulator. We&#8217;re going to have a <code>Hero<\/code> that attacks different types of <code>Enemies<\/code>. Let&#8217;s start by writing an abstract <code>Enemy<\/code> class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace PubPriExample2\n{\n    public abstract class Enemy\n    {\n        public string name { get; set; }\n        public int hitPoints { get; set; }\n        public int strength { get; set; }\n        public int defense { get; set; }\n        public bool alive { get; set; }\n\n        public Enemy(string enemyName, int hp, int str, int def)\n        {\n            name = enemyName;\n            hitPoints = hp;\n            strength = str;\n            defense = def;\n            alive = true;\n        }\n\n        public abstract void takeDamage(int attackDamage);\n        public abstract bool isAlive();\n        public abstract void die();\n    }\n}<\/code><\/pre>\n\n\n\n<p>What do we have here? This abstract class defines the base class for all enemies. Each enemy will have a name, hit points that represent how much damage it can take, strength which will control its attack damage, defense which controls how it takes damage, and a boolean variable called <code>alive<\/code> that will be set to false when the hit points fall below zero.<\/p>\n\n\n\n<p>We also have a few methods. Besides the constructor, we have <code>takeDamage<\/code>, <code>isAlive<\/code>, and <code>die<\/code>. These are methods that every enemy must have because it is the only thing we&#8217;ll do with enemies in this game. All enemies will be attacked, will be alive or dead, and do something when they die.<\/p>\n\n\n\n<p>Let&#8217;s make our <code>Hero<\/code> class. Most of this class will look like it should be extending the <code>Enemy<\/code> class, but we&#8217;re not going to do that. If this were to evolve as a full on RPG, <code>Hero<\/code> would probably also evolve into an abstract class used by multiple customizable heroes. For now, this class will just help us interact with the <code>Enemy<\/code> classes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\n\nnamespace PubPriExample2\n{\n    class Hero\n    {\n        public string name { get; set; }\n        public int hitPoints { get; set; }\n        public int strength { get; set; }\n        public int defense { get; set; }\n\n        public Hero(string heroName, int hp, int str, int def)\n        {\n            name = heroName;\n            hitPoints = hp;\n            strength = str;\n            defense = def;\n        }\n\n        public void attack(Enemy enemy)\n        {\n            Console.WriteLine(name + \" attacks \" + enemy.name);\n            enemy.takeDamage(strength);\n        }\n    }\n\n}<\/code><\/pre>\n\n\n\n<p>We haven&#8217;t made any <code>takeDamage<\/code> type methods for this class because to illustrate the points I&#8217;m trying to make, they are not necessary. The one thing I do want you to note here is that is that <code>attack<\/code> takes in an <code>Enemy<\/code> object, and uses the enemy&#8217;s <code>takeDamage<\/code> method to interact with it. Hence, the <code>takeDamage<\/code> method is <code>Hero<\/code>&#8216;s interface to <code>Enemy<\/code>.<\/p>\n\n\n\n<p>Let&#8217;s make a couple of concrete enemy classes. First, we&#8217;ll make <code>RegularEnemy<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\n\nnamespace PubPriExample2\n{\n    class RegularEnemy : Enemy\n    {\n        public RegularEnemy(string enemyName, int hp, int str, int def) : base(enemyName, hp, str, def)\n        {\n        }\n\n        public override void takeDamage(int heroStrength)\n        {\n            int damage = calculateDamage(heroStrength);\n            hitPoints -= damage;\n            Console.WriteLine(name + \" takes \" + damage + \" points of damage\");\n            if (isAlive()) die();\n        }\n\n        public override bool isAlive() => hitPoints > 0;\n\n        public override void die()\n        {\n            alive = false;\n            Console.WriteLine(name + \" has died!\");\n        }\n\n        private int calculateDamage(int attackStrength)\n        {\n            int damage = attackStrength - defense;\n            if (damage > 0)\n            {\n                return damage;\n            }\n            else\n            {\n                return 0;\n            }\n        }\n\n    }\n}\n<\/code><\/pre>\n\n\n\n<p><strong><em>NOTE:<\/em><\/strong><em> If the <\/em><code><em>=&gt;<\/em><\/code><em> syntax is throwing you off, don&#8217;t worry, it&#8217;s just some C# syntactic sugar. <\/em><code><em>public override bool isAlive() =&gt; hitPoints &gt; 0;<\/em><\/code><em> is exactly the same as<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public override bool isAlive()\n{\n    return hitPoints > 0;\n}<\/code><\/pre>\n\n\n\n<p>Here, we&#8217;ve overridden the base class&#8217;s abstract methods <code>takeDamage<\/code>, <code>isAlive<\/code>, and <code>die<\/code>. The one we&#8217;re going to pay attention to is the <code>takeDamage<\/code> method because, remember, it is the public interface at this moment.<\/p>\n\n\n\n<p>Why, if we have <code>takeDamage<\/code>, do we also have <code>calculateDamage<\/code>? Why can&#8217;t we put the logic for calculatign the damage in the <code>takeDamage<\/code> method? We could, but this is part of what we&#8217;re learning.<\/p>\n\n\n\n<p>First of all, calculating the damage within the same method in which we apply the damage would violate the <strong>Single Responsibility Principle<\/strong> of <strong>S<\/strong>OLID Object Oriented Design. We want each method to have a single responsibility, and the <code>takeDamage<\/code> method&#8217;s responsibility is applying damage, not calculating it.<\/p>\n\n\n\n<p>Secondly, <code>takeDamage<\/code> is the interface that the <code>Hero<\/code> class is going to use to interact with <code>Enemy<\/code>, so we want it to be relatively uniform across all <code>Enemy<\/code> sub types. We will make other enemies that can also be attacked, but will take damage in different ways. <code>calculateDamage<\/code> is therefore the private method that will do the sub-type-specific operations to figure out how much our hero has damaged the enemy.<\/p>\n\n\n\n<p>Speaking of, let&#8217;s make our second <code>Enemy<\/code> class, the <code>ArmoredEnemy<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\n\nnamespace PubPriExample2\n{\n    class ArmoredEnemy : Enemy\n    {\n        public ArmoredEnemy(string enemyName, int hp, int str, int def) : base(enemyName, hp, str, def)\n        {\n        }\n\n        public override void takeDamage(int heroStrength)\n        {\n            int damage = calculateDamage(heroStrength);\n            hitPoints -= damage;\n            Console.WriteLine(name + \" takes \" + damage + \" points of damage\");\n            if (!isAlive()) die();\n        }\n\n        public override bool isAlive() => hitPoints &lt; 0;\n\n        public override void die()\n        {\n            alive = false;\n            Console.WriteLine(name + \" has died; the armor shatters\");\n        }\n\n        private int calculateDamage(int attackStrength)\n        {\n            \/\/ Enemy has 20% change of deflecting the attack\n            Random random = new Random();\n            int deflect = random.Next(1, 6);\n            if (deflect == 1)\n            {\n                deflectAttack();\n                return 0;\n            }\n            else if ((attackStrength - defense) > 0)\n            {\n                return (attackStrength - defense);\n            }\n            else\n            {\n                return 0;\n            }\n        }\n\n        private void deflectAttack()\n        {\n            Console.WriteLine(name + \" deflects the attack!\");\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>Notice here that the <code>ArmoredEnemy<\/code> takes damage a different way. The enemy&#8217;s armor may deflect our hero&#8217;s attack, and thus the <code>calculateDamage<\/code> method essentially rolls the dice to find out if the attack was deflected or not.<\/p>\n\n\n\n<p>Now, let&#8217;s see some actual use of these methods:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\n\nnamespace PubPriExample2\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            Hero hero = new Hero(\"Erik\", 100, 10, 5);\n            RegularEnemy imp = new RegularEnemy(\"Imp\", 50, 3, 2);\n            ArmoredEnemy armorImp = new ArmoredEnemy(\"Armor Imp\", 30, 4, 4);\n\n            while (imp.alive)\n            {\n                hero.attack(imp);\n            }\n\n            while (armorImp.alive)\n            {\n                hero.attack(armorImp);\n            }\n\n            Console.ReadLine();\n        }\n\n    }\n}<\/code><\/pre>\n\n\n\n<p>Run this and you should get something similar to the following output:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Erik attacks Imp<br>Imp takes 8 points of damage<br>Erik attacks Imp<br>Imp takes 8 points of damage<br>Erik attacks Imp<br>&#8230;truncated<br>Imp takes 8 points of damage<br>Imp has died!<br>Erik attacks Armor Imp<br>Armor Imp deflects the attack!<br>Armor Imp takes 0 points of damage<br>&#8230; truncated<\/p><p>Erik attacks Armor Imp<br>Armor Imp deflects the attack!                                                                                          Armor Imp takes 0 points of damage                                                                                      Erik attacks Armor Imp                                                                                                  Armor Imp takes 6 points of damage                                                                                      &#8230;truncated<br>Erik attacks Armor Imp<br>Armor Imp takes 6 points of damage<br>Armor Imp has died; the armor shatters<\/p><\/blockquote>\n\n\n\n<p>Now consider we wanted to add even a third type of enemy, one that counterattacks. The code would mostly look the same, the new enemy would still have a <code>takeDamage<\/code> method, but there would also be a private method for implementing the counterattack. The interface for the enemy wouldn&#8217;t be any different, the hero can still only <code>attack<\/code>, but the implementation of that interface would be different, which would mean it should be hidden inside a private class of the new sub type.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When Things Change<\/h3>\n\n\n\n<p>What if we wanted to add deflection capabilities to our <code>RegularEnemy<\/code> class? Just because an enemy isn&#8217;t armored doesn&#8217;t mean it can&#8217;t deflect an attack, right? Right. So we want to add deflection capabilities to <code>RegularEnemy<\/code> but we want these enemies to have a 5% chance of deflecting rather than 20%.<\/p>\n\n\n\n<p>In theory, this new feature should not require <strong><em>any<\/em><\/strong> changes to our public interfaces. In fact, it doesn&#8217;t:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private int calculateDamage(int attackStrength)\n        {\n            \/\/ Enemy has 5% change of deflecting the attack\n            Random random = new Random();\n            int deflect = random.Next(1, 21);\n            if (deflect == 1)\n            {\n                deflectAttack();\n                return 0;\n            }\n            else if ((attackStrength - defense) > 0)\n            {\n                return (attackStrength - defense);\n            }\n            else\n            {\n                return 0;\n            }\n        }\n\n        private void deflectAttack()\n        {\n            Console.WriteLine(name + \" deflects the attack!\");\n        }<\/code><\/pre>\n\n\n\n<p>Nothing needed to change in order for this new feature to be added because we had a good separation of our public and private methods.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Interfaces Representing Roles<\/h2>\n\n\n\n<p>It&#8217;s kind of funny to have spent all this time talking about interfaces and not once using the keyword <code>interface<\/code> huh? Let&#8217;s go ahead and do that, but let&#8217;s think it through first.<\/p>\n\n\n\n<p>What is it about <code>Enemy<\/code> types that unify them? They all have stats and a name. They can also all be attacked, but in the context of a video game is that really a common trait? For example, consider a game like Zelda, where our hero Link can not only attack bad guys with his sword, but also grass and bushes. The grass and bushes don&#8217;t need stats like hit points and strength, but they&#8217;re still <strong><em>attackable<\/em><\/strong>.<\/p>\n\n\n\n<p>Attackable. That&#8217;s definitely not a real word, but it segues well into deciding when to use an abstract class vs when to use interfaces. Enemies are attackable. In Zelda, bushes are also attackable. So if we wanted to implement something similar in our game, like a tree our <code>Hero<\/code> could chop down with a sword, do we want the tree to extend the <code>Enemy<\/code> abstract class?<\/p>\n\n\n\n<p>Conceptually, no. We could, of course do it this way,  but making it work would look super shady. Likewise, any functionality we&#8217;d want to add to our sentient enemies would also get added to our non-sentient trees. In this case, trees and enemies don&#8217;t exactly share traits, but they do share roles. Specifically, they share the &#8220;attackable&#8221; role, which is what we&#8217;re going to name our interface. We&#8217;re going to name our interface <code>IAttackable<\/code> because that&#8217;s how you name interfaces in C#, sorry :shrug:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace PubPriExample2\n{\n    interface IAttackable\n    {\n        void takeDamage(int attackDamage);\n        bool isAlive();\n        void die();\n    }\n}<\/code><\/pre>\n\n\n\n<p>Now, head over to the <code>Enemy<\/code> abstract class to implement this interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace PubPriExample2\n{\n    public abstract class Enemy : IAttackable\n    {\n    \/\/ Truncated<\/code><\/pre>\n\n\n\n<p>What has this done for us? Haven&#8217;t we really just added some constraints on ourselves, forcing us to always write these three methods for any class implementing this interface?<\/p>\n\n\n\n<p>Well, yes. And trust me, I get it. It does look like a bit of unnecessary self-restraint, but try to look at it from a bigger picture. Imagine you&#8217;re developing this game and you decided you wanted to add <code>attackable<\/code> trees a few months after you finished the last <code>Enemy<\/code> sub type. Will you remember which methods you&#8217;ve been using for these objects? In this case, probably yes because it&#8217;s such a small project right now, but imagine the project grows to a couple thousand lines of code.<\/p>\n\n\n\n<p>Even better, imagine you are in a large company with multiple teams working on the game. Another team has been tasked with implementing trees that our <code>Hero<\/code> can cut down. Luckily, they already have this interface and know exactly how similar functionality has been added to the game before. It lets everything that is <code>attackable<\/code> in the game have the same interface.<\/p>\n\n\n\n<p>Finally, it gives us a little something we might neglect. It helps us understand the system better. Think about <code>RegularEnemy<\/code> and <code>ArmoredEnemy<\/code> and how they both extend the <code>Enemy<\/code> class. Any time we look at a class, regardless of its name, if we see that it extends <code>Enemy<\/code>, we know that this is something the player will fight with.<\/p>\n\n\n\n<p>Likewise, for any class implementing the <code>Attackable<\/code> interface, we will know it takes damage from the <code>Hero<\/code>. This example might make this benefit seem inconsequential, but in large systems with business processes less easy to conceptualize, this benefit can go a long way. The programmer&#8217;s main job is managing complexity, and things like proper naming and good interface design help us do that.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Note on Testability<\/h2>\n\n\n\n<p>We&#8217;ve learned that public interfaces should rarely change, and private ones are the real workhorses of classes. You might think then that the private methods of a class are the ones that need to be tested the most, but the opposite is true.<\/p>\n\n\n\n<p>Private methods cannot be implemented by other classes, and the nuggets of functionality they provide are really just in support of their public methods. Therefore, thoroughly testing a class&#8217;s <strong>public<\/strong> interface essentially tests its private methods as well.<\/p>\n\n\n\n<p>Similarly, as we&#8217;ve already learned, public interfaces should not change much. That means that testing of them should also not change very frequently, except when new functionality is added that changes the object&#8217;s behavior. For example, our <code>ArmoredEnemy<\/code> class implemented two private methods when taking damage. Testing the public <code>takeDamage<\/code> tests both methods satisfactorily. If we added even a third private method to the <code>takeDamage<\/code> method, we may need to change a few expected values here and there in our tests, but ultimately, test maintenance should be very low.<\/p>\n\n\n\n<p>So not only does the proper design of interfaces help us conceptualize our systems better, it also helps cut down on maintenance costs while our tests still give us the same level of confidence they always have.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>Today we learned a little bit about good object oriented design. We learned that public interfaces, not necessarily <code>interface<\/code> methods, are designed to be stable. Keeping these methods constant and hiding complexity in private methods gives us the ability to add or modify functionality almost at a whim. These concepts give us simple public interfaces and help our test suite stay maintainable and effective.<\/p>\n\n\n\n<p>For further reading, I strongly suggest checking out Sandi Metz&#8217;s book, <a href=\"http:\/\/www.informit.com\/store\/practical-object-oriented-design-an-agile-primer-using-9780134456478?ranMID=24808\">Practical Object-Oriented Design: An Agile Primer Using Ruby<\/a>. She does a much better job at explaining this concept in chapter 4. The rest of the book is excellent as well. No this isn&#8217;t an affiliate link, I really think this book is worth reading if you&#8217;re interested in good software design.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Interfaces define the ways objects interact with each other. Properly designing interfaces not only help conceptualize a system, but aid in testing and maintainability of our systems.<\/p>\n","protected":false},"author":1,"featured_media":139,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[21],"tags":[13,22,24,25,26],"class_list":["post-133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-design","tag-c","tag-csharp","tag-object-oriented","tag-oop","tag-software-design"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2019\/11\/kelly-sikkema-ECxsxbjAmMY-unsplash.jpg?fit=1987%2C3000&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pb90KY-29","jetpack-related-posts":[{"id":232,"url":"https:\/\/erikscode.space\/index.php\/2020\/04\/20\/5-great-programming-books-rarely-mentioned-in-great-programming-books-articles\/","url_meta":{"origin":133,"position":0},"title":"5 Great Programming Books Rarely Mentioned in &#8220;Great Programming Books&#8221; Articles","author":"erik","date":"April 20, 2020","format":false,"excerpt":"Originally posted on dev.to If you search something like \"programming books\" or \"books developers should read\" you will get a lot of articles listing the same 5 or 6 books. In this article, I want to bring to your attention some stellar books on coding that don't get the love\u2026","rel":"","context":"In &quot;Book Reviews and Suggested Reading&quot;","block_context":{"text":"Book Reviews and Suggested Reading","link":"https:\/\/erikscode.space\/index.php\/category\/suggested-reading\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":222,"url":"https:\/\/erikscode.space\/index.php\/2020\/04\/14\/why-you-shouldnt-learn-c\/","url_meta":{"origin":133,"position":1},"title":"Why You Shouldn&#8217;t Learn C","author":"erik","date":"April 14, 2020","format":false,"excerpt":"Knowledge of the C programming language is often touted as the mark of a \"true\" programmer. You don't really know programming unless you know this language, or so the wisdom goes. Many aspiring programmers have been advised by gatekeepers senior developers to learn C to up their skills and bring\u2026","rel":"","context":"In &quot;C\/C++&quot;","block_context":{"text":"C\/C++","link":"https:\/\/erikscode.space\/index.php\/category\/language-specific\/c-c\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/04\/phil-hearing-YbT8wrbPMug-unsplash-scaled.jpg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/04\/phil-hearing-YbT8wrbPMug-unsplash-scaled.jpg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/04\/phil-hearing-YbT8wrbPMug-unsplash-scaled.jpg?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/04\/phil-hearing-YbT8wrbPMug-unsplash-scaled.jpg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/04\/phil-hearing-YbT8wrbPMug-unsplash-scaled.jpg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1768,"url":"https:\/\/erikscode.space\/index.php\/2023\/09\/26\/an-introduction-to-software-architecture\/","url_meta":{"origin":133,"position":2},"title":"An Introduction to Software Architecture","author":"erik","date":"September 26, 2023","format":false,"excerpt":"Software architecture is the concept of how a software project is structured; a holistic view of the entire system including class hierarchies, interface design, even deployment patterns. A system\u2019s architecture impacts nearly every facet of interaction with that system, from end users to the developers that build and maintain it.\u2026","rel":"","context":"In &quot;Architecture&quot;","block_context":{"text":"Architecture","link":"https:\/\/erikscode.space\/index.php\/category\/software-design\/architecture\/"},"img":{"alt_text":"floor plan on table","src":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2023\/09\/pexels-photo-834892.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2023\/09\/pexels-photo-834892.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2023\/09\/pexels-photo-834892.jpeg?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2023\/09\/pexels-photo-834892.jpeg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2023\/09\/pexels-photo-834892.jpeg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":545,"url":"https:\/\/erikscode.space\/index.php\/2022\/05\/07\/updates-and-small-changes-to-erikscode-space\/","url_meta":{"origin":133,"position":3},"title":"Updates and Small Changes to eriksCode.space","author":"erik","date":"May 7, 2022","format":false,"excerpt":"There will be one small change to the content of this blog. Read on! Up until now, this blog has been almost all how-to articles dedicated to teaching concepts the average programmer might need to know in their day-to-day work, but might not have been taught at their university or\u2026","rel":"","context":"In &quot;Learning&quot;","block_context":{"text":"Learning","link":"https:\/\/erikscode.space\/index.php\/category\/learning\/"},"img":{"alt_text":"time for change sign with led light","src":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2022\/05\/pexels-photo-2277784.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2022\/05\/pexels-photo-2277784.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2022\/05\/pexels-photo-2277784.jpeg?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2022\/05\/pexels-photo-2277784.jpeg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2022\/05\/pexels-photo-2277784.jpeg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":275,"url":"https:\/\/erikscode.space\/index.php\/2020\/08\/02\/delegate-and-decorate-in-python-part-2-the-decorator-pattern\/","url_meta":{"origin":133,"position":4},"title":"Delegate and Decorate in Python: Part 2 &#8211; The Decorator Pattern","author":"erik","date":"August 2, 2020","format":false,"excerpt":"Note: This is not about Python's language feature called decorators (with the @ symbol), but about the design patterns called \"decorator\" and \"delegate.\" In the previous article, we learned how to implement the Delegation pattern in Python. With this knowledge, we'll now learn about the Decorator pattern, which will make\u2026","rel":"","context":"In &quot;Patterns&quot;","block_context":{"text":"Patterns","link":"https:\/\/erikscode.space\/index.php\/category\/software-design\/patterns\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/08\/snake.jpg?fit=410%2C386&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":269,"url":"https:\/\/erikscode.space\/index.php\/2020\/08\/01\/delegate-and-decorate-in-python-part-1-the-delegation-pattern\/","url_meta":{"origin":133,"position":5},"title":"Delegate and Decorate in Python: Part 1 &#8211; The Delegation Pattern","author":"erik","date":"August 1, 2020","format":false,"excerpt":"Note: This is not about Python's language feature called decorators (with the @ symbol), but about the design patterns called \"decorator\" and \"delegate.\" In this series we're going to learn two very useful design patterns: the delegation pattern and the decorator pattern. Each pattern is useful in that they help\u2026","rel":"","context":"In &quot;Language Specific&quot;","block_context":{"text":"Language Specific","link":"https:\/\/erikscode.space\/index.php\/category\/language-specific\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/08\/pexels-egor-kamelev-922521-scaled.jpg?fit=1200%2C984&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/08\/pexels-egor-kamelev-922521-scaled.jpg?fit=1200%2C984&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/08\/pexels-egor-kamelev-922521-scaled.jpg?fit=1200%2C984&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/08\/pexels-egor-kamelev-922521-scaled.jpg?fit=1200%2C984&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/erikscode.space\/wp-content\/uploads\/2020\/08\/pexels-egor-kamelev-922521-scaled.jpg?fit=1200%2C984&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":0,"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/media\/139"}],"wp:attachment":[{"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/erikscode.space\/index.php\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}