Concepts of OOP
Object-Oriented Programming (OOP) is a software design approach that builds programs around real-world "objects" containing data and actions rather than just functions.
<p></p><h3>Definition</h3><h3><span style="font-weight: 400; color: rgb(0, 0, 0);">Object-Oriented Programming (OOP) is a way of writing computer code where you structure your software around digital "objects." Each object acts like a real-world entity, combining </span><span style="color: rgb(0, 0, 0);">data</span><span style="font-weight: 400; color: rgb(0, 0, 0);"> (what it knows or has) and </span><span style="color: rgb(0, 0, 0);">actions</span><span style="font-weight: 400; color: rgb(0, 0, 0);"> (what it can do).</span></h3><h3>Explanation</h3><h2><p>Imagine you are building a video game with cars:</p><ul><li><p><b>Class (The Blueprint):</b> Think of a class as the factory design plan for a car. It specifies that every car will have a color and a speed, and that every car can drive or brake.</p></li><li><p><b>Object (The Actual Car):</b> Using that blueprint, you build a physical <b>Red Sports Car</b> or a <b>Blue Sedan</b>. Each individual car is an <b>object</b>. It has its own specific color and speed, but it uses the behavior defined by the blueprint.</p></li></ul><p>Instead of writing long lists of loose instructions, OOP keeps related data and behaviors neatly packaged inside these objects.</p></h2><h3>Key Points (The 4 Pillars)</h3><h2><ol><li><p><b>Encapsulation (Data Hiding):</b> Keeps internal details safe inside the object. Users can interact with the object using approved buttons without messing with the complicated wiring inside.</p></li><li><p><b>Abstraction (Simplifying Complexity):</b> Shows only the necessary features to the outside world while hiding complex mechanics. (For example, you press a gas pedal to drive a car without needing to understand how the engine burns fuel.)</p></li><li><p><b>Inheritance (Reusing Blueprints):</b> Allows a new blueprint to copy properties from an existing one. A "Electric Car" blueprint can inherit everything from "Car" and simply add battery features, saving time and code.</p></li><li><p><b>Polymorphism (Multiple Forms):</b> Allows different objects to respond to the same command in their own unique way. A <code data-path-to-node="11,3,0" data-index-in-node="114">makeSound()</code> command makes a Dog object bark and a Cat object meow.</p></li></ol><div><span><strong>Apart from the four pillars:-</strong></span></div><div><ul><li><span style="color: black;">Simula is
considered the first object-oriented programming language.</span></li><li><span style="color: black;">Smalltalk is
considered the first truly object-oriented programming language.</span></li><li><span style="color: rgb(0, 0, 0);">The
popular object-oriented languages are <a href="https://www.javatpoint.com/java-tutorial" style="">Java</a>, <a href="https://www.javatpoint.com/c-sharp-tutorial" style="">C#</a>, <a href="https://www.javatpoint.com/php-tutorial" style="">PHP</a>, <a href="https://www.javatpoint.com/python-tutorial" style="">Python</a>, <a href="https://www.javatpoint.com/cpp-tutorial" style="">C++</a>, etc</span><span style="color: rgb(0, 0, 0);"><strong>.<!--StartFragment-->
<div><span><strong> </strong></span></div></strong></span></li></ul></div></h2><h3>Advantages</h3><h2><ul><li><p><b>High Reusability:</b> You can reuse existing blueprints across multiple projects without starting from scratch.</p></li><li><p><b>Easy Maintenance:</b> If something breaks, you can fix or update a single object without breaking the entire program.</p></li><li><p><b>Better Organization:</b> Large codebases become much cleaner and easier to navigate because code is split into clear, logical units.</p></li><li><p><b>Improved Security:</b> Encapsulation protects sensitive data from being accidentally modified by other parts of the code.</p></li></ul></h2><h3>Disadvantages</h3><h2><ul><li><p><b>Steeper Learning Curve:</b> It takes more time and thought to design blueprints upfront compared to writing simple sequential scripts.</p></li><li><p><b>Larger Program Size:</b> OOP programs often require more lines of code and memory, making them slightly larger.</p></li><li><p><b>Slower Execution Speed:</b> Because of the layered structure and object management, OOP can run slightly slower than direct procedural code in high-performance tasks.</p></li><li><p><b>Over-Engineering Risk:</b> For very simple or small tasks, setting up classes and objects can add unnecessary complexity.</p></li></ul></h2><p></p>
