Download CS 150: Computing from Ada to the Web

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Natural philosophy wikipedia , lookup

Object-oriented ontology wikipedia , lookup

List of unsolved problems in philosophy wikipedia , lookup

Representation (arts) wikipedia , lookup

Direct and indirect realism wikipedia , lookup

Transcript
CS 150: Computing from Ada to
the Web
The Philosophy of Programming
Liberal Arts Recap
• Language/Literature
– Grammars and defining languages
– Recursion in literature
• Visual Arts
– Recursion in Escher’s drawings
– Fractals
• Music
– Bach’s Canons
– Foo Fighters’ in recursion
Philosophy
• Definition: “Philosophy is the discipline
concerned with questions of how one should
live (ethics); what sorts of things exist and
what are their essential natures
(metaphysics); what counts as genuine
knowledge (epistemology); and what are the
correct principles of reasoning (logic).”
How does Philosophy relate to CS?
• A more general definition: “How we view the
world.”
• How do we represent the world around us?
• How do we turn what we see into the world
into something digital? Something a
computer can understand and operate on?
Topics we’ll cover in Philosophy
• Modeling the world
– Object-oriented programming
– Abstract Data Types
– Data modeling
• Inheritance
– How objects relate to each other
• Requirements and Design
– Understanding the needs of others
• Ethics in Computer Science
What have we been programming
• Functional Programming Paradigm
– “treats computation as the evaluation of
mathematical functions and avoids state and
mutable data. It emphasizes the application of
functions, in contrast with the imperative
programming style that emphasizes changes in
state.”
How do we view the world?
• Some take the world and can turn it into
mathematical functions…
– Mathematicians
– Physicists
• How do you view the world?
How I (Mark Sherriff) View the World
• Millions of interconnected and interrelated
objects
– Example: this classroom
• The room sits in a particular spot in a particular building
at a particular place on grounds.
• Inside the room is a set number of seats is a prescribed
formation
• In some of the seats are students
Object vs. Instance
• What is an object?
– Is it a thing? Is it a place? Is it a person?
• An object has attributes
– Where is the object?
– What is the object like?
• An object has functions
– What can the object do?
– What is it used for?
Object vs. Instance
• An instance is a particular object
– I (Mark) am an instance of a professor
– My Civic is an instance of the general object car
• What instances are there in this room?
• What differentiates one instance from
another?
Another way to say it
• Entity vs. Entity Set
– An entity set is the general category that an object
comes from (i.e. desks)
– A particular entity is a specific object from the set
(i.e. the desk at the very front on the right)
The Philosophy of OO
• Why does the way we view the world matter?
• How does a computer “view the world?”
– What is machine language like?
– Can we read/understand machine language?
• The programs we have written so far are nice,
but are they things you’d use in your everyday
life?
• What are programs you use every day?
List of programs
•
•
•
•
•
•
•
Internet Browsing: Firefox, Safari, Opera
Email: Thunderbird, GMail, Webmail
Calendar: iCal, GCal
Music: iTunes, Rhapsody, Napster, … others
Games: Solitare, Wii, XB360, DS
IM: AIM, Adium
Office: MS Office, iWork, OpenOffice
What are the purposes of these
programs?
• Solve real-world problems
• Provide real-world solutions
• Improve quality of life
• So, how do you represent all that in 1’s and
0’s?
The world you are trying to model
• How do you tell a computer what any of this stuff
is?
• Each programming paradigm has a different
“language” it speaks to model the world
• Functional programming models the world in the
terms of mathematics.
• OO programming models the world by saying
that everything is an object unto itself, with
attributes and functions that it can carry out,
affecting other objects.
Finding Objects
• Define the object Book.
Finding Objects
• Define the object Book.
• A book has:
– A title
– An author
– A publisher
– Copyright
– Pages of text
– Pages with pictures
Finding Objects
• Well… what’s a page?
– A page is a single sheet of paper that has text on
it.
• Well… what’s paper?
• How far down do we need to go?
• Remember: What is the world you are trying
to model?
Finding Objects
• Consider a library
• Now, what do you need to know about a
book?
How do we represent objects in code
• Classes
– Classes are made up of primitive types and
functions.
– Classes are entity sets / objects because they
define an entire category of objects
– Classes can be instantiated, creating instances
– An instance is a particular entity from the class
• i.e. the front right desk is an instance of the Desk class
The building blocks of a class
• Attributes
– Pieces of data that define the object
• Functions / Methods
– Functionality that the object has
– Functionality that can be performed on the object
Class in PHP
<?php
class Book {
var $title;
var $author;
var $publisher;
var $pages;
var $callNumber;
}
?>