SlideShare una empresa de Scribd logo
1 de 7
Class 11 – Intro to Classes
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introducing Classes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Ball Class PROPERTIES Size Base_Color Elasticity Shape Decal? METHODS Roll Bounce Curve? Fly Spin
Classes in Ruby ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Class Act! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Wrap-up ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

La actualidad más candente

Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objectsrahulsahay19
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingManish Pandit
 
Reflection and Introspection
Reflection and IntrospectionReflection and Introspection
Reflection and Introspectionadil raja
 
Ruby OOP: Objects over Classes
Ruby OOP: Objects over ClassesRuby OOP: Objects over Classes
Ruby OOP: Objects over ClassesAman King
 
OOP->A Bird's-eye view
OOP->A Bird's-eye viewOOP->A Bird's-eye view
OOP->A Bird's-eye viewSaugata Bose
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaiUnmesh Baile
 
Object Oriented Programming : Part 2
Object Oriented Programming : Part 2Object Oriented Programming : Part 2
Object Oriented Programming : Part 2Madhavan Malolan
 
Object oriented programming (oop) cs304 power point slides lecture 01
Object oriented programming (oop)   cs304 power point slides lecture 01Object oriented programming (oop)   cs304 power point slides lecture 01
Object oriented programming (oop) cs304 power point slides lecture 01Adil Kakakhel
 

La actualidad más candente (12)

Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
 
RIBBUN SOFTWARE
RIBBUN SOFTWARERIBBUN SOFTWARE
RIBBUN SOFTWARE
 
Introduction what is java
Introduction what is javaIntroduction what is java
Introduction what is java
 
Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objects
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Reflection and Introspection
Reflection and IntrospectionReflection and Introspection
Reflection and Introspection
 
Ruby OOP: Objects over Classes
Ruby OOP: Objects over ClassesRuby OOP: Objects over Classes
Ruby OOP: Objects over Classes
 
OOP->A Bird's-eye view
OOP->A Bird's-eye viewOOP->A Bird's-eye view
OOP->A Bird's-eye view
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
Java
JavaJava
Java
 
Object Oriented Programming : Part 2
Object Oriented Programming : Part 2Object Oriented Programming : Part 2
Object Oriented Programming : Part 2
 
Object oriented programming (oop) cs304 power point slides lecture 01
Object oriented programming (oop)   cs304 power point slides lecture 01Object oriented programming (oop)   cs304 power point slides lecture 01
Object oriented programming (oop) cs304 power point slides lecture 01
 

Similar a Class 11 lecture notes

Is2215 lecture2 student(2)
Is2215 lecture2 student(2)Is2215 lecture2 student(2)
Is2215 lecture2 student(2)dannygriff1
 
Moo the universe and everything
Moo the universe and everythingMoo the universe and everything
Moo the universe and everythingHenry Van Styn
 
Objected-Oriented Programming with Java
Objected-Oriented Programming with JavaObjected-Oriented Programming with Java
Objected-Oriented Programming with JavaOum Saokosal
 
Core java and advance java syallabus - Cacit.co.in
Core java and advance java syallabus - Cacit.co.inCore java and advance java syallabus - Cacit.co.in
Core java and advance java syallabus - Cacit.co.incacitnoida
 
Take the Plunge with OOP from #pnwphp
Take the Plunge with OOP from #pnwphpTake the Plunge with OOP from #pnwphp
Take the Plunge with OOP from #pnwphpAlena Holligan
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scalafanf42
 
Php meetup 20130912 reflection
Php meetup 20130912   reflectionPhp meetup 20130912   reflection
Php meetup 20130912 reflectionJoelRSimpson
 
Java se 8 fundamentals
Java se 8 fundamentalsJava se 8 fundamentals
Java se 8 fundamentalsmegharajk
 
PHP-05-Objects.ppt
PHP-05-Objects.pptPHP-05-Objects.ppt
PHP-05-Objects.pptrani marri
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Mario Camou Riveroll
 
Core java lessons
Core java lessonsCore java lessons
Core java lessonsvivek shah
 
Me, my self and IPython
Me, my self and IPythonMe, my self and IPython
Me, my self and IPythonJoel Klinger
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxShaownRoy1
 

Similar a Class 11 lecture notes (20)

Is2215 lecture2 student(2)
Is2215 lecture2 student(2)Is2215 lecture2 student(2)
Is2215 lecture2 student(2)
 
OOPs in Java
OOPs in JavaOOPs in Java
OOPs in Java
 
Moo the universe and everything
Moo the universe and everythingMoo the universe and everything
Moo the universe and everything
 
Objected-Oriented Programming with Java
Objected-Oriented Programming with JavaObjected-Oriented Programming with Java
Objected-Oriented Programming with Java
 
Core java and advance java syallabus - Cacit.co.in
Core java and advance java syallabus - Cacit.co.inCore java and advance java syallabus - Cacit.co.in
Core java and advance java syallabus - Cacit.co.in
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Take the Plunge with OOP from #pnwphp
Take the Plunge with OOP from #pnwphpTake the Plunge with OOP from #pnwphp
Take the Plunge with OOP from #pnwphp
 
OOP in PHP
OOP in PHPOOP in PHP
OOP in PHP
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Php meetup 20130912 reflection
Php meetup 20130912   reflectionPhp meetup 20130912   reflection
Php meetup 20130912 reflection
 
Core java online training
Core java online trainingCore java online training
Core java online training
 
Java se 8 fundamentals
Java se 8 fundamentalsJava se 8 fundamentals
Java se 8 fundamentals
 
OOP Day 2
OOP Day 2OOP Day 2
OOP Day 2
 
PHP-05-Objects.ppt
PHP-05-Objects.pptPHP-05-Objects.ppt
PHP-05-Objects.ppt
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
 
Me, my self and IPython
Me, my self and IPythonMe, my self and IPython
Me, my self and IPython
 
Ravi software faculty
Ravi software facultyRavi software faculty
Ravi software faculty
 
130704798265658191
130704798265658191130704798265658191
130704798265658191
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
 

Más de Stephen Parsons

Atlantic Woodworkers Website Strategy
Atlantic Woodworkers Website StrategyAtlantic Woodworkers Website Strategy
Atlantic Woodworkers Website StrategyStephen Parsons
 
Chairs Report to LSCRS 2012 AGM
Chairs Report to LSCRS 2012 AGMChairs Report to LSCRS 2012 AGM
Chairs Report to LSCRS 2012 AGMStephen Parsons
 
Program Renewal for NSCC Schools 2010-11
Program Renewal for NSCC Schools 2010-11Program Renewal for NSCC Schools 2010-11
Program Renewal for NSCC Schools 2010-11Stephen Parsons
 
Class 6 truth tables and boolean math
Class 6   truth tables and boolean mathClass 6   truth tables and boolean math
Class 6 truth tables and boolean mathStephen Parsons
 
Class 5 - Set Theory and Venn Diagrams
Class 5 - Set Theory and Venn DiagramsClass 5 - Set Theory and Venn Diagrams
Class 5 - Set Theory and Venn DiagramsStephen Parsons
 
Class 4 IPO and Intro to Ruby
Class 4 IPO and Intro to RubyClass 4 IPO and Intro to Ruby
Class 4 IPO and Intro to RubyStephen Parsons
 
Class 3 Binary & Hexadecimal
Class 3 Binary & HexadecimalClass 3 Binary & Hexadecimal
Class 3 Binary & HexadecimalStephen Parsons
 
Class 1 introduction to logic & problem solving
Class 1   introduction to logic & problem solvingClass 1   introduction to logic & problem solving
Class 1 introduction to logic & problem solvingStephen Parsons
 
Portfolio Of A Community
Portfolio Of A CommunityPortfolio Of A Community
Portfolio Of A CommunityStephen Parsons
 
Cause & effect analysis part 2
Cause & effect analysis part 2Cause & effect analysis part 2
Cause & effect analysis part 2Stephen Parsons
 
Cause & effect analysis part 1
Cause & effect analysis part 1Cause & effect analysis part 1
Cause & effect analysis part 1Stephen Parsons
 

Más de Stephen Parsons (19)

Atlantic Woodworkers Website Strategy
Atlantic Woodworkers Website StrategyAtlantic Woodworkers Website Strategy
Atlantic Woodworkers Website Strategy
 
Chairs Report to LSCRS 2012 AGM
Chairs Report to LSCRS 2012 AGMChairs Report to LSCRS 2012 AGM
Chairs Report to LSCRS 2012 AGM
 
Class 10 Arrays
Class 10 ArraysClass 10 Arrays
Class 10 Arrays
 
Program Renewal for NSCC Schools 2010-11
Program Renewal for NSCC Schools 2010-11Program Renewal for NSCC Schools 2010-11
Program Renewal for NSCC Schools 2010-11
 
Class 7 lecture notes
Class 7 lecture notesClass 7 lecture notes
Class 7 lecture notes
 
Class 6a ruby math
Class 6a   ruby mathClass 6a   ruby math
Class 6a ruby math
 
Class 6 truth tables and boolean math
Class 6   truth tables and boolean mathClass 6   truth tables and boolean math
Class 6 truth tables and boolean math
 
Class 5 - Set Theory and Venn Diagrams
Class 5 - Set Theory and Venn DiagramsClass 5 - Set Theory and Venn Diagrams
Class 5 - Set Theory and Venn Diagrams
 
Class 4 IPO and Intro to Ruby
Class 4 IPO and Intro to RubyClass 4 IPO and Intro to Ruby
Class 4 IPO and Intro to Ruby
 
Class 3 Binary & Hexadecimal
Class 3 Binary & HexadecimalClass 3 Binary & Hexadecimal
Class 3 Binary & Hexadecimal
 
Class 2 Math I
Class 2 Math IClass 2 Math I
Class 2 Math I
 
Class 1 introduction to logic & problem solving
Class 1   introduction to logic & problem solvingClass 1   introduction to logic & problem solving
Class 1 introduction to logic & problem solving
 
Portfolio Of A Community
Portfolio Of A CommunityPortfolio Of A Community
Portfolio Of A Community
 
Cause & effect analysis part 2
Cause & effect analysis part 2Cause & effect analysis part 2
Cause & effect analysis part 2
 
Cause & effect analysis part 1
Cause & effect analysis part 1Cause & effect analysis part 1
Cause & effect analysis part 1
 
Class 10 Lecture Notes
Class 10  Lecture  NotesClass 10  Lecture  Notes
Class 10 Lecture Notes
 
Class 9 Lecture Notes
Class 9 Lecture NotesClass 9 Lecture Notes
Class 9 Lecture Notes
 
Class 8 Lecture Notes
Class 8 Lecture NotesClass 8 Lecture Notes
Class 8 Lecture Notes
 
Deck Project Phase II
Deck Project Phase IIDeck Project Phase II
Deck Project Phase II
 

Último

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Último (20)

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

Class 11 lecture notes

  • 1. Class 11 – Intro to Classes
  • 2.
  • 3.
  • 4. The Ball Class PROPERTIES Size Base_Color Elasticity Shape Decal? METHODS Roll Bounce Curve? Fly Spin
  • 5.
  • 6.
  • 7.

Notas del editor

  1. This evening’s class will start with a brief introduction to classes, a concept central to the notion of object-oriented programming. By the time we have finished this class you will have examined concepts related to object-oriented programming and be able to articulate the meaning and utility of classes in programming.
  2. Our agenda is a short one:
  3. We will begin our discussion on classes with an exploration of object-oriented development, an approach to programming that starts by dealing with entities in the code as “objects” that can be manipulated and examined like objects in the real-world. Our code so far has been fairly simple, but at the same time quite verbose – that is, we have had to write a lot of code – often repeatedly – in order to get our solutions to work. We have learned that some techniques like branching, looping and the development of methods can allow us to write more elegant (or tighter) code. OOD allows us to go a step further by modelling real-world objects so that we can use them more effectively. A Class in programming terms is the model of an object: something that represents a thing and can describe properties or attributes of the object as well as the tings it can do – its methods or behaviours. For example, if we wanted to develop a game in which we needed to model a car, we would need to describe the object with the properties as well as the actions that the car can undertake. So how do we describe a car? What are its attributes? [type, model, maker, ext_color, int_color, style, engine_size, hp, warranty, int_fabric]. And what can a car do [drive, backup, accelerate, park] Class creation and manipulation requires certain rules and procedures and those are largely determined by the language. Ruby is a very simple yet robust language that minimizes the rules and procedures needed to create and manipulate its Classes. In addition, Ruby has many built-in classes – some of which we will examine shortly. These built-in classes are part of the default set of capabilities that the language is able to work with and in fact that we have already been working with since the beginning of our work in Ruby. Why use classes? To begin, being able to abstract – or model – an object as a Class allows us to use it as a blueprint or cookie-cutter so we can create numerous instances of the object and manipulate its properties and behaviours. This allows us to re-use the code many times rather than having to write it every time we want to use an object in our code. Second, as a developer if I write a piece of code and want to re-sell that application, I can encapsulate the class into an encrypted object like a java .jar file or a Windows .dll and hide the details of the code that makes it work – protecting my investment and my intellectual property. If I want to use someone else’s class I may be able to simply attach the class to my application and call its properties and methods by following a published API (application programming interface). The API tells us what I can pass to the object and what I will get back from it…I don’t really need to know what’s inside of it. Finally, I can create classes based on other classes – so that if I need to have an object that is like some other object, but has some unique capabilities or features, I can create a Class based on another (its parent) and then just add the additional properties or functions to it. I can also use functions that are in one class across numerous classes through something called polymorphism – as long as I follow some basic rules. Overall, then, Classes allow me to create a model of a business object and deploy or re-use instances of that object that I can manipulate in code. Let’s try an example: let’s think about the idea of a ball. I want you to write down two columns for our class “Ball”. What are all the things that describe a ball (the features that might make one ball different from or similar to another ball) and what are the things a ball can do (something that all balls may be made to do)…
  4. Well here’s the start of a model or abstraction of the Ball Class. The basic attributes might include…(see image) And the basic behaviours could include…(see image) What else did you identify? Are they features of ALL Balls? Now if we instantiate the class Ball by creating a new Ball, then that object should be able to be described by any of those properties and should be able to do any of those methods. If we wanted to create a new class of ball – say Soccer_Ball, then what new properties and methods might we need to add?
  5. Let’s look at some of the built-in classes in Ruby – you can point your browser to the URL shown here and explore some of the Classes in Ruby. We’ve used some of these Classes already, most recently Array – let’s look at that…note the methods listed for the Class “Array” Now look at some others – here are some ideas that might be useful: String, Matrix, Foo (don’t ask), and how about Object! Object is the Mother of ALL Classes in Ruby, so that means that everything that Object can do, every other Class can do too. Looking at parent  child relationships, you can see the inheritance in something like DateTime Class – which is a child of Date. We can develop our own classes based on those classes simply by creating a sub-class…or we can create our own class by using the class keyword, capitalizing the class name and defining the properties and methods of the class – remember that to Ruby both properties and behaviours are all methods, but properties are just laid out to allow us to set the value of a property and to get the value of the property (we’ll see this in a moment when I demonstrate a class in Ruby). Finally, to use the Class – you use the “new” keyword to create a copy of the object and then you are off to the races! Let’s see an example.
  6. In this example, we’ll code the Class Ball and create a ball Color property and a bounce method. Follow along if you can. Initialize is a useful function that is run automatically when the object of the class is created. Although initialize can be left out, it is a good idea to add it in, even if it does nothing more than set the object up. You can use initialize to set up the default properties of the object. The left side is the creation of the Class, the right shows some code we can use to work with the class…we start by creating an instance of the Class using new and then we can do anything that is defined in the class – set the color, get the color, and bounce the ball. Note that when we ask the ball to bounce we tell it the number of times we want it to bounce and it does so. In the next section, I call a random function to set the color of the ball and then I print out the color of that particular ball. If I decided to create a second and third ball, they might be different colors – but each one would keep that property unless we change it.
  7. So for this course, we will not really need to get you developing Classes to any great extent. Our purpose was really to get you familiar with the notion of object-oriented programming and development and to understand a little about how classes work and how you might create and use a class. I don’t suggest that you should create and use Classes in your project or assignment, but you are free to do so if you think you want to. OOP is a subject you would undertake in some detail at the next level or programming such as in our PROG 1040 Programming I or many of our courses in Programming and Web Concentrations. In our next session we are going to look at a technique to evaluate cause and effect in business or workplace situations using a tool called a Fishbone Diagram