{"id":52,"date":"2019-12-19T10:18:26","date_gmt":"2019-12-19T15:18:26","guid":{"rendered":"http:\/\/ayling.tech\/blog\/?p=52"},"modified":"2019-12-20T11:32:03","modified_gmt":"2019-12-20T16:32:03","slug":"objects-in-code","status":"publish","type":"post","link":"https:\/\/shortbooks.online\/blog\/2019\/objects-in-code\/","title":{"rendered":"Objects in code"},"content":{"rendered":"\n<p>Everything I read about object oriented code gives an example, like an animal, that has features such as a number of legs, and a breed, and any number of other, entirely-irrelevant-to-real-life-examples. These examples are good at describing the very, <em>very<\/em> high-level concept, but they fail to provide the concrete examples that a user might genuinely need in their coding life.<\/p>\n\n\n\n<p>A module I have written pulls data from Active Directory, and has functions that can change that data. I believe this is a much clearer example than one that uses imaginary animals.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class AD\n{\n     public static string domain;\n\n     public AD(DirectoryEntry de)\n     {\n          DirectoryEntryI = de;\n          \/\/Other methods\n     }\n\n     private DirectoryEntry _DirEntry {get;set;}\n     public DirectoryEntry DirEntry\n     {\n          get\n          {\n               UpdateDN();\n               if (this.DN is string objectDn)\n               {\n                    _DirEntry = new DirectoryEntry(\"LDAP:\/\/\" + objectDn);\n                    return _DirEntry;\n               }\n               return null;\n           }\n     }\n}<\/code><\/pre>\n\n\n\n<p>This class contains a constructor, uses Microsoft APIs [it would need &#8220;using System.DirectoryServices&#8221; above the namespace declaration], has member variables [DirEntry and _DirEntry] which have different accessibility, has a function [UpdateDN() which I have not included in the code to make it easier to read] and has a non-member variable to store the domain of this Active Directory object.<\/p>\n\n\n\n<p>Personally, I think this is a far more interesting example.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Everything I read about object oriented code gives an example, like an animal, that has features such as a number of legs, and a breed, and any number of other, entirely-irrelevant-to-real-life-examples. These examples are good at describing the very, very high-level concept, but they fail to provide the concrete examples that a user might genuinely need in their coding life. A module I have written pulls data from Active Directory, and has functions that can change that data. I believe&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/shortbooks.online\/blog\/2019\/objects-in-code\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":127,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[14],"tags":[21,15,16,22,18,17],"class_list":["post-52","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code","tag-active-directory","tag-c","tag-code","tag-directoryservices","tag-object-oriented-programming","tag-objects"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":0,"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/media\/127"}],"wp:attachment":[{"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shortbooks.online\/blog\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}