Where Do I Put Code to Create Classes?

It would be much easier to just write a text file in a text editor then use the text project type and add the item to the manifest
Or write some code to write that text file and append it to the manifest
Its probably much less error prone too (yeah IDE script isnt perfect and it gets beaten into being used for a LOT of things it was never designed for - says the guy who WROTE the IDE for a decade but … whatever)

Then you can almost literally just write, in a text editor

Class foo
   sub bar
   end sub
end class

and have it work

But have at it Jim :stuck_out_tongue:

When I first started using Xojo (well actually RealBasic) I too had to adjust to the way things are done with the tool, most of the people here too I would asume. I adapted and now I find it very convenient and the times I have to work with other languages that require me to have a bunch of files and require me having to track what goes in which file ends up being not much fun. Why not embrace the Xojo way and be happy with it?

[quote=492435:@Jim Underwood]
If you don’t understand the benefit of looking at class, property, and method definitions in code, well you can keep using the “easy” way of point and click. I find lots of value in understanding the classes by viewing in code.[/quote]

if you only wanted to look at code, you could do a file print on the project and save as PDF.

Early on in my RealBasic days, I wrote a ORM database tool (similar to BKeeney’s ARGen) where you pointed to a database table and it spit out an XML file for a class that represented that table. Drag it into the IDE and voila, you have a class. Then export it as external and you can use it in all your projects. Saved a LOT of clicking and typing. And mistakes.

[h]The Goal[/h]
The goal is to be able to define a number of complex classes, complete with properties and methods, in code, and then do a one-time execute of the IDE Script to create and store those classes in the IDE. The classes would then be maintained in the IDE, unless there was a need for a major update, which I don’t expect. I’ll cross that bridge when/if I come to it

As I am writing the classes in text, I find it easier to quickly view and understand them, and the relationships with subclasses, methods and properties.

[h]Modivation[/h]
Finally, to be candid, I was shocked that there was no native way to create classes in code with Xojo. So many people said it couldn’t be done, and I took it as a challenge (which is fun for me) to see if I could do it. So now, I have a proof-of-concept. I expect that I will use a mix of IDE point/click and code to create my classes. Since I am a touch typist, and I have some great text automation tools, I can very quickly type out class definitions – much much faster than I can move the mouse around in the IDE.

[h]Using Only Keyboard in the IDE[/h]
However, I just discovered the customizable keyboard shortcuts in the IDE. So maybe if I can setup a shortcut for all of the steps to create classes, properties, and methods, I’ll find that more usable.

So, after playing around in the IDE, it looks like I may be able to create classes, methods, and properties, and type in the method code – all without using a mouse. If that works out, then I may tend to use the IDE more.

I’m going to start a new topic for this: How Can I Use Only the Keyboard to Create Classes, Properties, and Methods in the IDE?
If someone has perfected a technique to do this, I’d love to hear about it.

EDIT: New topic posted: How Can I Use Only the Keyboard to Create Classes, Properties, and Methods in the IDE?

Tim, that sounds great! Would you be willing to share your tool?

or there is this one from long time forum users
https://strawberrysw.com/argen/

Unfortunately, I am not at liberty to share that tool. It also would be very specific to my application/approach. But it still isn’t very clear what your use case is. Are you trying to automate the creation of classes based on some external thing like a database? Or are you just wanting to see all your code at once? The Xojo philosophy is to encapsulate everything. It feels a little bit claustrophobic at first, but it becomes very freeing in the long run. It does force one to change their approach to coding though. It may not be for everyone, especially if you have deeply ingrained habits.

For automatic code generation, it’s very useful. For the creation of classes that you intend to share between projects, not so much.

One last question: what led you to consider Xojo as a tool, as opposed to other tools that you seem to already be comfortable with?

Mainly its use as a RAD tool. My initial use case was simple apps to support Mac automation.
But as I started learning Xojo, and seeing from the many great videos that @Paul Lefebvre and others have published, I have started to recognize more potential.

I hate repetition. The first thing I look for in any language I seriously want to learn is how do I maximize reuse of my code. So I expect to reuse a lot of the same classes across all of my projects. I am not in a team right now, but that could change.
I also strongly prefer use of the keyboard.

I am not opposed to learning new ways/techniques of doing things – in fact I enjoy and embrace it.
But the new way has to prove beneficial. I don’t take to “this is the only way you can do it”, or “it’s always done that way” without any real technical explanation.

In my former life I was an aerospace systems engineer, by DNA and training. So I pretty much question everything I don’t understand. :slight_smile: I also have a minor in computer science, and have always made effective use of HW and SW in my career. I really like databases, and in the distant past have written a number of apps that use DB.

I rarely have the need to create more than a couple of classes at once. Same for properties. Could the editor be better? Yes.

What works very well for code sharing is to use XML with external classes. There is a way to share code in text format. But most of my code can be shared so I found text format not very practical.

me too. You’re going to love the code refactoring options that allow you to convert a block of code to a method :slight_smile: