{"id":478,"date":"2019-07-06T13:07:00","date_gmt":"2019-07-06T11:07:00","guid":{"rendered":"http:\/\/www.labo.mathieurella.fr\/?p=478"},"modified":"2020-07-06T13:36:22","modified_gmt":"2020-07-06T11:36:22","slug":"procedural-vs-object-oriented-programming","status":"publish","type":"post","link":"https:\/\/www.labo.mathieurella.fr\/?p=478","title":{"rendered":"Procedural vs Object-Oriented Programming"},"content":{"rendered":"\n<p>A Procedural programming is essentially a list of instruction that execute one after the other from the top of the file and working down.<\/p>\n\n\n\n<p>Object Oriented Programming, on the other hand, are built around object, you can think about object about things that exist in the real world.<\/p>\n\n\n\n<p><strong>Example :<\/strong> If you were going to build a clothing store, the store itself would be an object, the item in the store like the shirt and jean would also be an object, like the salesman or cash register.<\/p>\n\n\n\n<p>An object oriented program would focus on the individual characteristic of each object and what each object can do.<\/p>\n\n\n\n<p>So an object has 2 essential parts : Characteristic &amp; Action.<\/p>\n\n\n\n<figure class=\"wp-block-gallery columns-1 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.17.20-PM-1024x525.png\" alt=\"\" data-id=\"479\" data-full-url=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.17.20-PM.png\" data-link=\"https:\/\/www.labo.mathieurella.fr\/?attachment_id=479\" class=\"wp-image-479\"\/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"525\" src=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.17.20-PM-1024x525.png\" alt=\"\" data-id=\"479\" data-full-url=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.17.20-PM.png\" data-link=\"https:\/\/www.labo.mathieurella.fr\/?attachment_id=479\" class=\"wp-image-479\" srcset=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.17.20-PM-1024x525.png 1024w, https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.17.20-PM-300x154.png 300w, https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.17.20-PM-768x394.png 768w, https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.17.20-PM.png 1436w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/noscript><\/figure><\/li><\/ul><figcaption class=\"blocks-gallery-caption\">Objects are defined by their characteristics and their actions<\/figcaption><\/figure>\n\n\n\n<p>Another way to think about characteristics and actions is in terms of English grammar. A characteristic would be a noun. On the other hand, an action would be a verb.<\/p>\n\n\n\n<p>Let&#8217;s pick something from the real-world: a dog. A few characteristics could be the dog&#8217;s weight, color, breed, and height. These are all nouns. What actions would a dog take? A dog can bark, run, bite and eat. These are all verbs.<\/p>\n\n\n\n<p>The characteristic and actions have specific names in OOP, <\/p>\n\n\n\n<ul><li>Characteristic : Attributes<\/li><li>Actions : Methods<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Object vs Class<\/h4>\n\n\n\n<p>The t-shirt object have the same attributes and methods only the value of those attributes differs.<\/p>\n\n\n\n<p>They both have a price, style, color &#8230;<\/p>\n\n\n\n<p>It&#8217;s like they came from the a blueprint, a generic shirt consisting of all attributes and methods.<\/p>\n\n\n\n<p>This generic version of an object is called a Class.<\/p>\n\n\n\n<p>From this Class you can create specific object from the class over and over again<\/p>\n\n\n\n<figure class=\"wp-block-gallery columns-1 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.26.26-PM-1024x509.png\" alt=\"\" data-id=\"480\" data-full-url=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.26.26-PM.png\" data-link=\"https:\/\/www.labo.mathieurella.fr\/?attachment_id=480\" class=\"wp-image-480\"\/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"509\" src=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.26.26-PM-1024x509.png\" alt=\"\" data-id=\"480\" data-full-url=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.26.26-PM.png\" data-link=\"https:\/\/www.labo.mathieurella.fr\/?attachment_id=480\" class=\"wp-image-480\" srcset=\"https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.26.26-PM-1024x509.png 1024w, https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.26.26-PM-300x149.png 300w, https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.26.26-PM-768x382.png 768w, https:\/\/www.labo.mathieurella.fr\/wp-content\/uploads\/2020\/07\/Capture-d\u2019e\u0301cran-2020-07-06-a\u0300-1.26.26-PM.png 1436w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/noscript><\/figure><\/li><\/ul><figcaption class=\"blocks-gallery-caption\">A class is a blueprint consisting of attributes and methods.<br><\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>A Procedural programming is essentially a list of instruction that execute one after the other from the top of the &#8230;<\/p>\n","protected":false},"author":1,"featured_media":481,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=\/wp\/v2\/posts\/478"}],"collection":[{"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=478"}],"version-history":[{"count":1,"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=\/wp\/v2\/posts\/478\/revisions"}],"predecessor-version":[{"id":482,"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=\/wp\/v2\/posts\/478\/revisions\/482"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=\/wp\/v2\/media\/481"}],"wp:attachment":[{"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.labo.mathieurella.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}