DEV Community

Cover image for OOPS!!
Dipti Gandhi
Dipti Gandhi

Posted on


This article requires complete silence of all the negative voices and something to munch.Though its not very big but it might leave you with lots of thoughts I hope.
Object Oriented Programming Language mainly support Objects as language feature.
Since the begin of my career, objects are following my code like a shadow.Even if I am not creating it,it is getting created by the library for my code. When I began my Javascript journey statements like "every thing in javascript is Object" made me more curious to deep dive in objects. But when you decide to do deep dive you will mostly come across entire computer science knowledge which is quite vast for our brain to consume all together.
Sometimes I feel my thirst for understanding the entire nomenclature of language itself is wrong. I have fall into that loop hole so many times. I do learn alot to some point, but to understand the rest of it I need to work on real coding challenge which will create basefor my understanding, rather than imagining everthing without working on real world application.
Programming concept definations are quite abstract,I love wikipedia explaination where you get the hints of words for those abstract concept to look for but then it becomes so interesting that you will keep going deeper and deeper from one article to another and you will forget which one to holdon to.
Anyways Objects store the state and provide methods to access its state or perform operations.Techically we call them Properties and functions. Objects are actually which takes place in the memory compare to function which just executes.

Idea of reusability of code is so dominate and efficient in programming world, object itself represent a gist of it, e.g if Object A, B and C represents a different Todo application but share lots of commonalities then to manage commonalities amongs those objects we create a class Todo, which stores the common operations(method) and provide a way to save the state(properties) of the Todo. Thats how classes originated to manage the common behaviour of objects in the object oriented programming which supports classes e.g java

Cool,So now I can understand the tech defination for classes: class is a template from which we can create Object of same types.(type word reminds me of typescript :P)

What about the common functionality between the classes,in OOP we have a mechanism for managing that as well through interface. Interface lets you declare just a function, which you can be define inside a class that implemented the interface(You can google about it more ).So Interfaces are good way of sharing the common operation of classes.Javascript is not type language and hence doesn't support interface, but we can implement interface using typescript.

I would like to highlight that object represents type of class(Object:class).Have you heard the phrase "Sharing is caring", this plays a very important role in the programming world, we have mechanism like inheritance, where we let one class/object inherit methods, state into another.Self-reference (i.e "this" concept) also lets us dynamically bind/extend the object to the other objects, thereby creating parent-child relationship, this mechanisnm is also know as delegation.

Languages that implements object can be typed or untyped. Typed languages implements certain rules which acts as an overhead to our code and makes us define the state that our program will have after running certain operation written into our code. State in this case would be string, objects of certain type e.g Obj{xyz:string, abd:array}, this state would be simply return value of a function.
Untype language never bothers with type of objects or how nicely you have written code, it will simply execute the program which will look for certain value and perform the operation on them, without checking the type of the value or wheather these are correct value of type on which certain operation can be perform. It will stop executing the program when its not able to find the value itself.
Javascript is untype, typescript provides the mechanism of type checking before executing the program.
Hence typed language like Kotlin will not execute the program and will give compile time error for types errors.

Conclusion : So basically Object stores our state, provides methods to access/change that state. Object shares their responsibility with other Objects, they are data-structure of the language whose main feature is object e.g Javascript. Type of object can be class or root Object itself. Mechanism like inheritece, delegation, self-reference increases the shareability of object, looks like I am repeating myself so stopping here

My aim was to talk about this concept and give part of the gist of big view of language itself in most simple way.(I will add the examples in the future)

Top comments (0)