101.school
CoursesAbout
Search...⌘K
Generate a course with AI...

    Intro to computers and programming

    Receive aemail containing the next unit.
    • Computer Basics
      • 1.1Overview of Computers
      • 1.2Understanding Operating Systems
      • 1.3Understanding Computer Networks
    • Introduction to Programming
      • 2.1What is Programming?
      • 2.2Basics of a Program
      • 2.3How a Program Runs on a Computer
    • Introduction to Coding
      • 3.1Writing your First Code
      • 3.2Language of Coding
      • 3.3Common Coding Practices
    • Scripting Basics
      • 4.1What is Scripting?
      • 4.2Difference Between Coding and Scripting
      • 4.3First Look at Shell Scripts
    • Basics of a Programming Language
      • 5.1Understanding Syntax
      • 5.2Basic Constructs – Loops & Conditionals
      • 5.3Functions and Procedures
    • Intermediate Programming
      • 6.1Arrays and Lists
      • 6.2File Handling
      • 6.3Error Handling
    • Introduction to Object Oriented Programming
      • 7.1Principles of Object Oriented Programming
      • 7.2Classes and Objects
      • 7.3Inheritance and Encapsulation
    • Practical Uses of Scripting
      • 8.1Process Automation with Scripts
      • 8.2Using Scripts for Data Manipulation
      • 8.3Web Scraping with Scripts
    • Algorithms and Data Structures
      • 9.1Basics of Algorithms
      • 9.2Introduction to Data Structures
      • 9.3Practical Uses of Data Structures
    • Code Efficiency
      • 10.1Writing Efficient Code
      • 10.2Debugging and Testing
      • 10.3Code Performance Analysis
    • Managing Code Project
      • 11.1Understanding Version Control
      • 11.2Use of GitHub for Project Management
      • 11.3Collaborative Coding Practices
    • Real World Coding Examples
      • 12.1Review and Analysis of Real World Code
      • 12.2Case Study—Use of Code in Solving Real World Problems
      • 12.3Building and Presenting a Mini Coding Project
    • Future Learning and Wrap Up
      • 13.1Essentials for Advanced Learning
      • 13.2Overview of Other Programming Languages
      • 13.3Course Wrap Up and Next Steps

    Introduction to Object Oriented Programming

    Principles of Object Oriented Programming

    Object Oriented Programming (OOP) is a programming paradigm that provides a means of structuring programs so that properties and behaviors are bundled into individual objects. It is a way to write programs using classes, which in turn are templates for objects.

    What is Object Oriented Programming?

    In OOP, each object is an instance of a class. Objects are entities that have attributes (properties) and behaviors (methods). For example, a car can be an object. It has attributes like color, model, and brand, and behaviors like start, stop, and accelerate.

    Four Principles of OOP

    There are four fundamental principles in OOP: Abstraction, Encapsulation, Inheritance, and Polymorphism.

    Abstraction

    Abstraction is the process of hiding the complex details and showing only the essential features of a particular object or concept. In OOP, an abstract class can be used to define a base class with methods that the derived classes would implement.

    Encapsulation

    Encapsulation is the process of bundling the data and the methods that operate on that data into a single unit, i.e., class. It is a protective shield that prevents the data from being accessed by the code outside this shield.

    Inheritance

    Inheritance is a mechanism in which one class acquires the properties (methods and fields) of another class. With the use of inheritance, information is made manageable in a hierarchical order. The class which inherits the properties of another class is known as the subclass, and the class whose properties are inherited is known as the superclass.

    Polymorphism

    Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. It allows us to perform a single action in different ways.

    Benefits and Drawbacks of OOP

    The main advantage of OOP is that it simplifies software development and maintenance by providing some concepts:

    • Objects can also be reused within an across applications. The reuse of software also lowers the cost of development. More effort is put into the object-oriented analysis and design, which lowers the overall cost of development.
    • It makes software easier to maintain. Since the design is modular, part of the system can be updated in case of issues without a need to make large-scale changes.
    • Reuse also enables faster development. Object-oriented programming languages come with rich libraries of objects, and code developed during projects is also reusable in future projects.

    However, OOP can be seen as more complex to understand and write than procedural code, and it can be less efficient and slower in terms of execution speed.

    By understanding these principles, you can start to see the world in terms of objects. This is a key step in becoming a successful object-oriented programmer.

    Test me
    Practical exercise
    Further reading

    Good morning my good sir, any questions for me?

    Sign in to chat
    Next up: Classes and Objects