Hello
Everyone,
Since, I started off my career, I was
hearing about classes, Methods, publics, private, objects blab blab and I tried
a lot to understand it but somehow I couldn’t get a chance to learn it properly.
(I am Electronics and Communication Engineer, LOL)
However, now I made one sincere
attempt and learnt a bit of it, which I would like to share with you guys who
are having trouble in understanding it, as it was with me.
Let
us get into some story how an organization works and from there, we will try to
relate the classes, objects, methods.
We all have come across how a
Multi-National Company works. Consider for instance, Microsoft Inc. Microsoft
is one of the top MNC, anyone would dream to work with. We also know that there
are many departments in Microsoft. As example, Data Management team, Licensing
Team, Marketing team, Development team, testing team etc. Everyone has their
own functionality and work they do is different from each other though all are
working for same company called “Microsoft”.
But if we observe, Microsoft is not
operating these teams in same region. What I mean is, if finance team is
sitting in France, Microsoft Data management team is in India. So Microsoft
from France has its own CEO, Microsoft India has its own CEO and all are
reporting to Microsoft US which is supposed to be headquarter of Microsoft.
There is policy which is been
followed in Microsoft. Though being under same company, one cannot go ahead and
talk or take information from other office of Microsoft, just like that. This
means, a person from France Microsoft cannot just take data or update the data
from Microsoft India, without the permission of India’s Microsoft heads. This
is applicable to most of MNC and banking domains.
However, India’s Microsoft can give
some privilege to other offices. Say, they can have look into their customer
data. India’s Microsoft has made public view of data for the employees in
Microsoft worldwide, so that they can just go ahead and view the data and but
update, delete and other access all those functionality is disabled.
There are many reasons for this. Say
for example, a Marketing team from Microsoft US, wants to sell some products,
to customers in India, then it is required for them to view the customer data
right.
Say, Now Microsoft released some new
windows OS. From Microsoft, US, a marketing guy has a plan to sell to some
people in India. So what he does, he goes to India’s database, take some
customers details, Copy it and paste it in an Excel sheet. (Which contains
Information like Name of customer, Email, Phone Number, Address, Delivery
Address, Zip Code etc.). Later, he check first customer, and give a call to him
to sell the products.
This
is same analogy goes with OOPS concepts, where the words called classes,
methods, private, public etc., are seen.
In
above scenario, each country represents a class. India is a class, France is a
different class and so on and each class does a unique operations. (In my
example, each country does a unique operations- Data management, Finance etc.).
Microsoft
US, being the headquarters is head of all and hence the same in coding, could
be called as “MAIN CLASS”. This is the starting point, everything is executed
or commands are given to other countries.
This
is represented in general form like:
Class
MicrosoftUSA {
Public
static void Main (String args [])
{
<<Bill Gates sits here>>
<< Monitoring other
Countries>> (Classes)
}
}
Here
you can see there are many keywords seen other than keyword called “Main”.
Public: if public keyword is there, then it
means, any country can contact them.
Void: it means: It is not going to give
any result to anyone.
If we take Microsoft India, They have
some daily activities happening with them. Microsoft India themselves have many
teams. One team will be looking after Data testing, one team looking after Data
updates etc. Each team doing some work and functions are in coding terminology
called as “Methods”.
Methods
are nothing but functions one does. This Similar with your SQL functions.
Say
Microsoft UK wants to see the data from India, they will check whether
Microsoft India is public, meaning, they make a check whether they can contact
them or not.
We know now, Microsoft India is being
transparent and Microsoft UK will look, what are the things that Microsoft
India is allowing us to do. When they investigated, they got to know that
Microsoft India is allowing to view one of the department/team which is working
in reading customer detail.
So a marketing guy, from Microsoft
UK, can open his excel sheet, copy some of the records and works on them. The
excel sheet which holds all the details is called “Object”. An Object will hold
the information from other class methods. (A excel sheet, holding the
information of India’s Customer Details).
So
now question is, how other country looks like? This in coding term, let’s write
a simple structure how India looks like.
Public
class MicrosoftINDIA
{
Public string ReadCustomerDetails()
{
<< Team which is working on
Customer Details which has an access to other countries (Classes)>>
}
Private void WriteCustomerDetails()
{
<< Team which is working on
data updates and deletes but it is not allowed by other counties to view or to
access (France, UK cannot view this part) >>
}
}
So by putting keyword called Private,
we are blocking other classes (countries) to view or have access. Then, what is
use of Private? This is common question. Private is used and can be accessed
within the same class they exists, Meaning, India’s data manipulation team
working to help other team in India to look good so that some other marketing
person from UK, can have a good look of the records rather than junk records.
This
is all fine but the question here is, how a UK guy or a France guy can create
an Object (Excel)? How it looks in a code.
So
what is left, let us go ahead create a France class and then create an object.
Class
MicrosoftFRANCE {
MicrosoftINDIA ExcelSheetIndia = new
MicrosoftINDIA ()
ExcelSheetIndia. ReadCustomerDetails()
}
What
we did here is, we called Microsoft India and Created an Object Called
“ExcelSheetIndia”. By doing this, every time we use, ExcelsheetIndia, it
default understands, where this Excelsheet is getting generated.
Now
Once, ExcelSheet is created, now we need to fill the records, from India. This
is done by next like, by calling the Method (Department) from India.
ExcelSheetIndia.ReadCustomerDetails(), will make to execute (make them to
work) the ReadCustomerDetails(). When ReadCustomerDetails() team are working,
meaning, they are generating records to view to France Excelsheet.
In
other words, Say, India having many teams, which are now globally accessible.
Meaning, Other than data Reading team, Say Licensing team from India is also
giving away their data’s to other Microsoft offices.
So
using Object.method, we are telling, which department
Information to access. In above example, we are telling, We need
ReadCustomerDetails() method but not LicensingTeam() method.
Comments
Post a Comment