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

Zip/Unzip multiple files and also include password for zipped file using SSIS

We have many scenario that we need to Zip many files which we come across and then so some operations like either sending it as a email or just moving zipped file to some other destinations etc. But we were using manual method to zip multiple files. In this post, I tried to create a package which will zip multiple files using SSIS. Here for Zipping files purpose, I'm using 7-ZIP which is free software available in google sites. Download files and install onto your system. First let me show how to Zip on file and later I will show how to zip multiple files using SSIS and 7Zip tool. Compressing Single file. Here I'm trying to Zip one single flat file which is of 40MB size. I kept this file in C:\Documents and Settings\\Desktop\test\source folder. Now to compress this file, I will open my SSIS and I'm dragging and dropping EXECUTE PROCESS TASK from Control Flow. Now right click on Execute Process task and go for edit and select Process option. In process tab,

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 move multiple files in ssis and also rename simultaneously

There are two ways to achieve this. 1) We can move the flat files and then rename it. 2) While moving files itself, automatic rename should be done. We will do the second type. The criteria is to rename the files while moving from source to destination. So for that, we need FILE SYSTEM TASK to be included. Secondly since we need to move many files, we will use FOR EACH LOOP CONTAINER. To fetch all the files, we can use FOR EACH LOOP task in SSIS. In collection tab, we can select FOREACH FILE enumerator option for fetching files and we can change enumerator configuration Folder option: Points to source where we need to fetch files. Files: will give us idea whether we need to fetch all the files (*.*) or if we give extension like *.txt, it is going to fetch only  .txt files . Once I give Source name in FOR EACH LOOP container, It is going to fetch all the files corresponding to that path. Retrieve file name: This option is used to let the variables mentioned in VARIA