Object oriented programming

Vechicle class

Classes are a fundamental part of object-oriented programming. They allow variables and methods to be isolated to specific objects instead of being accessible by all parts of the program. This encapsulation of data protects each class from changes in other parts of the program. By using classes, developers can create structured programs with source code that can be easily modified.

The class is one of the defining ideas of object-oriented programming. Among the important ideas about classes are:

A class can have subclasses that can inherit all or some of the characteristics of the class. In relation to each subclass, the class becomes the superclass.

Subclasses can also define their own methods and variables that are not part of their superclass.

The structure of a class and its subclasses is called the class hierarchy.

Objects are pass by reference.

Principles of OOPs :

  1. Inheritance
  2. Encapsulation
  3. Polymorphism

Inheritance :

Inheritance.swift

Encapsulation :

  • Everyone knows how to access it.
  • Can be easily used regardless of implementation details.
  • There shouldn’t any side effects of the code, to the rest of the application.

Polymorphism :

  • Overloading in simple words means two methods having same method name but takes different input parameters. This called static because, which method to be invoked will be decided at the time of compilation
  • Overriding means a derived class is implementing a method of its super class.
Polymorphism.swift

Data abstraction:

If you enjoyed reading this post, please share and recommend it so others can find it 💚💚💚💚💚💚 !!!!

--

--

--

iOS and tvOS developer, dreamer, photographer 🤨

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Publish to NuGet with GitHub actions

Composition Over Inheritance

DialogFlow: A Simple Way to Build your Voicebots and Chatbots

System Design simplified

Being Predictable

Discrete-Time Design Using Python Filter Design Analysis Tool

Welcome to the Era of No-Code

Launching Terp Data

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhimuralidharan

Abhimuralidharan

iOS and tvOS developer, dreamer, photographer 🤨

More from Medium

GIT — Branches and practices

Is it necessary to have an internet connection to use Git locally?

Solid Principles

Principle of Least Surprise