All Questions

Community

A
Ashraz

Is it considered bad practice to bind a signal to a native method?

Given that _on_HideButton_pressed() only calls hide(), I wondered whether it's possible to just skip that and immediately call the existing CanvasItem.hide(). And yes, that's possible:

However, I wonder whether this is considered good or bad practice. What are your thoughts on skipping trivial wrappers?

  • Nathan Lovato replied
    Solution

    What are your thoughts on skipping trivial wrappers?

    That's a great thing to do in general, that's less indirection in your code. I would just recommend being as consistent as possible and either connecting most signals through the editor, either connecting none.

    At GDQuest, while we teach the editor interface to connect signals, in our projects we connect everything by code. That way when looking for any signal connection in any project, you know you just have to make a script search.

    You'll see in the course that past the first lessons, where we try to break things down and make them more explicit for learning, we will directly connect signals to existing functions when possible.