Skip to main content

Classes, Methods, Objects..!!!! How do we relate to real world to understand it

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

Popular posts from this blog

BIG Data, Hadoop – Chapter 2 - Data Life Cycle

Data Life Cycle The data life cycle is pictorial defined as show below:     As we see, in our current system, we capture/ Extract our data, then we store it and later we process for reporting and analytics. But in case of big data, the problem lies in storing and then processing it faster. Hence Hadoop takes this portion, where it stores the data in effective format (Hadoop distributed File System) and also process using its engine (Map Reduce Engine). Since Map Reduce engine or Hadoop engine need data on HDFS format to process, We have favorable tools available in market to do this operation. As an example, Scoop is a tool which converts RDBMS to HDFS. Likewise we have SAP BOD to convert sap system data to HDFS.

SSIS: The Value Was Too Large To Fit In The Output Column

I had a SSIS package where I was calling a stored procedure in OLEDB Source and it was returning a “The Value Was Too Large to Fit in the Output Column” error. Well, My Datatype in OLEDB source was matching with my OLEDB Destination table. However, when I googled, we got solutions like to increase the output of OLEDB Source using Advanced Editor option . I was not at all comfortable with their solution as my source, destination and my intermediate transformation all are having same length and data type and I don’t want to change. Then I found that I was missing SET NOCOUNT ON option was missing in Stored Procedure. Once I added it, my data flow task ran successfully. 

How to Copy or Move Multiple Files from One Folder to Another Folder using Talend

Hello all, In this Post, I will explain how to move Multiple Files from One Folder (Say Source) to Other folder (Say Destination). This Post will also helps you to understand How to Declare Variable and Use it. To Declare a variable, We are go to use Contexts option in repository. Lets say we have two .txt files in Path D:/Source/ . My Requirement is to move the files from Source Folder ( D:/Source/ ) to Destination Folder ( D:/Dest/ ). Step 1: Open a New job Step 2: Now right click and Create a New Contexts from Repository. Give some Name and give Next. Step 3: Now Fill in the Source Directory Details where the loop on files should happen as shown in the snippet and give finish. Step 4: Now Context is created and The values will be changing based on each file in Folder. Step 5: Click and Drag the context from Repository to Context Job Window below the Job Designer. Step 6: If we Expand the Contexts, We can find the variable SourcePath is holdi...