{"id":6,"date":"2009-09-30T06:01:29","date_gmt":"2009-09-30T05:01:29","guid":{"rendered":"http:\/\/www.michaelokarimia.com\/blog\/?p=6"},"modified":"2012-06-04T13:23:32","modified_gmt":"2012-06-04T12:23:32","slug":"tutorial-part-one","status":"publish","type":"post","link":"https:\/\/www.michaelokarimia.com\/blog\/2009\/09\/30\/tutorial-part-one\/","title":{"rendered":"Command Pattern Tutorial: Part One"},"content":{"rendered":"<p style=\"text-align: left;\">When designing software, effective use of design patterns can simplify your design, save you time and produce results more quickly.<\/p>\n<p style=\"text-align: left;\">In the following posts I will be demonstrating the implementation of one the Gang of Four&#8217;s frequently used patterns, The Command Pattern.<\/p>\n<p style=\"text-align: left;\">The final result will be a web application which the user will be able to experiment with, written in C# .NET 3.5<\/p>\n<p style=\"text-align: left;\">To start,\u00c2\u00a0 let&#8217;s look at the <a href=\"http:\/\/en.wikipedia.org\/w\/index.php?title=Command_pattern&amp;oldid=312457817\" target=\"_blank\">Wikipedia&#8217;s definition<\/a> of the Command Pattern:<\/p>\n<blockquote style=\"text-align: left;\"><p>an object is used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.<\/p>\n<p>Three terms always associated with the command pattern are <em>client<\/em>, <em>invoker<\/em> and <em>receiver<\/em>. The <em>client<\/em> instantiates the command object and provides the information required to call the method at a later time. The <em>invoker<\/em> decides when the method should be called. The <em>receiver<\/em> is an instance of the class that contains the method&#8217;s code.<\/p><\/blockquote>\n<p style=\"text-align: left;\">As I&#8217;ve based this project on an\u00c2\u00a0 example in the excellent book <a href=\"http:\/\/www.amazon.co.uk\/gp\/product\/0596007124\/ref=as_li_ss_tl?ie=UTF8&#038;tag=michaokaricom-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0596007124\" target=\"_blank\">Head First Design Patterns<\/a><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.assoc-amazon.co.uk\/e\/ir?t=michaokaricom-21&#038;l=as2&#038;o=2&#038;a=0596007124\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" style=\"border:none !important; margin:0px !important;\" \/>, I&#8217;ve included its definition of this pattern below:<\/p>\n<blockquote style=\"text-align: left;\"><p>Encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests and support undo-able operations.<\/p><\/blockquote>\n<p style=\"text-align: left;\">In UML this pattern is defined as:<\/p>\n<p style=\"text-align: left;\">\n<div id=\"attachment_33\" style=\"width: 567px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-33\" class=\"size-full wp-image-33 \" title=\"Command Design Pattern Class Diagram\" src=\"http:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/Command_Design_Pattern_Class_Diagram.png\" alt=\"Command Design Pattern Class Diagram\" width=\"557\" height=\"353\" srcset=\"https:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/Command_Design_Pattern_Class_Diagram.png 557w, https:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/Command_Design_Pattern_Class_Diagram-300x190.png 300w\" sizes=\"auto, (max-width: 557px) 100vw, 557px\" \/><p id=\"caption-attachment-33\" class=\"wp-caption-text\">Command Design Pattern Class Diagram<\/p><\/div>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">Now we have a definition of the pattern, I will explain the project brief.<\/p>\n<p style=\"text-align: left;\">The idea is to code an API for a Home Automation system, operated by a hand-held remote control. The Remote Control will be able to control any household appliance through a simple interface; seven pairs of on\/off buttons, plus an undo button. Each pair of on\/off buttons will allow one particular command to be activated and deactivated. As the pair of on\/off buttons have to correspond with the same command, I will from now on refer to them as a &#8220;command slot&#8221;. The Remote Control has seven command slots. The appliances will be likely to change in the future with new features added to them.\u00c2\u00a0 Additionally,\u00c2\u00a0 new appliances may be added to the house. The changes in the appliances should not cause us to change code in the remote control.<\/p>\n<p style=\"text-align: left;\">The user will be able to add and remove the command in each command slot during run time.<\/p>\n<p style=\"text-align: left;\">The undo button will undo the last  action performed.<\/p>\n<p style=\"text-align: left;\">The Remote Control Object is the <em>Invoker<\/em> in this pattern. When a button on the Remote Control is pushed a command object <em>execute()<\/em> method is invoked.<\/p>\n<p style=\"text-align: left;\">The appliances are instances of the <em>Receiver<\/em> in this pattern. Calls to a receivers methods are made by instances of the command objects.<\/p>\n<p style=\"text-align: left;\">The House class<em> <\/em>is the<em> Client<\/em> in this pattern, which instantiates and holds references to both the Remote Control and the Appliance objects. There is only one Remote Control per house.<\/p>\n<p style=\"text-align: left;\">At this stage of the project the <em>receiver <\/em>classes all must have parameterless constructors, as well as an on and off method along with a publicly accessible boolean property\u00c2\u00a0 representing the state of the object (either on or off).<\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">By using this design pattern, the Remote Control is decoupled from the Command Objects and the Appliances.\u00c2\u00a0 The first four classes are <em>CeilingFan, GarageDoor, Ligh<\/em>t, and <em>Stereo.<\/em><\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">The Light Class is one of our Appliances and is a <em>Receiver<\/em> in this pattern. Source code for this class and the other receiver classes can be found in <a href=\"http:\/\/michaelokarimia.com\/CodeExamples\/RemoteControl\/RemoteControl\/tags\/v1.0.0\/RemoteController\/ReceiverClasses\/\" target=\"_blank\">my Subversion repository<\/a><\/p>\n<p style=\"text-align: left;\">\n<div id=\"attachment_25\" style=\"width: 209px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-25\" class=\"size-full wp-image-25 \" title=\"Light Class\" src=\"http:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/Light.png\" alt=\"Light Class\" width=\"199\" height=\"295\" \/><p id=\"caption-attachment-25\" class=\"wp-caption-text\">Light Class<\/p><\/div>\n<p style=\"text-align: left;\">Boolean _isOn holds the state of the Light, which is accessed through the read only Property isLightOn<\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">The <em>on() <\/em>and <em>off()<\/em> methods when called, do what their names suggest and update the boolean field _isOn accordingly.<\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">ICommand Object Interface (<a href=\"http:\/\/michaelokarimia.com\/CodeExamples\/RemoteControl\/RemoteControl\/tags\/v1.0.0\/RemoteController\/ICommand.cs\" target=\"_blank\">source code here<\/a>)<\/p>\n<p style=\"text-align: left;\">\n<div id=\"attachment_24\" style=\"width: 138px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-24\" class=\"size-full wp-image-24 \" title=\"Command Object Interface\" src=\"http:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/ICommand.png\" alt=\"Command Object Interface\" width=\"128\" height=\"128\" \/><p id=\"caption-attachment-24\" class=\"wp-caption-text\">Command Object Interface<\/p><\/div>\n<p style=\"text-align: left;\">All Command Objects implement this interface, and are responsible for executing methods in the <em>receiver <\/em>classes.<\/p>\n<p style=\"text-align: left;\"><em>execute() <\/em>invokes a method or methods in the <em>receiver<\/em> class.<\/p>\n<p style=\"text-align: left;\"><em>undo()<\/em> invokes a method or methods in the <em>receiver<\/em> class that does the logical opposite of whatever the execute method does.<\/p>\n<p style=\"text-align: left;\">The LightOnCommand Class is concrete Command object. <a title=\"Commands.cs\" href=\"http:\/\/michaelokarimia.com\/CodeExamples\/RemoteControl\/RemoteControl\/tags\/v1.0.0\/RemoteController\/Commands.cs\" target=\"_blank\">See Source Code for all Command Objects<\/a><\/p>\n<p style=\"text-align: left;\">\n<div id=\"attachment_27\" style=\"width: 188px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27\" class=\"size-full wp-image-27 \" title=\"Light On Command\" src=\"http:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/LightOnCommand.png\" alt=\"Light On Command\" width=\"178\" height=\"190\" \/><p id=\"caption-attachment-27\" class=\"wp-caption-text\">Light On Command<\/p><\/div>\n<p style=\"text-align: left;\">It&#8217;s constructor must be passed a Light object as a parameter, which is stored in the _light field.<\/p>\n<p style=\"text-align: left;\">When the <em>execute()<\/em> method is invoked, it calls the <em>on() <\/em>method of the _light object, and the<em> undo()<\/em> method when invoked calls the <em>off() <\/em>method on the _light object.<\/p>\n<p style=\"text-align: left;\">\n<pre lang=\"csharp\" line=\"1\">public class LightOnCommand : ICommand\r\n{\r\nprivate Light _light;\r\n\r\n<code> public LightOnCommand(Light light)\r\n{\r\n_light = light;\r\n}\r\npublic void execute()\r\n{\r\n_light.on();\r\n}\r\npublic void undo()\r\n{\r\n_light.off();\r\n}\r\n}<\/pre>\n<p style=\"text-align: left;\">Because the <em>Receiver<\/em> object being called has only a binary state which is toggled with the <em>on() <\/em>and <em>off() <\/em>methods, this command is very straightforward.\u00c2\u00a0 In a latter we will introduce a more advanced use of state in <em>Receiver <\/em>classes.<\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">The LightOffCommand Class is another implementation of the ICommand interface<\/p>\n<div id=\"attachment_26\" style=\"width: 183px\" class=\"wp-caption alignleft\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-26\" class=\"size-full wp-image-26\" title=\"LightOffCommand\" src=\"http:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/LightOffCommand.png\" alt=\"LightOffCommand\" width=\"173\" height=\"195\" \/><p id=\"caption-attachment-26\" class=\"wp-caption-text\">LightOffCommand<\/p><\/div>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">As you have probably guessed, this class is the corresponding \"Off\" command for the previous Command Class.<\/p>\n<p style=\"text-align: left;\">This time,<em> execute(<\/em>) turns _light object off, and <em>undo()<\/em> turns the _light object on.<\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">Another Concrete Command Class used in the application is NoCommand, which acts as a Null Object. Its <em>execute()<\/em> and <em>undo()<\/em> methods don't do anything. Null Objects are useful because we want to keep the Remote Control class simple and loosely coupled to the Command Objects; by using  NoCommand as a Null Object, the Remote Control class does not have to handle a null value. For instance, when a Command Slot has not been set to a specific Command Object, a NoCommand object can sit in the slot. This saves the Remote Control needing to check if each Command Object is null before it attempts to calls its <em>execute()<\/em> method.<\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">RemoteControl class: Responsible for invoking commands objects (<a href=\"http:\/\/michaelokarimia.com\/CodeExamples\/RemoteControl\/RemoteControl\/tags\/v1.0.0\/RemoteController\/RemoteControl.cs\" target=\"_blank\">source code<\/a>)<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" title=\"RemoteControl Class\" src=\"http:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/RemoteControl.png\" alt=\"RemoteControl Class\" width=\"200\" height=\"400\" \/><\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">Fields: _undoCommand holds an ICommand object. _offCommands and _OnCommands can hold an array of ICommandObjects<\/p>\n<p style=\"text-align: left;\">The Remote Control is created with each command array populated with NoCommand objects, the House object uses the <em>setCommand()<\/em> method to add them.<\/p>\n<p>Available_Slots and CommandCount properties are used by the House class to determine how many slots are unassigned in order to assign new commands.<\/p>\n<p>When the<em> onButtonWasPushed(int) <\/em>and <em>offButtonWasPushed(int)<\/em> methods are called, they look up the command object stored in the respective _onCommands or _offCommands\u00c2\u00a0 arrays\u00c2\u00a0 at the index passed in as the parameter. The <em>execute()<\/em> method of the command object is called. The Remote Control does not need to know what the command does or how it works; it just needs there to be an execute method to call. It is decoupled from the Command Object.<\/p>\n<p>Additionally when either <em>onButtonWasPushed(int) <\/em>or <em>offButtonWasPushed(int)<\/em> methods are invoked the\u00c2\u00a0 _undoCommand field is set to whatever command object was executed. This field will always hold a reference to the last command object executed. When the <em>undoButtonWasPushed()<\/em> method is called it in turn calls the <em>undo()<\/em> method of that command object. This is how the global undo feature is implemented<\/p>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">The Command Pair struct represents a Command Slot, a pair of commands objects which turn on or off a single appliance.<\/p>\n<p style=\"text-align: left;\">Defined as:<\/p>\n<pre lang=\"csharp\" line=\"1\">\r\npublic struct command_pair\r\n{\r\npublic string Name;\r\npublic ICommand onCmd;\r\npublic ICommand offCmd;\r\n}\r\n<\/pre>\n<p style=\"text-align: left;\">The House Class: Responsible for Appliances, Command Objects, and the Remote Control (<a href=\"http:\/\/michaelokarimia.com\/CodeExamples\/RemoteControl\/RemoteControl\/tags\/v1.0.0\/RemoteController\/House.cs\" target=\"_blank\">Source Code<\/a>)<\/p>\n<div id=\"attachment_23\" style=\"width: 241px\" class=\"wp-caption alignleft\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-23\" class=\"size-full wp-image-23\" title=\"House Class\" src=\"http:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/HouseClass.png\" alt=\"House Class\" width=\"231\" height=\"417\" srcset=\"https:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/HouseClass.png 231w, https:\/\/www.michaelokarimia.com\/blog\/wp-content\/uploads\/2009\/09\/HouseClass-166x300.png 166w\" sizes=\"auto, (max-width: 231px) 100vw, 231px\" \/><p id=\"caption-attachment-23\" class=\"wp-caption-text\">House Class<\/p><\/div>\n<p style=\"text-align: left;\">Fields:<\/p>\n<ul>\n<li> _ArrAppliances holds an ArrayList of the Appliances.<\/li>\n<li>_cmd_Pair is Command Pair struct<\/li>\n<li>_commandsArry holds an ArrayList of Command Pair structs, which are all the valid commands for the House object.<\/li>\n<li>rc is a reference to the Remote Control object<\/li>\n<\/ul>\n<p style=\"text-align: left;\">Properties:<\/p>\n<ul>\n<li>Appliances is the read only ArrayList of _ArrAppliances.<\/li>\n<li>CommandList is the read only ArrayList of _commandsArry.<\/li>\n<\/ul>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">\n<p>The <em>PopulateCommands()<\/em> method creates the valid appliances for the house and the command objects that control them. As we want the house class to be loosely coupled with all the appliance classes and the command objects, I have written the code so these objects are created dynamically at runtime, using Reflection.<\/p>\n<p>In order to do this, the Command Objects need to be defined outside of the code. I have chosen to store this information in a SQL server database, although storing the data in a XML file would be equally valid format. As I am using LINQ to SQL, the syntax does not have to change much in order to do this.<\/p>\n<p style=\"text-align: left;\">\n<pre lang=\"csharp\" line=\"1\">\r\n\r\nprivate void PopulateCommands()\r\n{\r\n_commandsArry = new ArrayList();\r\n\r\nRCDatabaseDataContext db = new RCDatabaseDataContext();\r\n\r\nvar query = from c in db.CommandObjects\r\nselect c;\r\n\r\nforeach (var x in query)\r\n{\r\n_commandsArry.Add(\r\ncreateValidCommand_Pair(x.Name,\r\n                                   x.ReceiverType,\r\n                                   x.OnCmdName,\r\n                                   x.OffCmdName)\r\n);\r\n}\r\n}\r\n<\/pre>\n<p style=\"text-align: left;\">The four attributes\u00c2\u00a0 retrieved from the LINQ query contain all the information for the<em> createValidCommandPair()<\/em> method to create a Command Pair for a single Remote Control Command Slot. Below is a row from the Command Object table.<\/p>\n<table border=\"1\">\n<tbody>\n<tr>\n<td><strong>Command Name<\/strong><\/td>\n<td><strong> Receiver Type<br \/>\n<\/strong><\/td>\n<td><strong>ON Command Class<\/strong><\/td>\n<td><strong>OFF Command Class<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Light Command<\/td>\n<td>RemoteController.<br \/>\nReceiverClasses.Light<\/td>\n<td>RemoteController.<br \/>\nLightOnCommand<\/td>\n<td>RemoteController.<br \/>\nLightOffCommand<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: left;\">\n<p style=\"text-align: left;\">These parameters are then passed to the <em>CreateCommand_Pair()<\/em> method:<\/p>\n<p style=\"text-align: left;\">Using reflection, the <em>receiver<\/em> object paramType is created and then passed as a parameter to both the ICmdOnObj ICmdOffObj constructors.<\/p>\n<p style=\"text-align: left;\">The object paramType is then stored in the _Appliances ArrayList.<\/p>\n<p style=\"text-align: left;\">Both Command Objects are set as Properties in the slot command_pair, which is then returned to the <em>PopulateCommands() <\/em>method.<\/p>\n<pre lang=\"csharp\" line=\"1\">\r\n\r\nprivate command_pair createValidCommand_Pair\r\n(string CmdName,\r\nstring strparamType,\r\nstring strOnCommandType,\r\nstring strOffCommandType)\r\n{\r\n\r\ncommand_pair slot;\r\n\r\nType TypeOnCmd = Type.GetType(strOnCommandType);\r\n\r\nType TypeOffCmd = Type.GetType(strOffCommandType);\r\n\r\nType paramType = Type.GetType(strparamType);\r\n\r\n\/\/creating the Receiver Object\r\n\r\nobject paramObj =\u00c2\u00a0 Activator.CreateInstance(paramType);\r\n\r\n\/\/creating the ON command object\r\n\r\nSystem.Reflection.ConstructorInfo[] ciOnCmd =\r\nTypeOnCmd.GetConstructors();\r\n\r\n\/\/create the OFF command object\r\n\r\nSystem.Reflection.ConstructorInfo[] ciOffCmd =\r\nTypeOffCmd.GetConstructors();\r\n\r\nobject[] objarr = new object[1];\r\n\r\n\/\/store created Receiver object in appliances arraylist\r\n\r\n_ArrAppliances.Add(paramObj);\r\n\r\nobjarr[0] = paramObj;\r\n\r\n\/\/create the on and off command objects\r\n\/\/with the same receiver object\r\n\r\nICommand ICmdOnObj = (ICommand)ciOnCmd[0].Invoke(objarr);\r\n\r\nICommand ICmdOffObj = (ICommand)ciOffCmd[0].Invoke(objarr);\r\n\r\n\/\/set command_pair struct values\r\n\r\nslot.Name = CmdName;\r\n\r\nslot.onCmd = ICmdOnObj;\r\n\r\nslot.offCmd = ICmdOffObj;\r\n\r\nreturn slot;\r\n\r\n}\r\n<\/pre>\n<p>The <em>PopulateCommands()<\/em> method then adds each of the new command_pair structs to the _commandsArry ArrayList.<\/p>\n<p>This design for the Appliances and Command Classes are decoupled from the Remote Control class. Commands Pairs are defined in a database, which means they can be altered at runtime. For instance, if one needed to create a new Command Pair for a new appliance, one would just need to add its definition to the Command Objects table.<\/p>\n<p>T-SQL script to create the Command Objects table  can be found <a title=\"CommandObject.sql\" href=\"http:\/\/michaelokarimia.com\/CodeExamples\/RemoteControl\/RemoteControl\/tags\/v1.0.0\/DatabaseScripts\/CommandObjects.sql\" target=\"_blank\">here in my Subversion repository<\/a>, along with <a title=\"SeedDataScript\" href=\"http:\/\/michaelokarimia.com\/CodeExamples\/RemoteControl\/RemoteControl\/tags\/v1.0.0\/DatabaseScripts\/SeedDataScript.sql\" target=\"_blank\">the script which  populates that table <\/a>with data to create the Command Pairs. In order to use LINQ to SQL the user will have to a new DBML file to the solution, with named \"RCDatabase.dbml\", and add the CommandObject table to file.\u00c2\u00a0 The details of the database schema and how LINQ to SQL is used in this project will be covered in a later post.<\/p>\n<p>Now that we have the classes required for our Home Automation Program I will demonstrate how we can test that they work correctly, and stay that way as we update the code. <a href=\"http:\/\/www.michaelokarimia.com\/blog\/2009\/10\/01\/command-pattern-tutorial-part-two\/\" title=\"In my next post I will show how this is done using Test Driven Development with NUnit, along with a working demo of the code\" target=\"_blank\">In my next post I will show how this is done using Test Driven Development with NUnit, along with a working demo of the code<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When designing software, effective use of design patterns can simplify your design, save you time and produce results more quickly. In the following posts I will be demonstrating the implementation of one the Gang of Four&#8217;s frequently used patterns, The Command Pattern. The final result will be a web application which the user will be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[6],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-tutorials","tag-design-patterns"],"_links":{"self":[{"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":82,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":82,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions\/82"}],"wp:attachment":[{"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}