{"id":21628,"date":"2021-05-29T09:55:24","date_gmt":"2021-05-29T09:55:24","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=21628"},"modified":"2021-05-29T09:55:28","modified_gmt":"2021-05-29T09:55:28","slug":"object-oriented-programming-oop-concept-simplified","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/object-oriented-programming-oop-concept-simplified\/","title":{"rendered":"Object-oriented programming (OOP) Concept Simplified!"},"content":{"rendered":"\n<p>In today&#8217;s technological culture, knowledge in computer programming is highly needed for programming. The development and maintenance of software systems might be helpful with an understandings of object-oriented programming (OOP). The fundamental ideas of OOP are discussed in this article and discussed in examples that are easy to grasp.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Object-oriented programming (OOP)?<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i2.wp.com\/francescolelli.info\/wp-content\/uploads\/2019\/08\/java-oops.png?fit=557%2C429&amp;ssl=1\" alt=\"Object Oriented Programming: A curated set of resources\"\/><\/figure>\n\n\n\n<p>Object-oriented programming consists of combining a set of variables (properties) and functions (methods), which are referred to as an object. These things are arranged into classes in which individual items can be combined. OOP can enable you to consider the objects and the many activities in connection with the objects in a program&#8217;s code.<\/p>\n\n\n\n<p>You can say in simple words, It is a technique to write computer programmes that use the concept of &#8220;Objects&#8221; to represent data and operations.<\/p>\n\n\n\n<p>A good knowledge of OOPs ideas can aid with the development of decisions. How should an application be designed and what language should be used. The programming languages are several object-oriented programming, including JavaScript, C++, Java, and Python.<\/p>\n\n\n\n<p>A <strong>class<\/strong> is an abstract plan for creating more particular, specialised items. Classes often include large categories, such as (<code><strong><span class=\"has-inline-color has-vivid-red-color\">Car<\/span><\/strong><\/code>) and (<code><span class=\"has-inline-color has-vivid-red-color\"><strong>Dog<\/strong><\/span><\/code>) with properties in common. These classes specify what characteristics an instance like (<code><span class=\"has-inline-color has-vivid-red-color\"><strong>colour<\/strong><\/span><\/code>) has for a certain object, but not the value of the attributes.<\/p>\n\n\n\n<p>As a blueprint for creating particular <strong>objects<\/strong>, class templates are employed. These are certain abstract class examples, such as (<strong><code><span class=\"has-inline-color has-vivid-red-color\">myCar<\/span><\/code><\/strong>) or (<strong><code><span class=\"has-inline-color has-vivid-red-color\">goldenRetriever<\/span><\/code><\/strong>). Each object can have distinct values for the class specified attributes.<\/p>\n\n\n\n<p><strong>Example:- <\/strong><\/p>\n\n\n\n<p>In order to include all the <code><strong><span class=\"has-inline-color has-vivid-red-color\">Car<\/span><\/strong><\/code>-properties (<code><strong><span class=\"has-inline-color has-vivid-red-color\">colour<\/span><\/strong><\/code>), (<span class=\"has-inline-color has-vivid-red-color\"><code><strong>brand<\/strong><\/code><\/span>), and We developed a class, (<strong><code><span class=\"has-inline-color has-vivid-red-color\">car<\/span><\/code><\/strong>), and (<strong><code><span class=\"has-inline-color has-vivid-red-color\">model<\/span><\/code><\/strong>). Then we build an instance of an object (<span class=\"has-inline-color has-vivid-red-color\"><strong><code>Car<\/code><\/strong><\/span>) type (<strong><code><span class=\"has-inline-color has-vivid-red-color\">myCar<\/span><\/code><\/strong>) that represents my particular car.<\/p>\n\n\n\n<p>Then, without changing other things or the class template, we may set up the properties provided for the class to describe my car.<\/p>\n\n\n\n<p>This class may be reused to represent any number of cars.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"488\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/image-60.png\" alt=\"\" class=\"wp-image-21648\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/image-60.png 642w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/image-60-300x228.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><figcaption>Class blueprint being used to create two Car type objects, myCar and helensCar.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">What are the principles of Object-oriented programming (OOP)?<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/1142\/1*GDZKZyaSfQGm8HL-CtYWtA.jpeg\" alt=\"What are four basic principles of Object Oriented Programming? | by Munish  Chandel | Medium\"\/><\/figure>\n\n\n\n<p>Four key principles for object-oriented programming: <strong>Encapsulation<\/strong>, <strong>Abstraction<\/strong>, <strong>Inheritance <\/strong>and <strong>Polymorphism<\/strong>. Although these notions appear to be quite complex, it is helpful to grasp the overall structure of the way they function. Here are the four fundamental theories:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Inheritance:<\/strong>\u00a0child classes inherit data and behaviors from parent class<\/li><li><strong>Encapsulation:<\/strong>\u00a0containing information in an object, exposing only selected information<\/li><li><strong>Abstraction:<\/strong>\u00a0only exposing high level public methods for accessing an object<\/li><li><strong>Polymorphism:<\/strong>\u00a0many methods can do the same task<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Terminology used in Object-oriented programming (OOP)?<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www3.ntu.edu.sg\/home\/ehchua\/programming\/java\/images\/OOP_Objects.png\" alt=\"Python Tutorial - Object-Oriented Programming (OOP)\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">What is <strong>Inheritance<\/strong>?<\/h4>\n\n\n\n<p>The idea of heritage in OOP allows a class to accept the properties of another class or to have (inherited). A class that inherits other class&#8217;s characteristics\/methods is called a sub-class or derived class. Heritage decreases the degree of code redundancy, so the class may utilize other class methods without rewriting the codes. This also gives dynamic programming using the methods of the main class (also called the parent class). A subclass has the characteristics of a principal class and can contain other methods that are either entirely independent or may not be in the main class.<\/p>\n\n\n\n<p><strong>What is the Function of Inheritance?<\/strong><\/p>\n\n\n\n<p>When fundamental attributes and behaviors are established in a parent&#8217;s class, children&#8217;s classes may be developed to expand the parent&#8217;s class functionality and to add more attributes.<\/p>\n\n\n\n<p><strong>Example:-<\/strong> This difference is shown by establishing a parent class child class(<code><span class=\"has-inline-color has-vivid-red-color\">HerdingDog<\/span><\/code>) (<code><span class=\"has-inline-color has-vivid-red-color\">Dog<\/span><\/code>) and then adding a single behaviour of the {<code><span class=\"has-inline-color has-vivid-red-color\">herd()<\/span><\/code>}.<\/p>\n\n\n\n<p>The following code contains the child class (<span class=\"has-inline-color has-vivid-red-color\"><code>HerdingDog<\/code><\/span>) inherits a parent class method (<span class=\"has-inline-color has-vivid-red-color\"><code>bark<\/code><\/span>) (<code><span class=\"has-inline-color has-vivid-red-color\">Dog<\/span><\/code>), and an extra method {<code><span class=\"has-inline-color has-vivid-red-color\">herd()<\/span><\/code>} is added by the child class.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/AdarshAshwani\/46cac428f68b6dfd7ed406a9dc252e4d.js\"><\/script>\n\n\n\n<p>The method {<code><span class=\"has-inline-color has-vivid-red-color\">bark()<\/span><\/code>} moves up the child&#8217;s chain in order to find out where the {<code><span class=\"has-inline-color has-vivid-red-color\">bark<\/span><\/code>} method is defined when the code uses a {<code><span class=\"has-inline-color has-vivid-red-color\">fluffy.bark()<\/span><\/code>} method.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/AdarshAshwani\/dde3dbe7d18ffe83d4245c7e7d138ac2.js\"><\/script>\n\n\n\n<h4 class=\"wp-block-heading\">What is <strong>Encapsulation<\/strong>?<\/h4>\n\n\n\n<p>This is the packaging of data and functions in classes correspondingly. Object-oriented programming enables a single package to combine data and functions together. This allows simple debugging and tracking of errors during programming. When a programmer is running and the interpreter finds a mistake, it makes it easy for the programmer to know precisely where to search and modify. Although it is possible to define functions and assign variables, like with procedural programming, there is no unit or structure meant to package them.<\/p>\n\n\n\n<p><strong>What is the Function of <strong>Encapsulation<\/strong>?<\/strong><\/p>\n\n\n\n<p>When an object is formed from the class, the data and methods are included in the object. Encapsulation hides internal software code implementation within a class and disguises internal information from inner objects. <\/p>\n\n\n\n<p>Encapsulation requires certain fields to be defined in public and private. <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Private\/ Internal interface<\/strong>:- Properties and methods, available from the other methods same class.<\/li><li><strong>Public \/ External Interface:<\/strong>&#8211; Properties and methods, are taken from outside the class.<\/li><\/ul>\n\n\n\n<p><strong>Example<\/strong>:- Once again take the example of the Dog owner, Encapsulation is ideal so owners can\u2019t access private information about other people\u2019s dogs.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/AdarshAshwani\/7bb9ab017db876e736689e40ef6f1978.js\"><\/script>\n\n\n\n<h4 class=\"wp-block-heading\">What is <strong>Abstraction<\/strong>?<\/h4>\n\n\n\n<p>Abstraction in OOP allows information\/access to be hidden as to how codes are applied, providing just the necessary access. These data are contained inside the definitions of objects. The counting method that works on list items is a classic example. A brief piece of information to notice here is that, given the same OOP notion, all Python I data types and structures are objects. In that respect, a list is a class constructed with methods for performing functions.<\/p>\n\n\n\n<p><strong>What is the Function of <strong><strong>Abstraction<\/strong><\/strong>?<\/strong><\/p>\n\n\n\n<p>In order to access a complicated object, abstraction utilizes simpler high-level instruments :<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Using simple things to represent complexity<\/li><li>Hide complex details from user<\/li><\/ul>\n\n\n\n<p>A large security function is also played by abstraction. We safeguard the data against exposure solely by showing chosen data items and only enabling data access via classes and methods. in a car example, You wouldn&#8217;t want an open gas tank when driving a car to continue with the Car.<\/p>\n\n\n\n<p>There are some benefits of abstraction which is mention below:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Simple, high level user interfaces<\/li><li>Complex code is hidden<\/li><li>Security<\/li><li>Easier software maintenance<\/li><li>Code updates rarely change abstraction<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">What is <strong><strong>Polymorphism<\/strong><\/strong>?<\/h4>\n\n\n\n<p>As its name indicates, polymorphism has numerous shapes. OOP permits the usage of the several kinds of methods I. Simply put, they pertain to the usage of methods, such that a method works differently for various objects. Polymorphic methods permits alternative actions to be performed in two ways: Method Overriding and Method Overloading. <\/p>\n\n\n\n<p><strong>The benefits of Polymorphism are:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Objects of different types can be passed through the same interface<\/li><li>Method overriding<\/li><li>Method overloading<\/li><\/ul>\n\n\n\n<p><strong>Method Overriding<\/strong>:- Polymorphism of runtime employs overriding approach. A child class can implement another method than its parent class by overriding it. In the example of our dogs, we may desire a certain form of bark different from the generic sort of dog (<code><strong><span class=\"has-inline-color has-vivid-red-color\">TrackingDog<\/span><\/strong><\/code>).<\/p>\n\n\n\n<p><strong>Example:-<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/AdarshAshwani\/bf43d4eba711a453d8066e214ab99846.js\"><\/script>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"443\" height=\"369\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/image-61.png\" alt=\"\" class=\"wp-image-21653\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/image-61.png 443w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/image-61-300x250.png 300w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><figcaption>TrackingDog&#8217;s overriding the bark() method<\/figcaption><\/figure>\n\n\n\n<p><strong>Method Overloading<\/strong>:- The polymorphism compile time employs overloading approach. There might be the same name for methods or functions but distinct parameters have been given to the call method. Depending on the amount of parameters entered, different results may arise.<\/p>\n\n\n\n<p><strong>Example<\/strong>:- Where the {<code><span class=\"has-inline-color has-vivid-red-color\">updateAttendance()<\/span><\/code>} function has no arguments given. One day the count will be added. If the {<code><span class=\"has-inline-color has-vivid-red-color\">updateAttendance(4)<\/span><\/code>} argument is supplied, then the {<code><span class=\"has-inline-color has-vivid-red-color\">x<\/span><\/code>} {<code><span class=\"has-inline-color has-vivid-red-color\">updateAttendance(x<\/span><\/code>)} parameter is passed and four days added to the total.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/AdarshAshwani\/5234b5889eb581e97e38cc38e2271087.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Why do we need Object-oriented programming (OOP)?<\/h2>\n\n\n\n<p>The fundamental principle is that you construct a class instead of creating a programme which contains variables and functions as a type of template. Objects are independent instances of that class, and you may have them interact with one other in an engaging and interesting way.<\/p>\n\n\n\n<p>This type of encapsulation has the advantages of object-oriented programming. A comprehensive overview of some of the great advantages of OOP:-<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Modularity for easier troubleshooting<\/strong>:- <br>You know precisely where to look when working with object-oriented programming languages. &#8220;Oh, the object of the automobile collapsed? In the car class the problem must be!&#8221; There is nothing else you don&#8217;t have to muck.<br>This is the embellishment of the beauty. Objects are independent and each piece of functionality performs its own while the other pieces are left alone. This modality also allows an IT team to simultaneously work on many items while reducing the likelihood of one person duplicating the functionality of another individual.<\/li><li><strong>Reuse of code through inheritance<\/strong>:-<br>Suppose one of your Friend demands a RaceCar and other friend want as well want a Limousine object. Everyone constructs their own things, yet finds common amongst them. Actually, each thing is merely another type of Object. Here the method of heritage spares time: Create a generic class (car) and then defines the subclass(s) to inherit the characteristics of the generic class (racecar and limousine).<br>Of course, the qualities and functions of Limousine and RaceCar remain distinct. If the RaceCar object needs a &#8220;fireAfterburners&#8221; method, and the Limousine object wants a chauffeur, the distinct methods can be implemented for each class. Your inheriting classes can reuse the code that exists instead of typing those functions again, because both classes include crucial parts in the Car Class, such as the &#8220;drive&#8221; or &#8220;FillUpGas&#8221; methods.<\/li><li><strong>Flexibility through polymorphism<\/strong>:-<br>You merely need certain drivers or features like &#8220;driveCar,&#8221; &#8220;driveRaceCar&#8221; and &#8220;DriveLimousine&#8221; now to tackle the example. RaceCarDrivers share several aspects with LimousineDrivers, while some elements are distinct, such RaceHelmets and DrinkSponsorships.<br>This is where delicious polymorphism comes into play in object-oriented programming. Since a single function may be shaped to suit any class, a function named &#8220;drive&#8221; may also be created for the parent car class, not &#8220;driveCar&#8221; or &#8220;dryRaceCar,&#8221; simply &#8220;drive.&#8221; This function is named &#8220;drive.&#8221; The RaceCarDriver, LimousineDriver, etc. would work with the single function.<\/li><li><strong>Effective problem solving<\/strong>:-<br>The most intuitive and pragmatic technique, when you hang it, is object-oriented programming. OOP languages allow you, one object at a time, to split your programmer into digestible issues that you can then resolve.<br>This does not mean OOP is the One True Way. The benefits of object-driven programming, however, are numerous. When you need to address hard difficulties in programming, and you want to add code to your skills, OOP is your fellow \u2014 it is far longer and more useful than Pac-Man or parachute trousers.<\/li><\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">What are the Benefits of Object-oriented programming (OOP)?<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>As reproducible, basic structures, OOP model complex items<\/li><li>OOP objects may be utilized in programmes that are reusable<\/li><li>Allows class-specific conduct by polymorphism<\/li><li>Classes are easier to debug, and frequently provide all the relevant information<\/li><li>Secure, safeguards encapsulation information<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">How to learn Object-oriented programming (OOP)?<\/h2>\n\n\n\n<p>There are many ways to learn about  Object-oriented programming (OOP) like Video Tutorials on YouTube, Notes, Blogs, Articles, etc. I have share this Tutorials for you all guys with a great explanation and useful examples. And, There are Many institutes provide some training program that helps beginner programmer to Understand the concept of Object-oriented programming (OOP). I have shared One YouTube Referral Videos which is great for understanding.<br> <\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\"  id=\"_ytid_46251\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/pTB0EiLXUC8?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  epyt-is-override  no-lazyload\" title=\"YouTube player\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In today&#8217;s technological culture, knowledge in computer programming is highly needed for programming. The development and maintenance of software systems might be helpful with an understandings of object-oriented programming (OOP). The fundamental ideas of OOP are discussed in this article and discussed in examples that are easy to grasp. What is Object-oriented programming (OOP)? Object-oriented&#8230;<\/p>\n","protected":false},"author":25,"featured_media":21654,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5691,5150],"tags":[6693,6707,6715,6714,6709,6705,6702,6703,6716,6692,6691,6690,6689,6696,6697,6708,6713,6695,6704,6700,6698,6694,6706,6701,6699,6712,6711,6710],"class_list":["post-21628","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-php","tag-oop-2","tag-benefits-of-abstraction","tag-benefits-of-object-oriented-programming","tag-benefits-of-object-oriented-programming-oop","tag-benefits-of-polymorphism","tag-function-of-abstraction","tag-function-of-encapsulation","tag-function-of-inheritance","tag-how-to-learn-object-oriented-programming-oop","tag-object-oriented-programming","tag-object-oriented-programming-oop","tag-object-oriented-programming-oop-concept","tag-object-oriented-programming-oop-concept-simplified","tag-principles-of-object-oriented-programming","tag-terminology-used-in-object-oriented-programming-oop","tag-the-benefits-of-polymorphism","tag-what-are-the-benefits-of-object-oriented-programming-oop","tag-what-are-the-principles-of-object-oriented-programming-oop","tag-what-is-abstraction","tag-what-is-encapsulation","tag-what-is-inheritance","tag-what-is-object-oriented-programming-oop","tag-what-is-polymorphism","tag-what-is-the-function-of-encapsulation","tag-what-is-the-function-of-inheritance","tag-why-do-we-need-oop","tag-why-do-we-need-object-oriented-programming","tag-why-do-we-need-object-oriented-programming-oop"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/21628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=21628"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/21628\/revisions"}],"predecessor-version":[{"id":21655,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/21628\/revisions\/21655"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/21654"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=21628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=21628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=21628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}