In my last post, i had posted Basic definitions related with OOPs, here we will explain the details about Class and Objects.
Objects
If we talk about OOPs then that means Everything is an Object. if you are Solving a problem in OOPs ,then element of problem domain will map to object in solution of that problem.
What an object represents?
Consider yourself, what you can represent about yourself, you have height, you have some weight, your skin complexity means these all things will present your state at one time.
Now what you can do? you can walk , you can talk or can do things.. what it represents? it represents your behavior.
Now you might be having any social security number or may be any number that meant for you only, means that will represent your identity and through that number or identity no body else can be represented.
An object has state,behavior and identity. An object can have internal data (which gives it state), methods (to produce behavior), and each object can be uniquely distinguished from every other object—each object has a unique address in memory.
Class
A class represents categories of object.
A class provides template for creating an object.
A class represent a type in java.so when we create any object for a class then that object will have some type and that type will be represented by the name of class.
While writing a java program , when we write any class we write a variable that is called a s field in world of java, along with variable we write methods which can perform some operations.
Field in a class used to store value that represents particular property of an object and using operations we can manipulate the values stored in variable or fields.
The members (elements) of each class share some commonality: Every customer has an account, every account has a balance, every teller can accept a deposit, etc.
At the same time, each member has its own state: Each account has a different balance, each teller has a name.
Thus, the tellers, customers, accounts, transactions, etc., can each be represented with a unique entity in the computer program. This entity is the object, and each object belongs to a particular class that defines its characteristics and behaviors.
NOTE: When we talk about software design, then in that case we need to consider "Object as Service Provider". And considering Object in that way supports High Cohesion. In simple words high cohesion means how different components fits together.
In upcoming post i will explain about this quality of object with a use case.
NOTE: When we talk about software design, then in that case we need to consider "Object as Service Provider". And considering Object in that way supports High Cohesion. In simple words high cohesion means how different components fits together.
In upcoming post i will explain about this quality of object with a use case.
No comments:
Post a Comment