Your SlideShare is downloading. ×
Aman kingrubyoo pnew
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Aman kingrubyoo pnew

811

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
811
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ruby OOP: Objects over Classes Aman King king@thoughtworks.com RubyConf India 2010
  • 2. What is OOP?
  • 3. What is a class?
  • 4. What is an object?
  • 5. But before the serious stuff …
  • 6. Detouring through a comic book universe … Image copyrighted by respective owners Source: http://www.comics.org/
  • 7. Coming back …
  • 8. What is an object?
  • 9. Something that takes birth …
  • 10. exhibits some behavior …
  • 11. interacts with other objects …
  • 12. and finally dies off or is simply forgotten …
  • 13. all in an effort to solve a problem.
  • 14. What is a class?
  • 15. A container for related behavior …
  • 16. that a new object can start off with.
  • 17. A class itself is an object …
  • 18. used to create other objects.
  • 19. When creating a new object, a class calls the object’s private initialize method.
  • 20. Typically a class is named …
  • 21. referenced via a global constant variable.
  • 22. A class object can have singleton methods added to it.
  • 23. These singleton methods can be invoked wherever the class object is accessible …
  • 24. aka “class-level methods”.
  • 25. Why use classes?
  • 26. Some possible reasons
  • 27. An object remembers the class used to create it …
  • 28. explicit type checking using kind_of? …
  • 29. implicit type checking using case syntax …
  • 30. implicit type checking using rescue syntax.
  • 31. A class can build on other classes: inheritance.
  • 32. A class can share state across multiple objects: @@class_variables.
  • 33. Some good reasons
  • 34. A named container of behavior can have more behavior added to it.
  • 35. Any added behavior becomes part of all objects created by that class.
  • 36. A class can represent a common pattern of initialization.
  • 37. Classes improve readability and maintainability.
  • 38. What a class is not?
  • 39. The fundamental building block of an application.
  • 40. A strong data type.
  • 41. An enforcement of contract or limitations on how objects can behave.
  • 42. Ruby’s object focus
  • 43. Classes are objects.
  • 44. No static method-lookup tables: chain of ancestors.
  • 45. Singleton methods.
  • 46. Private access modifier is object-level.
  • 47. Duck typing.
  • 48. Finding hints in the real world …
  • 49. Objects over classes: Consequences
  • 50. Classes and hierarchies no longer limit you.
  • 51. Think through the usage of class-level methods and variables: globals?
  • 52. Understanding meta-programming is easier.
  • 53. Effective and confident use of meta-programming.
  • 54. Final words
  • 55. Objects are first-class citizens.
  • 56. Classes are useful but secondary.
  • 57. Thank you king@thoughtworks.com http://www.wikyblog.com/AmanKing

×