SlideShare a Scribd company logo
1 of 38
Principles of Object-Oriented Programming

   Why OOP is popular?
   Language and thoughts
   A new way of viewing the world
   Elements of OOP
   Coping with complexity
Difficult Questions

•   What is Object-Oriented Programming?


•   Why is it so popular?


– OOP is a revolutionary idea, totally unlike anything that has come before in
  programming languages


– OOP is an evolutionary step, following naturally on the heels of earlier
  programming abstractions
Why is OOP Popular?

A few possible reasons why OOP is popular:

 •   Hope that it will quickly and easily lead to increased productivity and
     increased reliability (solve the software crises)


 •   Similarity to techniques of thinking about problems in other domains


 •   Hope for easy transition from existing languages (e.g., C or Pascal)
A New Paradigm

   We start by considering the definition of the term ``paradigm'':

   Par a digm n. 1. A list of all the inflectional forms of a word taken as
   illustrative example of the conjugation or declension to which it belongs.
   An example or model. [Late Latein paradigma, from Greek paradeigma,
   modern paradeiknunai, to compare, exhibit.]

OO programming is a new paradigm
    •   New way of thinking about what it means to compute, and about what we
        can structure information inside a computer


Let’s first see the relationship between languages and thoughts
Language and Thoughts

     In linguistics there is a hypothesis that the languages we speak directly
     influence the way in which we view the world (called
    Sapir-Whorf Hypothesis)

   Controversial example of languages influencing thoughts
      – Eskimo (or Innuit) languages have many words to describe snow
      – Arabic languages and camels
   Should not over-generalize the conclusion
      – With time and training, we can also distinguish snow; however, our
        language does not force me into doing so, so it is not natural to me
      – Different languages can lead one (but does not require one) to view the
        world in a different fashion
   This is also applicable to computer programming languages
      – Using OO language can naturally lead one to view the world in OO fashion,
        but does not force one to do
An Example from Computer Languages

   The programming language chosen to solve a problem will decide
    fundamentally the way in which an algorithm is developed
     – A student working in DNA research had the task of finding repeated
       sequences of M values in a long sequence of values:

    ACTCGGATCTTGCATTTCGGCAATTGGACCCTGACTTGGCCA ...

    Wrote the simplest (and therefore, most efficient?) Fortran program :

          DO 10 I = 1, N-M
          DO 10 J = I+1, N-M
          FOUND = .TRUE.
          DO 20 K = 1, M
    20    IF X[I+K-1] .NE. X[J+K-1] THEN FOUND = .FALSE.
          IF FOUND THEN ...
    10    CONTINUE


    Took a depressingly long time.
A Better Solution

A friend writing in APL found a much better solution by rearranging the
data and sorting.

     A C T C G G positions 1 to M
     C T C G G A positions 2 to M+1
     T C G G A T positions 3 to M+2
     C G G A T T positions 4 to M+3
     G G A T T C positions 5 to M+4
     G A T T C T positions 6 to M+5
     ...
     TGGACCGGACCC
     ...


Ran surprisingly fast
What lead to the discovery?

   Why did the APL programmer find the better solution?

    •   Fortran programmer was blinded by a culture that valued loops, simple
        programs


    •   Sorting is a built-in operation in APL, so good APL programmers try to find
        solutions based on sorting


    •   APL programmers were “naturally” led to better solutions


Programming language directs the programmer’s mind to view the problem
   in certain way
Church's Conjecture

   Language affects the way of thinking is believable, but Sapir-Whorf
    hypothesis is controversial
     – It claims that it is possible for one working in one language to imagine
       thoughts that cannot be translated or understood in different languages
   In computer science, we have a directly opposite assertion:

    Church's Conjecture: Any computation for which there exists an
    effective procedure can be realized by a Turing machine.

   Any programming language can simulate Turing machine
     – All languages are equivalent, so anything can be done in any language
     – But it may simply be easier or more efficient to use one language or another
   Power of OO programming languages should be understood in a
    similar way; they make it easy to maintain large S/W projects
Imperative Programming Paradigm

Imperative programming is the ``traditional'' model of computation.

    •   State
    •   Variables
    •   Assignment
    •   Loops


A processing unit is separate from memory, and ``acts'' upon memory
    – Computer is the data manager
    – wandering through memory, pulling values in memory slots
    – transforming them in some manner, and pushing results back in some other
      slots
    – Although this is exactly what happens inside a computer, it is not the way
      people do for solving problems
Visualization of Imperative Programming




Sometimes called the ``pigeon-hole'' model of computation.
Recursive Design




The structure of the part mirrors the structure of the larger unit.
Alan Kay's Description of OO Programming

 OO programming is based on the principle of recursive design.

    1.   Everything is an object
    2.   Objects perform computation by making requests of each other
         through the passing of messages (bundled with arguments)
    3.   Every object has it's own memory, which consists of other objects.
    4.   Every object is an instance of a class. A class groups similar objects.
    5.   The class is the repository for behaviors associated with an object
    6.   Classes are organized into singly-rooted tree structure, called an
         inheritance hierarchy.

 We can illustrate these principles by considering how I go about
 solving a problem in real life.
Illustration of OOP Concepts
              - Sending Flowers to a Friend
To illustrate the concepts of OOP in an easily understood framework, consider
the problem of sending flowers to a friend who lives in a different city.

I can't deliver them myself. So I use my local Florist.

I tell my Florist (named Flo) the address for my friend, how much I want to spend,
and the type of flowers I wish to send.

Flo contacts a florist in my friends city, who arranges the flowers, then contacts a
driver, who delivers the flowers.

If we start to think about it, there may even be other people involved in this
transaction. There is the flower grower, perhaps somebody in charge of
arrangments, and so on.

And so we see, that to solve my problem requires the interaction of an entire
community of individuals.
Elements of OOP – Objects

1. Everything is an object.

Actions in OOP are performed by agents, called instances or objects.

There are many agents working together in my scenario. We have
myself, my friend, the florist, the florist in my friends city, the driver,
the flower arranger, and the grower. Each agent has a part to play,
and the result is produced when all work together in the solution of a
problem.
Elements of OOP – Messages

2.   Objects perform computation by making requests of each other
     through the passing of messages

  Actions in OOP are produced in response to requests for actions,
 called messges. An instance may accept a message, and in return
 will perform an action and return a value.

 To begin the process of sending the flowers, I give a message to Flo.
 She in turn gives a message to the florist in my friends city, who
 gives another message to the driver, and so on.
Information Hiding

Notice that I, as a user of a service being provided by an object, need
only know the name of the messages that the object will accept.

I need not have any idea how the actions performed in response to my
request will be carried out.

Having accepted a message, an object is responsible for carrying it out.
Elements of OOP – Receivers

Messages differ from traditional function calls in two very important
respects:

 •   In a message there is a designated receiver that accepts the message (in
     function calls, there is no receiver


 •   The interpretation of the message may be different, depending upon the
     receiver
Different Actions

var
   Flo : Florist;
   Beth : Wife;
   Ken : Dentist;
begin
   Flo.sendFlowersTo(myFriend); { will work }
   Beth.sendFlowersTo(myFriend); { will also work but in different way}
   Ken.sendFlowersTo(myFriend); { will probably not work }
end;
Behavior and Interpretation

Although different objects may accept the same message, the actions
(behavior) the object will perform will likely be different.

Usually, the specific receiver for any given message will not be known
until run-time, so the determination of what behavior (code) to perform
may be made at run-time, a form of late binding.
 •   Different from early binding of name to code in function calls


The fact that the same name can mean two entirely different operations
is one form of polymorphism.
Responsibility and Non-interference

• Behavior is described in terms of responsibilities
    • My message indicates only the desired outcome
    • I do not want to interfere with how the florist achieves the outcome
    • Responsibility is closely related to non-interference
• Implies greater independence between agents, which is a critical
  factor in solving complex systems
    • OOP is responsibility-driven software design process


• The difference between traditional and OO perspectives can be
  summarized by the following:

``Ask not what you can do to your data structures, but ask what your
  data structures can do for you''
Elements of OOP - Recursive Design

3.   Every object has it's own memory, which consists of other
     objects.

 Each object is like a miniature computer itself - a specialized
 processor performing a specific task.
Elements of OOP – Classes

4.    Every object is an instance of a class. A class groups similar
       objects.
5. The class is the repository for behavior associated with an
   object.

  The behavior I expect from Flo is determined from a general idea I
  have of the behavior of Florists.

  We say Flo is an instance of the class Florist.

  Behavior is associated with classes, not with individual instances. All
  objects that are instances of a class use the same method in
  response to similar messages.
Hierarchies of Categories

But there is more that I know about Flo then just that she is a Florist. I
know she is a ShopKeeper, and a Human, and a Mammal, and a
Material Objects, and so on.

At each level of abstraction I have certain information recorded. That
information is applicable to all lower (more specialized) levels.
Class Hierarchies
Elements of OOP – Inheritance

6.   Classes are organized into a singly-rooted tree structure, called an
     inheritance hierarchy


 Information (data and/or behavior) I associate with one level of
 abstraction in a class hierarchy is automatically applicable to lower
 levels of the hierarchy.
Elements of OOP – Overriding

Subclasses can alter or override information inherited from parent
classes for exceptional cases

 •   All mammals give birth to live young
 •   Some mammals lays eggs
Summary: OOP View of Computing

The OOP view of computation is similar to creating a universe of
interacting computing objects

Because the OOP view is similar to the way in which people go about
solving problems in real life (finding another agent to do the real work!),
intuition, ideas, and understanding from everyday experience can be
brought to bear on computing.

On the other hand, common sense was seldom useful when computers
were viewed in the process-state model, since few people solve their
everyday problems using pigeon-holes.
Coping with Complexity

Another way to understand OOP is to place it in a historical context.

Non-linear behavior of complexity
    – As programming projects become large, they tend to require a team of
      programmers
    – Interesting phenomenon: a task that takes 2 months with 1 programmer
      requires more than 1 month even with 2 programmers


``software crises'' came out when people realized the major problem
 in software development were not algorithmic, but were caused by
 communication difficulties and the management of complexity.
Interconnections - the Bane of Complexity

Many software systems are complex not because they are large, but
because they have many interconnections.

Interconnections make it difficult to understand pieces in isolation, or to
carry them from one project to the next.

The inability to cleanly separate out components makes it difficult to
divide a task between several programmers.

Complexity can only be managed by means of abstraction, by
eliminating information that a programmer do not need to know.

If we examine the history of mechanisms used to solve the problem of
 complexity we can better appreciate the role of OOP.
Assembly Languages

Assembly languages and linkers were perhaps the first tools used to
abstract features of the bare machine.

 •   Addresses could be represented symbolically, not as a number.


 •   Symbolic names for operations.


 •   Linking of names and locations performed automatically
Procedures and Functions

Libraries of procedures and functions (such as mathematical or
input/output libraries) provided the first hints of information hiding.

They permit the programmer to think about operations in high level
terms, concentrating on what is being done, not how it is being
performed.

But they are not an entirely effective mechanism of information hiding,
and they only partially solved the problem of multiple programmers
making use of the same names

An example - A stack
The Problem of Stacks

int datastack[100];
int datatop = 0;

void init() // initialize the stack
{ datatop = 0; }
void push(int val) // push a value on to the stack
{ if (datatop < 100)
      datastack [datatop++] = val; }
int top() // get the top of the stack
{ if (datatop > 0)
      return datastack [datatop - 1];
   return 0; }
int pop() // pop element from the stack
{ if (datatop > 0)
      return datastack [--datatop];
   return 0; }
Block Scoping Didn't Solve the Problem

   Problems with previous implementation
       –   we need to use global variables for the array (no access control)
       –   method names cannot be used elsewhere


   More control over name visibility using block scoping in Algol and Pascal, but
    any scope that accesses the four methods can access the data as well

begin
   var
           datastack : array [ 1 .. 100 ] of integer;
           datatop : integer;
    procedure init; ...
    procedure push(val : integer); ...
    function pop : integer; ...
...
end;
Modules

Modules basically provide collections of procedures and data with
import and export statements [Parnas 1972]
  – they can distinguish public part that are accessible outside and private part
    that are accessible only within the module
  – Enforces need-to-know principle


Solves the problem of encapsulation -- but what if your programming
task requires two or more stacks?
  – Only one stack can be manipulated with a module
  – Need to define a different module for another stack- with what names?


Modules provide information hiding but do not allow instantiation, which
is the ability to make multiple copies of the data area
  – need to develop a new concept
Abstract Data Types

An Abstract Data Type is a programmer-defined data type that can be
manipulated in a manner similar to system-provided data types

 •   Have the ability to instantiate many different copies of the data type.
 •   E.g., define stack as data type and instantiate it as many as you want
 •   Data type can be implemented using provided operations, without
     knowledge of internal representation.
 •   Packages in CLU and Ada can define abstract data types
Objects - ADT's with Message Passing

Characteristics of Objects

 •   Encapsulation -- similar to modules
 •   Instantiation -- similar to ADT's
 •   Messages -- dynamic binding of procedure names to behavior
      • Activity is initiated by a request to a specific object, not by calling a function (do
        you call push with a stack and a data value, or do you ask a stack to push a data
        value onto itself?)
      • Added to message passing, overloading of names and reusing software
 •   Interpretation of message -- it depends on objects receiving it
      • Push for stack and push for door are different
 •   Inheritance -- Allow different data types to share the same code
 •   Polymorphism -- Allow the shared code to be tailored to fit the specific
     circumstances
Summary

•   Object-oriented programming is not simply features added to a
    programming language. Rather, it is a new way of thinking

•   Object-oriented programming views a program as a community of agents,
    termed objects. Each object is responsible for a specific task.

•   An object is an encapsulation of state (data values) and behavior
    (operations).

•   The behavior of objects is dictated by the object class.

•   An object will exhibit its behavior by invoking a method (similar to executing
    a procedure) in response to a message.

•   Objects and classes extend the concept of abstract data types by adding
    the notion of inheritance.

More Related Content

What's hot (20)

Oops
OopsOops
Oops
 
Oops Concepts
Oops ConceptsOops Concepts
Oops Concepts
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented Programming
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
General OOP Concepts
General OOP ConceptsGeneral OOP Concepts
General OOP Concepts
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Oo ps concepts in c++
Oo ps concepts in c++Oo ps concepts in c++
Oo ps concepts in c++
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Concepts of oops
Concepts of oopsConcepts of oops
Concepts of oops
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 
Oops
OopsOops
Oops
 
principle of oop’s in cpp
principle of oop’s in cppprinciple of oop’s in cpp
principle of oop’s in cpp
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
Oops
OopsOops
Oops
 
Oops
OopsOops
Oops
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented language
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Advanced OOP - Laws, Principles, Idioms
Advanced OOP - Laws, Principles, IdiomsAdvanced OOP - Laws, Principles, Idioms
Advanced OOP - Laws, Principles, Idioms
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Characteristics of oop
Characteristics of oopCharacteristics of oop
Characteristics of oop
 

Similar to Oop concept

CSCI-383 Lecture 2: Thinking Object-Oriented (2)
CSCI-383 Lecture 2: Thinking Object-Oriented (2)CSCI-383 Lecture 2: Thinking Object-Oriented (2)
CSCI-383 Lecture 2: Thinking Object-Oriented (2)JI Ruan
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptxUmerUmer25
 
Natural Language Processing (NLP)
Natural Language Processing (NLP)Natural Language Processing (NLP)
Natural Language Processing (NLP)Abdullah al Mamun
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programmingRiturajJain8
 
Object And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesObject And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesJessica Deakin
 
Basics of object oriented programming
Basics of object oriented programmingBasics of object oriented programming
Basics of object oriented programmingNitin Kumar Kashyap
 
Natural Language Processing for development
Natural Language Processing for developmentNatural Language Processing for development
Natural Language Processing for developmentAravind Reddy
 
Natural Language Processing for development
Natural Language Processing for developmentNatural Language Processing for development
Natural Language Processing for developmentAravind Reddy
 
Java OOPs Concepts.docx
Java OOPs Concepts.docxJava OOPs Concepts.docx
Java OOPs Concepts.docxFredWauyo
 
The Four Principles Of Object Oriented Programming
The Four Principles Of Object Oriented ProgrammingThe Four Principles Of Object Oriented Programming
The Four Principles Of Object Oriented ProgrammingDiane Allen
 
M01_OO_Intro.ppt
M01_OO_Intro.pptM01_OO_Intro.ppt
M01_OO_Intro.pptRAJESH S
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.pptkrutika95
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.pptAkash553872
 
Deep Learning for Natural Language Processing
Deep Learning for Natural Language ProcessingDeep Learning for Natural Language Processing
Deep Learning for Natural Language ProcessingParrotAI
 

Similar to Oop concept (20)

CSCI-383 Lecture 2: Thinking Object-Oriented (2)
CSCI-383 Lecture 2: Thinking Object-Oriented (2)CSCI-383 Lecture 2: Thinking Object-Oriented (2)
CSCI-383 Lecture 2: Thinking Object-Oriented (2)
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptx
 
130704798265658191
130704798265658191130704798265658191
130704798265658191
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Natural Language Processing (NLP)
Natural Language Processing (NLP)Natural Language Processing (NLP)
Natural Language Processing (NLP)
 
Ai assignment
Ai assignmentAi assignment
Ai assignment
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
Object And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesObject And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) Languages
 
Basics of object oriented programming
Basics of object oriented programmingBasics of object oriented programming
Basics of object oriented programming
 
Natural Language Processing for development
Natural Language Processing for developmentNatural Language Processing for development
Natural Language Processing for development
 
Natural Language Processing for development
Natural Language Processing for developmentNatural Language Processing for development
Natural Language Processing for development
 
Java OOPs Concepts.docx
Java OOPs Concepts.docxJava OOPs Concepts.docx
Java OOPs Concepts.docx
 
The Four Principles Of Object Oriented Programming
The Four Principles Of Object Oriented ProgrammingThe Four Principles Of Object Oriented Programming
The Four Principles Of Object Oriented Programming
 
M01_OO_Intro.ppt
M01_OO_Intro.pptM01_OO_Intro.ppt
M01_OO_Intro.ppt
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.ppt
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.ppt
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.ppt
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.ppt
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.ppt
 
Deep Learning for Natural Language Processing
Deep Learning for Natural Language ProcessingDeep Learning for Natural Language Processing
Deep Learning for Natural Language Processing
 

Recently uploaded

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Recently uploaded (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

Oop concept

  • 1. Principles of Object-Oriented Programming  Why OOP is popular?  Language and thoughts  A new way of viewing the world  Elements of OOP  Coping with complexity
  • 2. Difficult Questions • What is Object-Oriented Programming? • Why is it so popular? – OOP is a revolutionary idea, totally unlike anything that has come before in programming languages – OOP is an evolutionary step, following naturally on the heels of earlier programming abstractions
  • 3. Why is OOP Popular? A few possible reasons why OOP is popular: • Hope that it will quickly and easily lead to increased productivity and increased reliability (solve the software crises) • Similarity to techniques of thinking about problems in other domains • Hope for easy transition from existing languages (e.g., C or Pascal)
  • 4. A New Paradigm We start by considering the definition of the term ``paradigm'': Par a digm n. 1. A list of all the inflectional forms of a word taken as illustrative example of the conjugation or declension to which it belongs. An example or model. [Late Latein paradigma, from Greek paradeigma, modern paradeiknunai, to compare, exhibit.] OO programming is a new paradigm • New way of thinking about what it means to compute, and about what we can structure information inside a computer Let’s first see the relationship between languages and thoughts
  • 5. Language and Thoughts In linguistics there is a hypothesis that the languages we speak directly influence the way in which we view the world (called Sapir-Whorf Hypothesis)  Controversial example of languages influencing thoughts – Eskimo (or Innuit) languages have many words to describe snow – Arabic languages and camels  Should not over-generalize the conclusion – With time and training, we can also distinguish snow; however, our language does not force me into doing so, so it is not natural to me – Different languages can lead one (but does not require one) to view the world in a different fashion  This is also applicable to computer programming languages – Using OO language can naturally lead one to view the world in OO fashion, but does not force one to do
  • 6. An Example from Computer Languages  The programming language chosen to solve a problem will decide fundamentally the way in which an algorithm is developed – A student working in DNA research had the task of finding repeated sequences of M values in a long sequence of values: ACTCGGATCTTGCATTTCGGCAATTGGACCCTGACTTGGCCA ... Wrote the simplest (and therefore, most efficient?) Fortran program : DO 10 I = 1, N-M DO 10 J = I+1, N-M FOUND = .TRUE. DO 20 K = 1, M 20 IF X[I+K-1] .NE. X[J+K-1] THEN FOUND = .FALSE. IF FOUND THEN ... 10 CONTINUE Took a depressingly long time.
  • 7. A Better Solution A friend writing in APL found a much better solution by rearranging the data and sorting. A C T C G G positions 1 to M C T C G G A positions 2 to M+1 T C G G A T positions 3 to M+2 C G G A T T positions 4 to M+3 G G A T T C positions 5 to M+4 G A T T C T positions 6 to M+5 ... TGGACCGGACCC ... Ran surprisingly fast
  • 8. What lead to the discovery? Why did the APL programmer find the better solution? • Fortran programmer was blinded by a culture that valued loops, simple programs • Sorting is a built-in operation in APL, so good APL programmers try to find solutions based on sorting • APL programmers were “naturally” led to better solutions Programming language directs the programmer’s mind to view the problem in certain way
  • 9. Church's Conjecture  Language affects the way of thinking is believable, but Sapir-Whorf hypothesis is controversial – It claims that it is possible for one working in one language to imagine thoughts that cannot be translated or understood in different languages  In computer science, we have a directly opposite assertion: Church's Conjecture: Any computation for which there exists an effective procedure can be realized by a Turing machine.  Any programming language can simulate Turing machine – All languages are equivalent, so anything can be done in any language – But it may simply be easier or more efficient to use one language or another  Power of OO programming languages should be understood in a similar way; they make it easy to maintain large S/W projects
  • 10. Imperative Programming Paradigm Imperative programming is the ``traditional'' model of computation. • State • Variables • Assignment • Loops A processing unit is separate from memory, and ``acts'' upon memory – Computer is the data manager – wandering through memory, pulling values in memory slots – transforming them in some manner, and pushing results back in some other slots – Although this is exactly what happens inside a computer, it is not the way people do for solving problems
  • 11. Visualization of Imperative Programming Sometimes called the ``pigeon-hole'' model of computation.
  • 12. Recursive Design The structure of the part mirrors the structure of the larger unit.
  • 13. Alan Kay's Description of OO Programming OO programming is based on the principle of recursive design. 1. Everything is an object 2. Objects perform computation by making requests of each other through the passing of messages (bundled with arguments) 3. Every object has it's own memory, which consists of other objects. 4. Every object is an instance of a class. A class groups similar objects. 5. The class is the repository for behaviors associated with an object 6. Classes are organized into singly-rooted tree structure, called an inheritance hierarchy. We can illustrate these principles by considering how I go about solving a problem in real life.
  • 14. Illustration of OOP Concepts - Sending Flowers to a Friend To illustrate the concepts of OOP in an easily understood framework, consider the problem of sending flowers to a friend who lives in a different city. I can't deliver them myself. So I use my local Florist. I tell my Florist (named Flo) the address for my friend, how much I want to spend, and the type of flowers I wish to send. Flo contacts a florist in my friends city, who arranges the flowers, then contacts a driver, who delivers the flowers. If we start to think about it, there may even be other people involved in this transaction. There is the flower grower, perhaps somebody in charge of arrangments, and so on. And so we see, that to solve my problem requires the interaction of an entire community of individuals.
  • 15. Elements of OOP – Objects 1. Everything is an object. Actions in OOP are performed by agents, called instances or objects. There are many agents working together in my scenario. We have myself, my friend, the florist, the florist in my friends city, the driver, the flower arranger, and the grower. Each agent has a part to play, and the result is produced when all work together in the solution of a problem.
  • 16. Elements of OOP – Messages 2. Objects perform computation by making requests of each other through the passing of messages Actions in OOP are produced in response to requests for actions, called messges. An instance may accept a message, and in return will perform an action and return a value. To begin the process of sending the flowers, I give a message to Flo. She in turn gives a message to the florist in my friends city, who gives another message to the driver, and so on.
  • 17. Information Hiding Notice that I, as a user of a service being provided by an object, need only know the name of the messages that the object will accept. I need not have any idea how the actions performed in response to my request will be carried out. Having accepted a message, an object is responsible for carrying it out.
  • 18. Elements of OOP – Receivers Messages differ from traditional function calls in two very important respects: • In a message there is a designated receiver that accepts the message (in function calls, there is no receiver • The interpretation of the message may be different, depending upon the receiver
  • 19. Different Actions var Flo : Florist; Beth : Wife; Ken : Dentist; begin Flo.sendFlowersTo(myFriend); { will work } Beth.sendFlowersTo(myFriend); { will also work but in different way} Ken.sendFlowersTo(myFriend); { will probably not work } end;
  • 20. Behavior and Interpretation Although different objects may accept the same message, the actions (behavior) the object will perform will likely be different. Usually, the specific receiver for any given message will not be known until run-time, so the determination of what behavior (code) to perform may be made at run-time, a form of late binding. • Different from early binding of name to code in function calls The fact that the same name can mean two entirely different operations is one form of polymorphism.
  • 21. Responsibility and Non-interference • Behavior is described in terms of responsibilities • My message indicates only the desired outcome • I do not want to interfere with how the florist achieves the outcome • Responsibility is closely related to non-interference • Implies greater independence between agents, which is a critical factor in solving complex systems • OOP is responsibility-driven software design process • The difference between traditional and OO perspectives can be summarized by the following: ``Ask not what you can do to your data structures, but ask what your data structures can do for you''
  • 22. Elements of OOP - Recursive Design 3. Every object has it's own memory, which consists of other objects. Each object is like a miniature computer itself - a specialized processor performing a specific task.
  • 23. Elements of OOP – Classes 4. Every object is an instance of a class. A class groups similar objects. 5. The class is the repository for behavior associated with an object. The behavior I expect from Flo is determined from a general idea I have of the behavior of Florists. We say Flo is an instance of the class Florist. Behavior is associated with classes, not with individual instances. All objects that are instances of a class use the same method in response to similar messages.
  • 24. Hierarchies of Categories But there is more that I know about Flo then just that she is a Florist. I know she is a ShopKeeper, and a Human, and a Mammal, and a Material Objects, and so on. At each level of abstraction I have certain information recorded. That information is applicable to all lower (more specialized) levels.
  • 26. Elements of OOP – Inheritance 6. Classes are organized into a singly-rooted tree structure, called an inheritance hierarchy Information (data and/or behavior) I associate with one level of abstraction in a class hierarchy is automatically applicable to lower levels of the hierarchy.
  • 27. Elements of OOP – Overriding Subclasses can alter or override information inherited from parent classes for exceptional cases • All mammals give birth to live young • Some mammals lays eggs
  • 28. Summary: OOP View of Computing The OOP view of computation is similar to creating a universe of interacting computing objects Because the OOP view is similar to the way in which people go about solving problems in real life (finding another agent to do the real work!), intuition, ideas, and understanding from everyday experience can be brought to bear on computing. On the other hand, common sense was seldom useful when computers were viewed in the process-state model, since few people solve their everyday problems using pigeon-holes.
  • 29. Coping with Complexity Another way to understand OOP is to place it in a historical context. Non-linear behavior of complexity – As programming projects become large, they tend to require a team of programmers – Interesting phenomenon: a task that takes 2 months with 1 programmer requires more than 1 month even with 2 programmers ``software crises'' came out when people realized the major problem in software development were not algorithmic, but were caused by communication difficulties and the management of complexity.
  • 30. Interconnections - the Bane of Complexity Many software systems are complex not because they are large, but because they have many interconnections. Interconnections make it difficult to understand pieces in isolation, or to carry them from one project to the next. The inability to cleanly separate out components makes it difficult to divide a task between several programmers. Complexity can only be managed by means of abstraction, by eliminating information that a programmer do not need to know. If we examine the history of mechanisms used to solve the problem of complexity we can better appreciate the role of OOP.
  • 31. Assembly Languages Assembly languages and linkers were perhaps the first tools used to abstract features of the bare machine. • Addresses could be represented symbolically, not as a number. • Symbolic names for operations. • Linking of names and locations performed automatically
  • 32. Procedures and Functions Libraries of procedures and functions (such as mathematical or input/output libraries) provided the first hints of information hiding. They permit the programmer to think about operations in high level terms, concentrating on what is being done, not how it is being performed. But they are not an entirely effective mechanism of information hiding, and they only partially solved the problem of multiple programmers making use of the same names An example - A stack
  • 33. The Problem of Stacks int datastack[100]; int datatop = 0; void init() // initialize the stack { datatop = 0; } void push(int val) // push a value on to the stack { if (datatop < 100) datastack [datatop++] = val; } int top() // get the top of the stack { if (datatop > 0) return datastack [datatop - 1]; return 0; } int pop() // pop element from the stack { if (datatop > 0) return datastack [--datatop]; return 0; }
  • 34. Block Scoping Didn't Solve the Problem  Problems with previous implementation – we need to use global variables for the array (no access control) – method names cannot be used elsewhere  More control over name visibility using block scoping in Algol and Pascal, but any scope that accesses the four methods can access the data as well begin var datastack : array [ 1 .. 100 ] of integer; datatop : integer; procedure init; ... procedure push(val : integer); ... function pop : integer; ... ... end;
  • 35. Modules Modules basically provide collections of procedures and data with import and export statements [Parnas 1972] – they can distinguish public part that are accessible outside and private part that are accessible only within the module – Enforces need-to-know principle Solves the problem of encapsulation -- but what if your programming task requires two or more stacks? – Only one stack can be manipulated with a module – Need to define a different module for another stack- with what names? Modules provide information hiding but do not allow instantiation, which is the ability to make multiple copies of the data area – need to develop a new concept
  • 36. Abstract Data Types An Abstract Data Type is a programmer-defined data type that can be manipulated in a manner similar to system-provided data types • Have the ability to instantiate many different copies of the data type. • E.g., define stack as data type and instantiate it as many as you want • Data type can be implemented using provided operations, without knowledge of internal representation. • Packages in CLU and Ada can define abstract data types
  • 37. Objects - ADT's with Message Passing Characteristics of Objects • Encapsulation -- similar to modules • Instantiation -- similar to ADT's • Messages -- dynamic binding of procedure names to behavior • Activity is initiated by a request to a specific object, not by calling a function (do you call push with a stack and a data value, or do you ask a stack to push a data value onto itself?) • Added to message passing, overloading of names and reusing software • Interpretation of message -- it depends on objects receiving it • Push for stack and push for door are different • Inheritance -- Allow different data types to share the same code • Polymorphism -- Allow the shared code to be tailored to fit the specific circumstances
  • 38. Summary • Object-oriented programming is not simply features added to a programming language. Rather, it is a new way of thinking • Object-oriented programming views a program as a community of agents, termed objects. Each object is responsible for a specific task. • An object is an encapsulation of state (data values) and behavior (operations). • The behavior of objects is dictated by the object class. • An object will exhibit its behavior by invoking a method (similar to executing a procedure) in response to a message. • Objects and classes extend the concept of abstract data types by adding the notion of inheritance.