{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/objectOrientedProgramming","result":{"data":{"blog":{"frontmatter":{"title":"OBJECT ORIENTED PROGRAMMING","thumbnail":"blog49","date":"February 27, 2021","dsaCppCodeFile":null},"excerpt":"<div class=\"my-2 p-2\">\n              <div class=\"m-2\">\n                <p>\n                  In this blog we study the basic concepts of object oriented\n                  programming, how it differs from Procedural oriented\n                  programming, advantages and it's features with examples.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Definition</h4>\n              <div class=\"m-2\">\n                <p>\n                  Object Oriented Programming(OOP) is an approach that provides\n                  a way of modularizing programs which is using \"objects\" to\n                  represent data(variables) and methods(functions).\n                </p>\n                <p>\n                  A single module can be used as a template so that we can\n                  create as many copies of each module on demand.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Procedural vs Object Oriented Programming</h4>\n              <div class=\"table-responsive m-2\">\n                <table class=\"table table-striped\">\n                  <caption class=\"text-center\">\n                    Procedural vs Object Oriented Programming\n                  </caption>\n                  <thead class=\"thead-dark\">\n                    <th>Procedural Oriented</th>\n                    <th>Object Oriented</th>\n                  </thead>\n                  <tbody>\n                    <tr>\n                      <td>Major focus is on functions.</td>\n                      <td>Major focus is on data and how to access them.</td>\n                    </tr>\n                    <tr>\n                      <td>Programs are divided into functions.</td>\n                      <td>\n                        Programs are divided into objects that contains data and\n                        functions.\n                      </td>\n                    </tr>\n                    <tr>\n                      <td>\n                        Data is usually global and focus on how to access data\n                        is not taken into account.\n                      </td>\n                      <td>\n                        Data is hidden and mainly focuses on how to access data.\n                      </td>\n                    </tr>\n                    <tr>\n                      <td>Not suitable for real world scenarios.</td>\n                      <td>\n                        Higly suitable and also resembles the real world\n                        scenarios.\n                      </td>\n                    </tr>\n                    <tr>\n                      <td>Data is publicly available.</td>\n                      <td>Data is hidden and cannot be accessed directly.</td>\n                    </tr>\n                    <tr>\n                      <td>\n                        <strong>Ex languages: </strong>Fortran, COBOL, Pascal, C\n                        etc.\n                      </td>\n                      <td>\n                        <strong>Ex languages: </strong>C++, Java, Python, Swift,\n                        C#, Ruby, Dart, R etc.\n                      </td>\n                    </tr>\n                  </tbody>\n                </table>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Advangates of OOPs</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  OOPs makes development and maintenance easier where as in\n                  Procedure-oriented programming language it is not easy to\n                  manage if code grows as project size grows.\n                </li>\n                <li>\n                  OOPs provides data hiding whereas in Procedure-oriented\n                  programming language a global data can be accessed from\n                  anywhere.\n                </li>\n                <li>\n                  OOPs provides ability to simulate real-world event much more\n                  effectively. We can provide the solution of real word problem\n                  if we are using the Object-Oriented Programming language.\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Features of OOPs</h4>\n              <div class=\"table-responsive m-2\">\n                <table class=\"table table-striped\">\n                  <caption class=\"text-center\">\n                    Features of OOPs\n                  </caption>\n                  <thead class=\"thead-dark\">\n                    <th>Features</th>\n                    <th>Meaning</th>\n                  </thead>\n                  <tbody>\n                    <tr>\n                      <th>Classes</th>\n                      <td>\n                        A class is a template that is a collection of data\n                        members(variables) & methods(member functions). It is a\n                        bluprint that defines the data & behavior of a given\n                        type. Classes are usually user defined data type.\n                        <br />\n                        <strong>Ex: </strong>A class named Book can be created\n                        with data(book id, name, author, cost) and methods(to\n                        add new book, to get details of specific book).\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Objects</th>\n                      <td>\n                        An object is a real world entity and is an instance of a\n                        class. Once a class is created then we can create any\n                        number of copies of that class using objects. Objects\n                        are an abstract data type and it can include multiple\n                        properties.\n                        <br />\n                        <strong>Ex: </strong>Any no. of objects can be created\n                        of class Book like a book for author ABC; a book for\n                        author XYZ etc.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Data Encapsulation</th>\n                      <td>\n                        Data encapsulation provides a way for binding data and\n                        methoids into single entity called class. In\n                        encapsulation, data is not accessed directly instead it\n                        is accessed using through the methods present inside\n                        that class.\n                        <br />\n                        <strong>Ex: </strong>Consider our phone contacts as a\n                        class; the contact no. and contact name are the data,\n                        the edit, call, message options are the methods that\n                        provides us to interact/access the contact.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Data Abstraction</th>\n                      <td>\n                        Data abstraction provides a way of hiding the internal\n                        details and shows only the functionality. Through this\n                        process, a programmer needs to hide the background\n                        features and relevant data about an object that reduces\n                        the complexity and increases the efficiency.\n                        <br />\n                        <strong>Ex: </strong>In mobile phones, we don't know how\n                        bluetooth works but we clearly know how to use it. Or, a\n                        user need not worry about working of a linked list, he\n                        just need to know how to add/delete/update/search data.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Polymorphism</th>\n                      <td>\n                        Polymorphism means many(poly) forms(morphism). It\n                        provides a way of perfoming similar tasks in different\n                        ways. It refers to programming language's ability to\n                        process objects differently depending on thier data type\n                        or class.\n                        <br />\n                        <strong>Ex: </strong>A + operator can be used to add two\n                        numbers or strings. A function can be overloaded and\n                        accessed depending on it's parameters type and return\n                        type.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Inheritance</th>\n                      <td>\n                        Inheritance is way of inheriting the properties of one\n                        class to another. It allows users to create derived\n                        class(subclass) from an existing class(superclass). Now\n                        this derived class inherits all the proerties from the\n                        superclass/baseclass and can also have it's own\n                        features. It is used to achive runtime polymorphism.\n                        <br />\n                        <strong>Ex: </strong>A new derived class named Cart can\n                        he inherted from class Book that inherits Book's\n                        properties and can also have it's own properties like\n                        quantity, total cost, shipment address etc.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Message Passing</th>\n                      <td>\n                        Message passing provides a way for objects to interact\n                        with each other.\n                        <br />\n                        <strong>Ex: </strong>In case we need a new object that\n                        has same properties of an existing one then we can clone\n                        this existing object.\n                      </td>\n                    </tr>\n                  </tbody>\n                </table>\n              </div>\n            </div>\n","html":"<div class=\"my-2 p-2\">\n              <div class=\"m-2\">\n                <p>\n                  In this blog we study the basic concepts of object oriented\n                  programming, how it differs from Procedural oriented\n                  programming, advantages and it's features with examples.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Definition</h4>\n              <div class=\"m-2\">\n                <p>\n                  Object Oriented Programming(OOP) is an approach that provides\n                  a way of modularizing programs which is using \"objects\" to\n                  represent data(variables) and methods(functions).\n                </p>\n                <p>\n                  A single module can be used as a template so that we can\n                  create as many copies of each module on demand.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Procedural vs Object Oriented Programming</h4>\n              <div class=\"table-responsive m-2\">\n                <table class=\"table table-striped\">\n                  <caption class=\"text-center\">\n                    Procedural vs Object Oriented Programming\n                  </caption>\n                  <thead class=\"thead-dark\">\n                    <th>Procedural Oriented</th>\n                    <th>Object Oriented</th>\n                  </thead>\n                  <tbody>\n                    <tr>\n                      <td>Major focus is on functions.</td>\n                      <td>Major focus is on data and how to access them.</td>\n                    </tr>\n                    <tr>\n                      <td>Programs are divided into functions.</td>\n                      <td>\n                        Programs are divided into objects that contains data and\n                        functions.\n                      </td>\n                    </tr>\n                    <tr>\n                      <td>\n                        Data is usually global and focus on how to access data\n                        is not taken into account.\n                      </td>\n                      <td>\n                        Data is hidden and mainly focuses on how to access data.\n                      </td>\n                    </tr>\n                    <tr>\n                      <td>Not suitable for real world scenarios.</td>\n                      <td>\n                        Higly suitable and also resembles the real world\n                        scenarios.\n                      </td>\n                    </tr>\n                    <tr>\n                      <td>Data is publicly available.</td>\n                      <td>Data is hidden and cannot be accessed directly.</td>\n                    </tr>\n                    <tr>\n                      <td>\n                        <strong>Ex languages: </strong>Fortran, COBOL, Pascal, C\n                        etc.\n                      </td>\n                      <td>\n                        <strong>Ex languages: </strong>C++, Java, Python, Swift,\n                        C#, Ruby, Dart, R etc.\n                      </td>\n                    </tr>\n                  </tbody>\n                </table>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Advangates of OOPs</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  OOPs makes development and maintenance easier where as in\n                  Procedure-oriented programming language it is not easy to\n                  manage if code grows as project size grows.\n                </li>\n                <li>\n                  OOPs provides data hiding whereas in Procedure-oriented\n                  programming language a global data can be accessed from\n                  anywhere.\n                </li>\n                <li>\n                  OOPs provides ability to simulate real-world event much more\n                  effectively. We can provide the solution of real word problem\n                  if we are using the Object-Oriented Programming language.\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Features of OOPs</h4>\n              <div class=\"table-responsive m-2\">\n                <table class=\"table table-striped\">\n                  <caption class=\"text-center\">\n                    Features of OOPs\n                  </caption>\n                  <thead class=\"thead-dark\">\n                    <th>Features</th>\n                    <th>Meaning</th>\n                  </thead>\n                  <tbody>\n                    <tr>\n                      <th>Classes</th>\n                      <td>\n                        A class is a template that is a collection of data\n                        members(variables) & methods(member functions). It is a\n                        bluprint that defines the data & behavior of a given\n                        type. Classes are usually user defined data type.\n                        <br />\n                        <strong>Ex: </strong>A class named Book can be created\n                        with data(book id, name, author, cost) and methods(to\n                        add new book, to get details of specific book).\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Objects</th>\n                      <td>\n                        An object is a real world entity and is an instance of a\n                        class. Once a class is created then we can create any\n                        number of copies of that class using objects. Objects\n                        are an abstract data type and it can include multiple\n                        properties.\n                        <br />\n                        <strong>Ex: </strong>Any no. of objects can be created\n                        of class Book like a book for author ABC; a book for\n                        author XYZ etc.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Data Encapsulation</th>\n                      <td>\n                        Data encapsulation provides a way for binding data and\n                        methoids into single entity called class. In\n                        encapsulation, data is not accessed directly instead it\n                        is accessed using through the methods present inside\n                        that class.\n                        <br />\n                        <strong>Ex: </strong>Consider our phone contacts as a\n                        class; the contact no. and contact name are the data,\n                        the edit, call, message options are the methods that\n                        provides us to interact/access the contact.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Data Abstraction</th>\n                      <td>\n                        Data abstraction provides a way of hiding the internal\n                        details and shows only the functionality. Through this\n                        process, a programmer needs to hide the background\n                        features and relevant data about an object that reduces\n                        the complexity and increases the efficiency.\n                        <br />\n                        <strong>Ex: </strong>In mobile phones, we don't know how\n                        bluetooth works but we clearly know how to use it. Or, a\n                        user need not worry about working of a linked list, he\n                        just need to know how to add/delete/update/search data.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Polymorphism</th>\n                      <td>\n                        Polymorphism means many(poly) forms(morphism). It\n                        provides a way of perfoming similar tasks in different\n                        ways. It refers to programming language's ability to\n                        process objects differently depending on thier data type\n                        or class.\n                        <br />\n                        <strong>Ex: </strong>A + operator can be used to add two\n                        numbers or strings. A function can be overloaded and\n                        accessed depending on it's parameters type and return\n                        type.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Inheritance</th>\n                      <td>\n                        Inheritance is way of inheriting the properties of one\n                        class to another. It allows users to create derived\n                        class(subclass) from an existing class(superclass). Now\n                        this derived class inherits all the proerties from the\n                        superclass/baseclass and can also have it's own\n                        features. It is used to achive runtime polymorphism.\n                        <br />\n                        <strong>Ex: </strong>A new derived class named Cart can\n                        he inherted from class Book that inherits Book's\n                        properties and can also have it's own properties like\n                        quantity, total cost, shipment address etc.\n                      </td>\n                    </tr>\n                    <tr>\n                      <th>Message Passing</th>\n                      <td>\n                        Message passing provides a way for objects to interact\n                        with each other.\n                        <br />\n                        <strong>Ex: </strong>In case we need a new object that\n                        has same properties of an existing one then we can clone\n                        this existing object.\n                      </td>\n                    </tr>\n                  </tbody>\n                </table>\n              </div>\n            </div>"},"thumbnail":{"childImageSharp":{"fluid":{"tracedSVG":"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='400'%20height='225'%20viewBox='0%200%20400%20225'%20preserveAspectRatio='none'%3e%3cpath%20d='M0%20113v112h401V0H0v113m75-41c-3%202-3%202-3%2015s1%2016%206%2016%206-3%206-16-1-15-5-16c-1-1-3%200-4%201m71-1c-3%201-4%203-4%2016%200%2011%200%2012%202%2014%204%204%2010%201%2010-6%200-5-4-6-4-1l-2%204-1-11%201-12%202%204c0%205%204%204%204-1s-4-9-8-7m48%200c-3%201-4%203-4%2016s1%2016%206%2016%206-3%206-16%200-13-3-15c-2-2-3-2-5-1M92%2087v15h4c7%200%2011-6%208-13-1-2-2-4-1-5%203-6%200-13-7-13h-4v16m21-3l-1%2014c-2%200-3%205-1%205l4-2c3-2%203-30%200-30-2%200-2%201-2%2013m12%203v15h5c5%200%205%200%205-3%200-2%200-2-3-2-2%200-3%200-3-4s0-4%202-4c4%200%204-5%201-5-2%200-3-1-3-4%200-4%200-4%203-4s3%200%203-2c0-3%200-3-5-3h-5v16m35-13l2%202c2%200%202%201%202%2013v13h5V89c0-12%200-13%202-13l2-2c0-3%200-3-6-3-7%200-7%200-7%203m49%2013v15h3c2%200%202%200%202-7s1-7%203%201c0%205%201%206%203%206s2%200%201-5-1-10%201-15c1-7-2-11-9-11h-4v16m20%200v15h5V71h-5v16m12%200v15h6c5%200%205%200%205-2%200-3%200-3-3-3s-3%200-3-4c0-3%200-4%202-4%204-1%204-5%201-5s-3%200-3-4%200-4%203-4%203%200%203-2c0-3%200-3-5-3h-6v16m18-1c0%2015%200%2016%202%2016s2-1%202-8c0-9%201-9%203%201%202%206%203%207%205%207h2V71h-2c-3%200-3%200-3%208v9l-2-8c-2-7-3-9-5-9s-2%200-2%2015m19-13c0%202%201%203%203%203s2%200%202%2013v13h5V89c0-12%200-13%202-13l2-2c0-3%200-3-7-3s-7%200-7%202m20%2014v15h6c5%200%205%200%205-2s-1-2-3-2c-3%200-3-1-3-5%200-3%200-4%202-4l2-2c0-2-1-3-2-3-2%200-2-1-2-4s0-4%203-4c2%200%203-1%203-3s0-2-5-2h-6v16m17%200v15h5c7%200%208-2%208-15%200-14-1-16-8-16h-5v16m-181%2033c-2%202-2%203-2%2014%200%2013%200%2013%203%2015%201%201%203%202%204%201%204-1%205-3%205-16%200-12%200-13-2-14-3-3-6-2-8%200m20%200c-4%203-4%2026%200%2029%201%201%203%202%204%201h4c2%200%202%200%202-8%200-7-1-8-3-8-3%200-6%203-3%204%202%200%201%208-1%208s-1-22%201-23l1%203c0%204%200%204%203%204s3-6%200-10c-3-2-5-3-8%200m143%200c-2%202-2%203-2%2015%200%2013%200%2013%202%2015h8c2%200%202%200%202-8v-8h-6l1%206-1%206c-2-1-3-16-2-21%201-3%203-2%203%202%200%203%200%203%203%203%202%200%202%200%202-4s-3-8-6-8l-4%202M93%20135v15h3c2%200%202%200%202-6%200-5%200-6%202-7%2010-3%207-18-3-18h-4v16m20-1c0%2015%200%2016%202%2016s2-1%202-6c0-9%201-9%203-1%200%206%201%207%203%207s2%200%201-5l1-17c0-6-2-9-8-9h-4v15m58%201v15h3c2%200%202%200%202-7s1-7%203%201c0%205%201%206%203%206s2%200%201-5v-8c1-17%200-18-8-18h-4v16m22-3l-3%2015c0%203%200%203%202%203%203%200%203%200%203-3s0-3%203-3c2%200%202%200%202%203s0%203%203%203c2%200%202%200%202-3l-3-15-1-13h-7l-1%2013m18%202v16h3c2%200%202%200%202-9v-8l2%208c2%2012%203%2012%205%200%201-10%202-9%201%201v8h5v-31h-3c-3%200-3%200-4%205l-1%207c0%203-2%200-2-6-1-5-2-6-5-6h-3v15m25%200v16h3c2%200%202%200%202-9v-9l2%208c2%2013%203%2013%205%202%201-11%202-11%201-1%200%209%200%209%203%209h2v-31h-3c-3%200-3%200-4%205l-1%207c0%203-2%200-2-6-1-5-2-6-5-6h-3v15m25%201v15h5v-31h-5v16m13-1c0%2015%200%2016%202%2016s2-1%202-8v-8l2%204%202%208%203%204c2%200%202-1%202-15%200-15%200-16-2-16s-2%201-2%208v9l-2-8c-2-7-3-9-5-9s-2%200-2%2015'%20fill='%23d3d3d3'%20fill-rule='evenodd'/%3e%3c/svg%3e","aspectRatio":1.7699115044247788,"src":"/static/c3b7aeccdfb82c0a33b7bad5bc57977f/ee604/blog49.png","srcSet":"/static/c3b7aeccdfb82c0a33b7bad5bc57977f/69585/blog49.png 200w,\n/static/c3b7aeccdfb82c0a33b7bad5bc57977f/497c6/blog49.png 400w,\n/static/c3b7aeccdfb82c0a33b7bad5bc57977f/ee604/blog49.png 800w,\n/static/c3b7aeccdfb82c0a33b7bad5bc57977f/f3583/blog49.png 1200w,\n/static/c3b7aeccdfb82c0a33b7bad5bc57977f/5707d/blog49.png 1600w,\n/static/c3b7aeccdfb82c0a33b7bad5bc57977f/9ddc6/blog49.png 2240w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"objectOrientedProgramming","thumbnail":"thumbnails/blog49.png"}},"staticQueryHashes":["2987289216","63159454"]}