0 Favourites

Legibitliy vs less events: What do you think?

  • So, Im making an engine template for the store.

    I want to make it as easy to understand as I can, so I try to divide funcionality blocks into groups, but to make it like that Im kind of forced to repeat some conditions that could be on the same event.

    One of many examples: I have a group that manages the animation of a character and wich animation to display on any situtation; on it I have an on landed platform event to make the character perform a landing animation before going idle.

    I also use the same on landed event to change the platform physics so the character handles differently on land than while he is airborne, but I want to put all that stuff on his own "Physics" group, hence the need of a repeated on landed event instead of doing all that stuff on the same one.

    Yeah, I guess the performance hit would be pretty much non-existant or in any case negligible, but....I dont think is a good practice anyways.

    Easier of understand code vs economy of events.....What do you guys think?

  • Readability for sure. It'll be easier for others to modify when they understand what's going on, and the tech-minded can optimize it themselves if they like.

  • I prefer to do a clean, easy to read code. I tend to avoid duplicate conditions and I use functions where they're feasible. It depends on your project though.

  • In a perfect world, you would strive and achieve both.

    Realistically speaking, aim for legibility with helpful comments at every point, specially since you are making it for others.

  • I still dont like unnecesary events, but I'll go for legibility then... thanks, everyone!

  • Making it more readable (at the price of redundancy) will certainly reduce the number of support requests you get. In the end, when people got how it's done, they will do the refactoring by themselves.

  • In the coding world, clear code is always better than clever code. I think the same applies for events: make it clear and easy to understand, rather than using tricks to make it use fewer events. The only circumstance you should break this rule is if you run a profile and measure that those events are causing a significant slowdown, in which case you might want to use clever tricks to speed it up, but that is surprisingly rare.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Thanks again!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,155
karshinkoff's avatar
karshinkoff
Unread hot topic
56 4,736
MPPlantOfficial's avatar
MPPlantOfficial
Unread hot topic
42 7,787
jobel's avatar
jobel