Xojo More Object-Oriented than Objective-C

Another random question. I read in the Introduction from the Xojo User Guide (Book 1 Fundamentals) that “…Xojo is more object-oriented than languages like Objective-C…”

I am interested to know why it is considered to be more object-oriented than Objective-C. Can someone elaborate? Thanks.

I’d be interested as well, because the claim you quoted seems silly to me.

Claims saying one is better than the other are often largely subjective, wrong and should simply be avoided, in my experience. If said, one had better have very good reasons and ready to defend.

Mea culpa!

I agree, it doesn’t seem necessary or accurate. That sentence has been there for years (it’s in my copy of the User Guide from 2008!). I should have edited it out when I moved content over, but I admit I didn’t spend much time on that section :slight_smile:

It will be removed in an update.

Either that, or make Xojo more object oriented than ObjC. Whichever is easier…

Well, I can imagine that the intent has been to say RB/Xojo is more like class-based object-oriented language than Objective-C which is a message-passing object-oriented language. Both are object-oriented but have different take on what being object-oriented means. There are many books about object-orientation out there but they mainly describe the class-based object-orientation and books that compare different takes on object-orientation may be harder to come by. I myself used The Interpretation of Object-Oriented Programming Languages by Iain D. Craig when I wrote my bachelor thesis about object-orientation and its application.

I’d like to apologize in advance and if you judge that my question is too silly please ignore.

I’m an former programmer from Clipper and some use of Access and Visual Basic. I never had used an Object Oriented language like Xojo. A friend of mine tried to explain me the concepts generically.

I read a lot about OO but when I try to apply in Xojo I confess that I became very confused. When should I create an object? Why should I create an object? And more important, HOW I could create and USE that object?

Nowadays I’m using Xojo to make a simple app for my wife and for myself and I got good results but probably I’m programming in the wrong way because I never created an object because I never understood the advantages.

As I told you in the beginning maybe there isn’t an easy answer but I decided to try ask here because It’s so much easier for me to learn from example and who knows if some of you could introduce a new approach to this issue.

Thanks a lot!

[quote=244811:@ALEXANDRE SANGALO]
I read a lot about OO but when I try to apply in Xojo I confess that I became very confused. When should I create an object? Why should I create an object? And more important, HOW I could create and USE that object?[/quote]

You might want to start with a video like this. While not related to Xojo, it will give you some ideas to think about:


And once you begin to understand the concepts behind OO programming, you will wonder how you ever managed to live without it…

OOP is not only about objects, it is about building programs to be modular enough so large amounts of code can be reused, which speeds up development.

The first step is to use methods instead of linear programming. If you find yourself writing the same kind of code twice, it probably can be turned into a method and added to a module that will be very conveniently dropped into another project.

When you use controls, you are using objects. Let us say you have perfected a program around TextArea, with nifty code in the event handlers. It works great. You can very well copy that and paste it into a starting project.

The next step is, instead of simply copying the instance from window to window, you create a subclass. Drag a Textarea out of a window in the project. That will create a customTextArea. Rename it to whatever you like, for instance myTextArea. Copy the event handlers containing the nifty code from your previous project and paste them one by one to myTextArea. Now when you drag myTextArea to a window, it comes with all bells and whistles built in. You can also export that class as a separate piece of code.

Little by little, you will find yourself spending less and less time redoing what you have already created. Welcome to OOP.

If you come from Clipper and other systems, you have experience in normalizing a database – instead of having ten fields for several addresses on a person’s record just in case, you create a table “address” and make it so that each person can have every number of addresses.

In a way, you can consider OOP a bit like that. Instead of having one big main routine that handles everything and branches from time to time, you break down everything to its most basic parts and make it independent from each other. In the end, there’s no big main method anymore but independent instances of classes that communicate with each other, but everyone takes care of its own business. This makes code very easy to reuse.

And this, btw, could be a point where “Xojo is even more OOP than ObjC” – in the latter, a class object carries its code in one file. In case you have a very active class, you need to scan through rather long files to find the exact method you are looking for. In Xojo, methods are displayed as individual objects attached to their class.