I Can’t Sleep - Object-Oriented Programming | Calm Sleep Reading
Episode Date: May 14, 2021Unwind with this calm bedtime reading on object-oriented programming, a peaceful way to ease insomnia and find restful sleep. Benjamin’s soothing voice explains the core concepts of this programming... paradigm, from classes and objects to inheritance and polymorphism, turning technical details into gentle, fact-filled narration. This is not whispering or hypnosis—just relaxing education designed to quiet the mind, reduce stress, and ease sleepless nights. Learn while you rest, and let Benjamin’s steady cadence carry you into dreams. Press play, close your eyes, and drift away into peaceful, restorative sleep. Want More? Request a Topic: https://www.icantsleeppodcast.com/request-a-topic Ad-Free Episodes: https://icantsleep.supportingcast.fm/ Shop Sleep-Friendly Products: https://www.icantsleeppodcast.com/sponsors Join the Discussion on Discord: https://discord.gg/myhGhVUhn7 This content is derived from the Wikipedia article on Object-Oriented Programming, available under the Creative Commons Attribution-ShareAlike (CC BY-SA) license. Read the full article: Wikipedia – Object-Oriented Programming. Happy sleeping! Learn more about your ad choices. Visit megaphone.fm/adchoices
Transcript
Discussion (0)
You're listening to a Glassbox media podcast.
What if I told you that most of the modern day self-help advice you've been hearing could actually make you worse?
The key to a better life isn't about feel-good gimmicks that sound catchy.
The Mentally Stronger Podcast gives you access to a licensed therapist who shares science-backed tools that will actually change your life.
Hi, I'm Amy Morin, psychotherapist, mental strength trainer, and international best-selling author.
In each episode, we cover research-back strategies, like how to stop relying on willpower and start creating habits for lasting change.
And the five mental strength-building exercises you can do from your couch.
I also speak to world-class experts like Dr. Nicole Kane, who shares how to permanently heal anxiety by addressing the root cause.
With over 200 episodes in our catalog, this podcast is for you if you're ready to crush self-doubt, conquer challenges,
become stronger than ever with therapist-approved strategies that can change your life.
Listen to Mentally Stronger with Therapist Amy Morin, wherever you get your podcasts.
Welcome to the I Can't Sleep Podcast, where I read random articles from across the web
to bore you to sleep with my soothing voice. I'm your host, Benjamin Boster.
Today's episode is from a Wikipedia article titled Object-oriented Programming.
recommended by Diogo Ortecowski.
Object-oriented programming, OOP, is a programming paradigm based on the concept of objects,
which can contain data and code, data in the form of fields, often known as attributes or properties,
and code in the form of procedures, often known as methods.
A feature of objects is that an object's own procedures,
can access and often modify the data fields of itself.
Objects have a notion of this or self.
In OOP, computer programs are designed by making them out of objects that interact with one another.
OOP languages are diverse, but the most popular ones are class-based,
meaning that objects are instances of classes.
which also determine their types.
Many of the most widely used programming languages,
such as C++, Java, Python, etc.,
are multi-paradigm,
and they support object-oriented programming
to a greater or lesser degree,
typically in combination with imperative procedural programming.
Significant object-oriented languages include
Java C++ C Sharp
Python
R
PHP
Visual Basic dot net
JavaScript
Ruby
Pearl
Object Pascal
Objective C
DART Swift
Scala
Kotlin
Common Lisp
Matlab
Features. Object-oriented programming uses objects, but not all of the associated techniques and structures are supported directly in languages that claim to support OOP.
The features listed below are common among languages considered to be strongly class- and object-oriented, or multi-paradigm with OOP support, with notable exceptions mentioned, shared with non-nobes.
OOP languages. Variables that can store information formatted in a small number of built-in
data types, like integers and alpha-numeric characters. This may include data structures like strings,
lists, and hash tables that are either built in or result from combining variables using memory
pointers. Procedures, also known as functions, methods, routines, or subroutines, or subroutes,
that take input, generate output, and manipulate data.
Modern languages include structured programming constructs like loops and conditionals.
Modular programming support provides the ability to group procedures into files and modules for organizational purposes.
Modules are namespaced, so identifiers in one module will not conflict with a procedure or variable sharing the same.
same name in another file or module. Objects and classes. Languages that support object-oriented
programming OOP typically use inheritance for code reuse and extensibility in the form of either
classes or prototypes. Those that use classes support two main concepts. Classes, the definitions
for the data format and available procedures for a given type or
class of object may also contain data and procedures known as class methods themselves,
i.e. classes contain the data members and member functions.
Objects instances of classes. Objects sometimes correspond to things found in the real world.
For example, a graphics program may have objects such as circle, square, menu,
An online shopping system might have objects such as shopping cart, customer, and product.
Sometimes objects represent more abstract entities like an object that represents an open file,
or an object that provides the service of translating measurements from U.S. customary to metric.
Object-oriented programming is more than just classes and objects.
It's a whole programming paradigm based around objects, data structures, that contain data fields and methods.
It is essential to understand this, using classes to organize a bunch of unrelated methods together, is not object orientation.
Junade Ali, mastering PHP design patterns.
Each object is said to be an instance of a particular class, for example, an object with a
its name field set to marry might be an instance of class employee.
Procedures in object-oriented programming are known as methods. Variables are also known as
fields, members, attributes, or properties. This leads to the following terms. Class variables.
Belong to the class as a whole, there is only one copy of each one.
Instance variables or attributes.
Data that belongs to individual objects.
Every object has its own copy of each one.
Member variables refers to both the class and instance variables that are defined by a particular class.
Class methods belong to the class as a whole and have access only to class variables and inputs from the procedure call.
instance methods belong to individual objects and have access to instance variables for this specific object they are called on, inputs, and class variables.
Objects are accessed somewhat like variables with complex internal structure, and in many languages are effectively pointers,
serving as actual references to a single instance of said object in memory within a heap or stack.
They provide a layer of abstraction which can be used to separate internal from external code.
External code can use an object by calling a specific instance method with a certain set of input parameters,
read an instance variable, or write to an instance variable.
Objects are created by calling a special type of method in the class known as constructor.
A program may create many instances of the same class as it runs, which operate independently.
This is an easy way for the same procedures to be used on different sets of data.
Object-oriented programming that uses classes is sometimes called class-based programming,
while prototype-based programming does not typically use classes.
As a result, significantly different yet analogous terminology is used to define the concepts of object and instance.
In some languages, classes and objects can be composed using other concepts like traits and mixins.
Class-based versus prototype-based.
In class-based languages, the classes are defined.
find beforehand, and the objects are instantiated based on the classes.
If two objects, apple and orange, are instantiated from the class fruit,
they are inherently fruits, and it is guaranteed that you may handle them in the same way,
e.g., a programmer can expect the existence of the same attributes such as
color or sugar underscore content or is underscore right.
In the prototype-based languages, the objects are the primary entities.
No classes even exist.
The prototype of an object is just another object in which the object is linked.
Every object has one prototype link and only one.
New objects can be created based on already existing objects chosen as their prototype.
It may call two different objects, Apple,
and orange a fruit if the object fruit exists, and both apple and orange have fruit as their prototype.
The idea of the fruit class doesn't exist explicitly, but as the equivalence class of the objects,
sharing the same prototype. The attributes and methods of the prototype are delegated to all the
objects of the equivalence class defined by this prototype. The attributes and methods own
individually by the object may not be shared by other objects of the same equivalence class,
e.g. the attribute sugar underscore content may be unexpectedly not present in Apple.
Only single inheritance can be implemented through the prototype.
Dynamic dispatch message passing. It is a responsibility of the object,
not any external code, to select the procedural code,
to execute in response to a method call,
typically by looking up the method at runtime
in a table associated with the object.
This feature is known as dynamic dispatch
and distinguishes an object from an abstract data type or module,
which has a fixed static implementation of the operations for all instances.
If the call variability relies on more than the single type of the object
on which it is called, i.e. at least one other parameter object is involved in the method choice.
One speaks of multiple dispatch. A method call is also known as message passing.
It is conceptualized as a message, the name of the method, and its input parameters being passed
to the object for dispatch. Encapsulation
Encapsulation is an object-oriented programming concept that binds together the data and functions that manipulate the data.
And that keeps both safe from outside interference and misuse.
Data encapsulation led to the important OOP concept of data hiding.
If a class does not allow calling code to access internal object data,
and permits access through methods only, this is a strong form of abstraction or information hiding known as encapsulation.
Some languages, Java, for example, let classes enforce access restrictions explicitly.
For example, denoting internal data from the private keyword and designating methods intended for use by a code outside the class with the public keyword.
methods may also be designed public, private, or intermediate levels, such as protected,
which allows access from the same class and its subclasses, but not objects of a different class.
In other languages like Python, this is enforced only by convention.
For example, private methods may have names that start with an underscore.
Encapsulation prevents external code.
from being concerned with the internal workings of an object.
This facilitates code refactoring, for example allowing the author of the class to change
how objects of that class represent their data internally, without changing any external code.
As long as public method calls work the same way. It also encourages programmers to put all
the code that is concerned with a certain set of data in the same class, which organizes
for easy comprehension by other programmers.
Encapsulation is a technique that encourages decoupling.
Composition, inheritance, and delegation.
Objects can contain other objects in their instance variables.
This is known as object composition.
For example, an object in the employee class might contain either directly or through a pointer,
an object in the address class, in addition to its own instance variables like
first underscore name and position.
Object composition is used to represent has-a relationships.
Every employee has an address,
so every employee object has access to a place to store an address object,
either directly embedded within itself or at a separate location addressed via a pointer.
Languages that support classes almost always support inheritance.
This always classes to be arranged in a hierarchy that represents is a type of relationships.
For example, class employee might inherit from class person.
Also, the data and methods available to the parent class also appear in the child class with the same names.
For example, class person might define variables first underscore name and last,
underscore name with method make underscore full underscore name.
These will also be available in class employee, which might add the variables, position,
and salary.
This technique allows easy reuse of the same procedures and data definitions, in addition to
potentially mirroring real-world relationships in an intuitive way.
Rather than utilizing database tables and programs,
subroutines, the developer utilizes objects the user may be more familiar with,
objects from other application domain.
Subclasses can override the methods defined by superclasses.
Multiple inheritance is allowed in some languages, though this can make resolving overrides complicated.
Some languages have special support for mix-ins, though in any language with multiple inheritance,
A mix-in is simply a class that does not represent and is a type of relationship.
Mix-ins are typically used to add the same methods to multiple classes.
For example, class Unicode conversion mix-in might provide a method
Unicode underscore 2-Ashi when included in class file reader and class Webpage scraper,
which don't share a common parent.
Contract classes cannot be instantiated into objects. They exist only for the purpose of inheritance
into other concrete classes that can be instantiated. In Java, the final keyword can be used
to prevent a class from being subclassed. The doctrine of composition over inheritance advocates
implementing has-a-relationships using composition instead of inheritance. For example, instead of
inheriting from class person, class employee could give each employee object an internal person object,
which it then has the opportunity to hide from external code, even if class person has many
public attributes or methods. Some languages like Go do not support inheritance at all. The open-closed
principle advocates that classes and function should be open for extension, but closed for
modification. Delegation is another language feature that can be used as an alternative to
inheritance. Polymorphism. Subtyping, a form of polymorphism, is when calling code can be
agnostic as to which class in the supported hierarchy it is operating on, the parent class,
or one of its descendants. Meanwhile, the same operation name among objects in an inheritance hierarchy
may behave differently. For example, objects of type circle and square are derived from a common
class called shape. The draw function for each type of shape implements what is necessary to draw itself,
while calling code can remain indifferent to the particular type of shape being drawn. This is another
type of abstraction that simplifies code external to the class hierarchy and enables strong separation
of concerns. Open recursion. In languages that support open recursion, object methods can call other methods
on the same object, including themselves, typically using a special variable or keyword called
this or self. This variable is latebound. It allows a method defined in one class to invoke another
method that is defined later in some subclass thereof. History. Terminology invoking objects
and oriented in the modern sense of object-oriented programming made its first appearance at
MIT in the late 1950s and early 1960s.
In the environment of the artificial intelligence group, as early as 1960,
object could refer to identified items, I LISP atoms, with properties, attributes.
Alan K. later cited a detailed understanding of LISP internals as a strong influence on his thinking in 1966.
I thought of objects being like biological cells and or individual computers on a network,
only able to communicate with messages, so messaging came at the very beginning,
took a while to see how to do messaging in a programming language efficiently enough to be useful.
Alan Kay
Another early MIT example was Sketchpad, created by Ivan Sutherland in 1960 to 61.
In the glossary of the 1963 technical report based on his dissertation about Sketchpad,
Sellerland defined notions of object and instance with the class concept covered by master or definition,
albeit specialized to graphical interaction.
Also, an MIT-AL-G-O-L version, A-E-D-0, established a direct link between,
data structures, plexes in that dialect, and procedures prefiguring what were later termed
messages, methods, and member functions.
In 1962, Kristen Nygaard initiated a project for a simulation language of the Norwegian
Computing Center, based on his previous use of the Monte Carlo simulation and his work
to conceptualize real-world systems.
Ole Johan Dal formerly joined the project and the Simula programming language was designed
to run on the Universal Automatic Computer, Univac 1107.
Simula introduced important concepts that are today an essential part of object-oriented programming,
such as class and object, inheritance, and dynamic binding.
formula was also designed to take account of programming and data security.
For programming security purposes, a detection process was implemented so that through reference counts,
a last resort garbage collector deleted unused objects in the random access memory RAM.
But although the idea of data objects had already been established by 1965,
data encapsulation through levels of scope for variables such as,
private, minus, and public, plus, were not implemented in Simula because it would have required
the accessing procedures to be also hidden. In the early stages, Simula was supposed to be a
procedure package for the programming language, Algol, 60. Disatisfied with the restrictions
imposed by Algoal, the researchers decided to develop Simula into a fully-fledged programming
language, which used the Univac-Algill 60 compiler.
Simula was promoted by Dahl and Nygaard throughout 1965 and 1966,
leading to increasing use of the programming language in Sweden, Germany, and the Soviet Union.
In 1968, the language became widely available through the Burroughs B-5500 computers
and was later also implemented in the Ural-16 computer.
In 1966, Dahl and Nygaard wrote a simula compiler.
They became preoccupied with putting into practice Tony Hoare's record-class concept,
which had been implemented in the free-form English-like general-purpose simulation language, SimScript.
They settled for a generalized process concept with record-class properties
and a second layer of prefixes.
Through prefixing, a process could.
reference its predecessor and have additional properties.
Simula thus introduced the class and subclass hierarchy and the possibility of generating objects
from these classes.
A Simula 67 compiler was launched for the System 360 and System 370 IBM mainframe computers
in 1972.
In the same year, a Simula 67 compiler was launched free of charge for the French CIO.
T.I.1070 and CII IRIS 80 mainframe computers.
By 1974, the association of Simula users had members in 23 different countries.
Early 1975, a Simula 67 compiler was released free of charge for the DEC System 10 mainframe family.
By August the same year, the DEC System 10 Simula 67 compiler had been installed at 28 sites,
22 of them in North America.
The object-oriented simula programming language was used mainly by researchers involved with physical modeling,
such as models to study and improve the movement of ships and their content through cargo ports.
In the 1970s, the first version of the Small Talk programming language was developed at Xerox Park by Alan K., Dan Ingalls, and Adele Goldberg.
Smalltalk 72 included a programming environment and was dynamically typed, and at first was interpreted, not compiled.
Smalltalk became noted for its application of object orientation at the language level, and its graphical
development environment. Small talk went through various versions and interest in the language grew.
While small talk was influenced by the ideas introduced in Simula 67, it was designed to be a fully
dynamic system in which classes could be created and modify dynamically. In the 1970s, small talk
influenced the LISP community to incorporate object-based techniques that were introduced to developers
via the LISP machine.
Experimentation with various extensions to LISP,
such as loops and flavors,
introducing multiple inheritance and mixins,
eventually led to the common LISP object-oriented system,
eventually led to the Common LISP object system,
which integrates functional programming
and object-oriented programming,
and allows extension via a meta-object protocol.
In the 1980s, there were a few attempts to design processor architectures that included hardware support for objects in memory.
But these were not successful.
Examples include the Intel IAPX 432 and the Lin-smart recursive.
In 1981, Goldberg edited the August issue of Byte magazine, introducing small talk and object-oriented programming to a wider audience.
In 1986, the Association for Computing Machinery organized the first conference on object-oriented programming,
systems, languages, and applications, Uppsla, which was unexpectedly attended by 1,000 people.
In the mid-1980s, Object C was developed by Brady Cox, who had used Smalltalk at ITT, Inc.
and Bjorn Strauss-Strapp, who had used Simula for his PhD thesis, eventually went to create the object-oriented C++.
In 1985, Bertrand Meyer also produced the first design of the Eiffel language.
Focused on software quality, Eiffel is a purely object-oriented programming language
and a notation supporting the entire software lifecycle.
Meyer described the Eiffel software development method based on a small number of key ideas from software engineering and computer science, an object-oriented software construction.
Essential to the quality focus of Eiffel is Meyer's reliability mechanism, designed by a contract, which is an integral part of both the method and language.
In the early and mid-1990s, object-oriented programming developed as the dominant programming paradigm
when programming languages supported the techniques became widely available.
It included Visual Fox Pro 3.0, C++, and Delphi.
Its dominance was further enhanced by the rising popularity of graphical user interfaces,
which rely heavily upon object-oriented programming techniques.
An example of a closely related dynamic GUI library and OOP language can be found in the COCO frameworks on MacOS10, written in Object C, an object-oriented dynamic messaging extension to C based on small talk.
OOP toolkits also enhance the popularity of event-driven programming, although this concept is not limited to OOP.
At E.H. Zurich, Niklaus Wirth and his colleagues had also been investigating such topics as data abstraction and modular programming, although this had been in common use in the 1960s or earlier.
Modula 2, 1978, included both, and their succeeding design, Oberon, included a distinctive approach to object orientation, classes, and such.
Object-oriented features have been added to many previously existing languages, including Ada, Basic, Fortran, Pascal, and Cobol.
Adding these features to languages that were not initially designed for them often led to problems with compatibility and maintainability of code.
More recently, a number of languages have emerged that are primarily object-oriented, but that are also compatible with.
procedural methodology. Two such languages are Python and Ruby. Probably the most
commercially important recent object-oriented languages are Java, developed by Sun Microsystems,
as well as C-sharp and VisualBbasic.net, vb.net. Both design for Microsoft's dot-net platform.
Each of these two frameworks show, in its own way, the benefit of using OOP by creating an abstraction from implementation.
The VB.net and C Sharp support cross-language inheritance, allowing classes defined in one language to subclass classes defined in the other language.
