Aman kingrubyoo pnew

866
-1

Published on

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

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

No notes for slide

Aman kingrubyoo pnew

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

×