Object oriented programming is a style of programming that focuses on using objects to design and build applications.
That means if we have to write a software which represents some real world system or some hypothetical system - we try to find out key objects in it and then see how they interact with each other.
For example say a Carrom Board Game - if you wanted to write software for this you will think of main objects in it - the board itself, striker, wood-disk, powder, player, queen, etc. Then you will think about the actors and their actions - player hits striker at some angle, etc
Another example can be say you are writing a File System - here although there are no physical objects - but still there can be concepts which can be modeled - like files, directories, permission, access, owner, user, etc
So it's not just about purely OOP but more about how various parts of code interact with each other. How the dependencies are managed between these pieces of code. How can these pieces of code structure themselves so that they are easily modify-able, how do these structures of code deal with changes and addition of new features.
Common terms one hears when writing code : Object, Class, Encapsulation, Abstraction, Inheritance, Polymorphism
Lets talk about Object, others we can talk about in future posts
Object is the basic building block - it represents a real world entity or a concept. For example - cat named Tom
Now this is a specific Object representing Tom in code. Depending on which language you are using the code will differ, but basically Tom will have some properties - which will represent its current state like - grey color, green eyes, etc and then some methods which will list what kinds of actions he can do - eg since its a cat it can meow, run, follow, eat etc.
So imagine we have this Tom object in our software program, we can simulate actions to it or make it interact with other objects, for example imagine there is a mouse named Jerry. Then we can do :
That means if we have to write a software which represents some real world system or some hypothetical system - we try to find out key objects in it and then see how they interact with each other.
For example say a Carrom Board Game - if you wanted to write software for this you will think of main objects in it - the board itself, striker, wood-disk, powder, player, queen, etc. Then you will think about the actors and their actions - player hits striker at some angle, etc
Another example can be say you are writing a File System - here although there are no physical objects - but still there can be concepts which can be modeled - like files, directories, permission, access, owner, user, etc
So it's not just about purely OOP but more about how various parts of code interact with each other. How the dependencies are managed between these pieces of code. How can these pieces of code structure themselves so that they are easily modify-able, how do these structures of code deal with changes and addition of new features.
Common terms one hears when writing code : Object, Class, Encapsulation, Abstraction, Inheritance, Polymorphism
Lets talk about Object, others we can talk about in future posts
Object is the basic building block - it represents a real world entity or a concept. For example - cat named Tom
Now this is a specific Object representing Tom in code. Depending on which language you are using the code will differ, but basically Tom will have some properties - which will represent its current state like - grey color, green eyes, etc and then some methods which will list what kinds of actions he can do - eg since its a cat it can meow, run, follow, eat etc.
So imagine we have this Tom object in our software program, we can simulate actions to it or make it interact with other objects, for example imagine there is a mouse named Jerry. Then we can do :
tom.follow(jerry);
No comments:
Post a Comment