godot-cpp-template icon indicating copy to clipboard operation
godot-cpp-template copied to clipboard

Add an example class to the project.

Open Ivorforce opened this issue 9 months ago • 7 comments

When you first clone godot-cpp-template, you may still have no idea what to do next, because the gdextension doesn't actually do anything right now. This may be additionally confusing because you may not know how to check your GDExtension is even loading. While the docs explain how to create and register classes, people may not look there when starting a project. It's may be easier to have some boilerplate for it ready and get right to programming C++.

This PR adds a minimal class for example purposes. I don't think we should try to cover a lot of functionality with it, but a single registered function and some docs is probably enough for people to kick off their project from.

Ivorforce avatar Apr 14 '25 16:04 Ivorforce

I forget the details of the discussion, but I recall when @paddy-exe's template was moved to godot-cpp-template, we decided to remove the example class that was there previously. Assuming I'm not remembering that incorrectly :-) - does anyone remember the reasons for that?

dsnopek avatar Apr 14 '25 17:04 dsnopek

I forget the details of the discussion, but I recall when @paddy-exe's template was moved to godot-cpp-template, we decided to remove the example class that was there previously. Assuming I'm not remembering that incorrectly :-) - does anyone remember the reasons for that?

Yep I remember that discussion as you explained David. The reasoning behind this as far as I can recall was that it was easier to just set it up instead of having to rewrite/delete the old boilerplate code. Also the template is set up for people familiar with the system and specifically not for newcomers.

paddy-exe avatar Apr 14 '25 18:04 paddy-exe

Interesting! I'd definitely argue that not having an example increases the barrier to entry. While we probably want to guide new godot-cpp users to the docs / tutorials as much as possible, having one example class would have been enough to get me started more quickly when I first used godot-cpp. If you don't mind, perhaps we can quickly talk it over at the next GDExtension meeting (or when we have time anyway)?

Ivorforce avatar Apr 14 '25 19:04 Ivorforce

Discussed at the GDExtension meeting and the folks present were all open to including a simple example to help folks get started. One caveat that was brought up was that this could lead to a "slippery slope" with regard to adding more and more things to the example. To avoid this, we don't want to expand the example beyond what is here.

@akien-mga From our recollection, it was you that requested that the original example class was removed when the "godot-cpp-template" project was created, but we're not sure where that conversation took place. Do you have any thoughts about this?

dsnopek avatar Apr 29 '25 22:04 dsnopek

We should include an example of _notification and NOTIFICATION_READY in the example class.

Personally, I don't think this is necessary. I think what we should just have the bare minimum here.

What we really need is a collection of demo projects, similar to the godot-demo-projects repo but for projects using godot-cpp, where we can show real full examples of various use cases.

dsnopek avatar Apr 30 '25 13:04 dsnopek

@akien-mga From our recollection, it was you that requested that the original example class was removed when the "godot-cpp-template" project was created, but we're not sure where that conversation took place. Do you have any thoughts about this?

Personally I consider that a template is something that should be ready to use, without having to first delete unwanted demo content. Any project started from this template would need to delete ExampleClass / example.{cpp,h} after having seen it once to understand how it's used, or git mv it and rename the class. This pollutes the Git history too, though it's not egregious.

Demos to show how to do various common tasks are great, but they should not be part of the template and brought along every time someone starts a new project. They should live in their own repository which people can reference alongside the documentation to know how to implement stuff (possibly copying some of it to their template-generated project if they want).

Still, if there's otherwise consensus to add this here, this isn't a hill I would die on. The example is minimal and maybe people won't use this template frequently enough that having to delete/rename a demo class would be a bother. And I do understand that getting started with godot-cpp isn't super trivial so having a concrete example does help set things in motion.

akien-mga avatar Apr 30 '25 15:04 akien-mga

Personally I consider that a template is something that should be ready to use, without having to first delete unwanted demo content. Any project started from this template would need to delete ExampleClass / example.{cpp,h} after having seen it once to understand how it's used, or git mv it and rename the class. This pollutes the Git history too, though it's not egregious.

Personally i find it easier to edit a class than to add a new one from scratch. Most of the boilerplate is the same, just the name changes :)

Demos to show how to do various common tasks are great, but they should not be part of the template and brought along every time someone starts a new project. They should live in their own repository which people can reference alongside the documentation to know how to implement stuff (possibly copying some of it to their template-generated project if they want).

Totally agreed, the idea is just to have something so if you're new you have something to test.

Ivorforce avatar Apr 30 '25 20:04 Ivorforce

All done!

Ivorforce avatar May 15 '25 16:05 Ivorforce

Merged thank you! Also thanks everyone for the reviews and discussion!

paddy-exe avatar May 15 '25 20:05 paddy-exe