ballouta wrotebut all is given to me is text. i can get the same result if i just made them a text using puts or print, while in vb6 i can draw a dog and put the cat and make them bark or miaow by clicking on them or something. so i didn't really know what the purpose of using all this code to make object that gives me only writings. I mean where is the object? can someone explain or something?
and thanks.
Ballouta, very interesting question. What you are asking is not limited to Ruby. You want to know more about
Object Oriented Programming. We call it OOP.
Now I'm not going to give you a tutorial about OOP, you should continue with the one you started. However here are some tips:
- OOP is not restricted to one language. It is a
programming paradigm that is implemented in many other languages like C++, Java, C#, Python, Smalltalk, etc.
- There is (virtually) nothing you can do in OOP that you cannot do in other paradigms. What you have done in VB6 for instance, is called the
procedural or sometimes called
imperative paradigm. Each paradigm has its strengths and weaknesses.
- The main strength of OOP, is that the code is much more organized than procedural code. You won't notice this for a small program like "Cats & Dogs", but when the program becomes larger it becomes very necessary to put order in your code. OOP is perfect for this.
- The main weakness of OOP (compared to procedural) is a slight loss in performance. Note that it doesn't mean that OOP is slow, or that Ruby is not powerful. This is wrong. What it means is that OOP comes at a slight cost of execution time and memory. However, modern computers are so powerful you won't even feel a difference.
There you go. OOP might seem useless at first. It took me some time to understand its real power. If you ask the developers in this forum, they will all agree that OOP gives you means of managing large code like never before.