Android Mastery: Classes and Objects

Photo by AltumCode on Unsplash

Android Mastery: Classes and Objects

Kotlin Developer Path Ep1

Asalaam Aleykum and greetings to you all.

Almost 2 weeks ago, I went for an interview, for the role of Mobile Development Trainer. I had no idea how to prepare for such an interview, as I had not previously applied for a trainer/teacher role.

Long story short, I got to the interview and the interviewers went to the basics of Kotlin, with a huge emphasis on Object Oriented Programming. I froze and couldn't remember any of the concepts.

This motivated me to study and come up with this blog post, which may turn into a series, as I attempt to master Android before the end of July 2024(In shaa Allah).

So let's have a quick rundown of OOP concepts, shall we?

Objects and Classes

These two interchangeable words/concepts can confuse you if you're not keen so let's break them down.

  • Class: A class is a blueprint that contains instructions on an object's properties(characteristics) and methods. A good example would be that of a house, the class would be equivalent to the architect's blueprint of the house that will be used to construct the house object.

  • Object: Once you have the blueprint, an object is the real-world implementation of the properties and methods of the class. In the example above, the house would be the real-world implementation or manifestation of the class.

  • Object Oriented Programming: OOP is a framework that teaches how to enclose data, logic, and behaviors in objects. The basic concepts of OOP are:

    • Encapsulation: This is the wrapping of properties and methods that act on those properties in a class. for example, a house encapsulates doors, windows, rooms, and more.

    • Abstraction: This is hiding the internal implementation logic as much as possible. For example, using the toilet doesn't require to learn how the toilet works to clean and flush away the waste.

    • Inheritance: enables us to build classes upon the properties and methods of other classes, by establishing a parent-child relationship e.g. Samsung phones and iPhones are both children of the mobile phone class.

    • Polymorphism: This allows us to use differently designed objects in a single common way. For example, we can connect to our home Wi-Fi without necessarily needing to know how each router we keep changing works by design and technology.

Conclusion

That sums up the basic definitions of OOP concepts, get yourself acquainted with each so you don't have to embarrass yourself at an interview, as I did. All the best guys, Asalaam Aleykum!!

See you on the next one, In shaa Allah.