• Register
Welcome to Kodlogs Q&A, programming questions and answer website.

Most popular tags

java python javascript android c# r mysql program spring python-3 php c windows x sql-server spring-boot numpy eclipse sockets arrays exception tomcat ggplot2 ios hibernate sql jdbc jquery string html python-2 ssl node js 7 list entity-framework keytool matlab pandas django git linux csv facebook json asp net java-8 intellij-idea ssl-certificate spring-mvc amazon-web-services reactjs unit-testing macos minecraft pip maven xcode security database class google-chrome elasticsearch tsql unity3d heap-memory for-loop scikit-learn machine-learning winforms glmnet webpack illegalstateexception redirect junit tensorflow docker ubuntu typeerror loops css cmd tcp math datetime cryptography loop int import https x11 sql-server-2012 laravel-5 pdo fatal-error struts java-applet pytorch runtime-error conda visual-studio apache-spark pyspark garbage-collection sql-server-2005 facebook-graph-api entity-framework-4 reporting-services anova keras indentation-error laravel android-studio jupyter-notebook tcplistener orm qt virtualenv webclient prediction headless visual-studio-2010 compiler-errors numpy-ndarray sudo postgresql curl vagrant aspnet reporting dataframe npm nullpointerexception javafx jsp gradle gcc jpa wordpress servlet indentation mongodb firebase scanner sum github deployment socketexception certificate util oracle recursion search syntax connection float httpwebrequest ajax excel dictionary main function number file html5 2 google-chrome-extension payment-gateway error-handling magento paypal aws-vpc amazon-iam aws-lambda executionexception html5-canvas vmware-workstation junit5 kotlin floating-point-precision autowired lifecycleexception catalina return-value joptionpane dom postgresql-9 wkwebview webkit cgroups mingw xming inno-setup jasmine osx-mavericks firebase-cloud-messaging google-play-services xcodebuild facebook-login ruby-on-rails-3 pdfkit selenium-chromedriver selenium-webdriver makefile android-gradle-plugin android-ndk cross-domain xcode6 sybase jsp-tags data-files zoo web-development-server xss functional-dependencies mysql-error-1064 node-sass gulp-sass archlinux sass data-science spring-batch psycopg2 backpropagation texture2d async-await net-mvc-4 google-calendar ruby-on-rails-4 ruby-on-rails dbmigrate wp-mail github-for-windows facebook-android-sdk jsx xcb microsoft-metro react-router spring-data-jpa softmax elastic-beanstalk google-sheets-api google-spreadsheet-api cnf minidump xuggler acumatica gitlab elasticsearch-5 app-transport-security ios10 ios9 cdn cloudflare wampserver plpgsql aptitude systemd salt-stack sysv parent-child android-edittext textview visual-studio-2012 android-workmanager unique-index unity2d electron theano maven-compiler-plugin pickle assetbundle rstudio bar-chart python-tesseract tomcat6 primefaces solr easymock jvm-crash tomcat7 apache-httpclient-4 web-services woodstox discord jersey-2 prepared-statement resultset sencha-cmd sencha-touch-2 sencha-touch wkhtmltopdf powermock fips apex x509certificate ibm-bpm websphere-7 file-permissions file-io accesscontrolexception grizzly atmosphere slick2d lwjgl informetica twitter-bootstrap-3 jax-rs resteasy spring-security-kerberos spring-security kerberos long-integer mapnik git-review vpython continuation homebrew xgboost android-asynctask stack-trace user-interface jaxws-maven-plugin maven-3 maven-2 browser-notsupportedexception google-maps-api-3 google-maps visual-studio-code truststore firebase-authentication aws-organizations php-7 string-formatting cplusplus visual-studio-2015 net-core net-mvc msbuild extension-methods foreign-keys windows-services react-redux inputstream quirks-mode internet-explorer-9 internet-explorer reportingservices-2005 debian linear-regression deep-learning block-device melt reshape2 floating-point webpack-dev-server javascrip 0-lollipop android-5 statsmodels avx eclipseide javafx-2 php-not-recognized command-line putty phpmyadmin tinyurl classnotfoundexception atom-editor android-emulator android-sdk-tools ionic2 cordova foobar2k net-2 net-4 ole-db-provider export-to-excel openrowset windows-10 vagrantfile jvm-arguments global-variables sqlexception autopostback classformatexception eof upstart ipv4 graphviz pydot atom curses unityeditor pandoc tesseract xls oledb redux spotify cxf wamp nio stacked typescript hyperlink outlook jackson ssh keystore applicationcontext iis jstl encryption perfect-square objective-c carthage xcode8 indexing standard-deviation apt xampp printer connector apple cpanel mdf kubernetes destructor gettime arithmeticexception mix iphone probability ioexception heuristics milliseconds disk angular cpu code program modx-revolution goldsky modx prevnext javascript-dictionary stack-smashing device-monitor radio-button android-actionbaractivity android-activity android-fragments java-long unqualified-id ora-12154 javc c++ java nullpointerexception runtime-error drjava awt-eventqueue dsx math-pow ajquery nosuchelementexception appcompatactivity jsf jtextfield awt jpanel thymeleaf inputmismatchexception glassfish deque anaconda jupyter flask lvalue swing servlets netbeans jdk simulation ibm na factorial javax apache arduino boot opengl virtualbox jar jvm margins 2147483647 cloud plot ruby angularjs plugins automation crash card install repository odbc push installer pointers annotations merge editor concatenation swift formatting printf debugging devices module testing color arraylist sequence nested date variables caching expected build response ip pdf directory decimal algorithms release express collections print figure casting url expression validation integer microsoft sorting sort read logging types replace rest limit 8 4 email exe message required text 1 variable time size dll system files table runtime static random code web map http error version 0 my
0 votes
7 views
Object Oriented Programming Concepts
by (320 points)  
reshown by

1 Answer

0 votes
So what is object oriented programming?Is it some kind of new technology? Is it just another programming language? or what is it?So object oriented programming to be simply said,         is a way of thinking.It's an approach to do software development.        Nothing more than that.So is that the only approach for programming? Is that the only available way of thinking in programming?Certainly not.So when we talk about programming,  programming really started with the invention of computers.right from the moment computers were invented, programming was there.because programming in it's very basic is nothing but giving instructions to the computer.and without instructions no computer will ever work.    So there was programming always.At the beginning of the computing era, the programming was usually limited to machine language programmingi.e set of instructions that are aimed at particular machine, particular processor to be honestUsually you will find machine language
code example like this:they are nothing but a sequence of bitsand imagine if you are now developing an Android application and I ask you to write the code in machine languagethat means you will have to write sequence of bits.     Will that really be possible?so that's what everyone thought and people moved on to next way of programmingand that was known as Assembly language programmingassembly language programming was a bit better than machine language programming in a sense that assembly language was more like English.This is nothing like English,  just a combination of          1's an 0's.You can't say what is this. This might be you know...this might be like: I am not gay (I am not BTW) or maybe
I do not know what it is.So it is hard to make sense of
this thing, right?but assembly language, If I were to give you an example it was something like this:ADD A to BMOVE B to CJUMP 9000.so this sentence basically means that: Add A to B, then copy value of B to C and then jump to instruction 9000so this is much better than the assembly
programming, right?Still this was not sufficient. Again I ask you the same question.Create an Android app, for let's say managing the billing system in a WalmartCan you write the code using these kind of
programming instructions?So again they came up with new thing that is:     Structured Programmingone instance of this, is procedural programmingand the most popular example of this would be:              C languageall those languages around 1970s or late 1960s were structured in nature.What you understand by structured in nature?they had these programming constructs that you and I use: if-else, loops, functionsThis is not very structured.if you want to implement looping in assembly language, it's like jump there then go back, something like that.whereas in procedural language you
have proper structured programming constructslike you know decision-making
constructs, looping constructs, functionsso this made programming
much much better in every regardand this was the most popular programming till you could say mid 90sso what went wrong? What is the problem with structure?Now I think my C programs are fantastically readable. They can achieve most of the thingsand people have told me that C is used in operating system implementation.So what's wrong with this?So the thing is; approach in C was to divide the big logic into set of functions.so overall the emphasis was on functionality, not on data.I agree that in C by creating lots of functions. program becomes more manageablebut that has a certain limit.if your program goes beyond, let's say a certain limitfor example 30,000 lines of code is crossedthen even if you breakdown that 30,000 lines of code into five functionslet's say four functions, then each of these
functions will also be about 8000 lines of code, right?So again even these
functions now become unmanageableyou can't hope to possibly debug a 8000 lines of code all at oncefuther more complicated thing is as I said earlier, the emphasis in structured programmingor you could say procedural approach
was on functions not on dataand if you ask any IT client of your company; What is the one thing about which customer really cares?it's not your functionality, it's about data.big corporations and big companies they all pay huge amount just to secure the data or to extract some meaningful information from the data.you can't you know, make data public or you can't possibly let data play lose.so when you divide your C program into five functions,first approach to share data amongst functions is to make data globalwhen you make some data global,
all the functions can use itbut the problem is, there is some data which is
common to these three functionsyou can declare it as global or you
could pass the data as an argument to three functionswhen you pass the same
data as an argument to three functions,it's wastage of memory, right?
We are passing the same data to three functions.so in order to avoid that we can declare it as globalthe problem with global is that; now there is this one more function which has no business with this databut still it has a free right to access that data because global can be accessed by any and every functionso this function might accidentally access this, because of the same name of naming conflict or something elseand it might change the value and this changed value will be affecting the functionality or other three functionsso data is not safebecause nobody thought about data that much. They were all about: function function functionso emphasis was on functionality not on dataThen people thought we need something else. We need something newand then there is this third reason. Which is I think is the most important reason of allthere was this gap between developers and software clients.so let's take this example:We have this sports complex in the neighborhood. They have these fantastic tennis courts over there,which I use a lotbut one problem that I found was;the courts needed to be booked manually by going to their office and that office was open only till 6pmsometimes because of my job timings I could only play late at night (tennis). Let's say from 10:00 to 11:00 pmso in that case I'm would have to make two rounds, two trips to the office.first to book the courts and then again at the night to actually playso I went to the complex to meet the owner and asked him:Why don't you develop an online booking system for your tennis courts?that will be really handy we don't have to make any trip to your office.anyone can book the courts from anywhere in the world. My brother could book it for me, right.He (The owner) was kind of interested in it so we started talking about how to develop that systemI was a technical person who was talking about:frameworks and we shall use this language we shall use that languagemaybe we could use you know this function, you know something like thatand that guy is totally non-technical. He doesn't understand even a bit of computing. Nothing at all, right.so he was talking like: we have 1200 active users, we have 15 security-men, we have 4 tennis courtswe have 5 lights, we provide tennis balls at
this rate, we have court booking timingsWe have this, we have that. We do this, we do that.Are you getting it? What I am trying to say here.I was more concerned about shall we use AngularJS? Shall we use PHP?Shall use JSP?  Shall we use Spring?and he was like: Users, Court, Booking, SecuritySee the gap in thinking. See the gap of
communication between us.In real life, we do not talk about functionality. We talk about objects, things.right now I am feeling terribly humid, you know.So what do I say? Give me air! Give me air!No. I don't say give me air. I say, turn on the fan or turn on the AC.In real life, we talk about objects. In order to get functionality, we seek objects.We don't seek functionality.so that's what that customer is talking about. He is talking about his thingsand I'm a developer so If I am only thinking about:How do I write a function for this thing ? How do I write local variables? How do I write global variables?that's not going to work. Our thinking should match.otherwise I might end up developing something which is of absolutely no relevance to him.so in  that case what was required was, if he says courtI should be able to write something in my code which is called as Court. Which represents this Court.If he says user, I should be able to write
something in my code which represents this user.if he says Booking, I should be able to write something in my code which represents this booking.I should be able to represent the real life objects in my code.I should not be only thinking about functions, local variables, global variables.If he says user, I should have user in my code. If he says court, I should have court in my code.and this is called as objects. I am creating objects in my code.and this way of programming, of trying to simulate real life things into your codeis called as Object Oriented Programmingnow that we have understood why this is required,  let's talk about the basics of  Object Oriented Programming.so now let's talk about the important aspects of Object Oriented programmingyou could say the major pillars of object oriented programming.first and foremost is object.so what is object?Object is a piece of code which represents a real life thing or real life entity for exampleas I was talking to that tennis complex owner he repeatedly talked about something called as Courtevery real life thing has two things:1) It has got attributes which we in English can call as characteristics2) It has got functionality, which in English can be translated to behavior.So court will have attributes like: color, type of surface, dimensionsWith regards to court what kind of functionality does that tennis complex provides?Let us say: doCourtBooking( )courtCleaning( )In programming we map attributes to
nothing but variables or let's say data membersand we map the functionality to functionsSo when we write an object in our code representing a real-life thing we write its variables i.e data memberswhich corresponds to attributesand then we write some functions which correspond to its behavior.The next thing is: ClassSo how we can define a class?I have read somewhere in some book: Class is a collection of objects. Which is so not true.What Class really is:It is a specification of an object.suppose you have been asked to create a student management system for a particular collegeNow obviosuly, the most important object in that system will be student itselfNow you have identified few things about student i.e his attributes and his behaviorfor example you're planning to store attributes:             roll number, name and markswhereas you're planning to store the
behavior that is curricularPerformance( )and extracurricularPerformance( )so where do you specify this, whatever we have decided i.e attributes and behavioryou specify that in classSo you create a class of Student. How do you do that?and then you specify student will have
three attributes: roll number, name and marksand it will have two functionalities curricularPerformance( ) and extracurricularPerformance( )so you specify here in the class of student that it will have these attributes and it will have this functionalityNow if somebody increases the marks of a studenthe (the student) increases his marks through hardwork or something or copyinghis curricularPerformace will changein another semester student's marks go down, because of his breakupthe
by  
...