Legibitliy vs less events: What do you think?

Discussion and feedback on Construct 2

Post » Mon Oct 10, 2016 7:30 pm

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?
B
26
S
7
G
1
Posts: 74
Reputation: 2,092

Post » Mon Oct 10, 2016 10:14 pm

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.
B
39
S
16
G
6
Posts: 543
Reputation: 7,619

Post » Mon Oct 10, 2016 10:19 pm

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.
B
135
S
33
G
17
Posts: 1,557
Reputation: 20,721

Post » Mon Oct 10, 2016 11:37 pm

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.
B
36
S
18
G
11
Posts: 248
Reputation: 8,694

Post » Tue Oct 11, 2016 1:47 am

I still dont like unnecesary events, but I'll go for legibility then... thanks, everyone! :D
B
26
S
7
G
1
Posts: 74
Reputation: 2,092

Post » Tue Oct 11, 2016 8:47 am

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.
B
77
S
28
G
32
Posts: 481
Reputation: 19,763

Post » Tue Oct 11, 2016 12:04 pm

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.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Tue Oct 11, 2016 5:15 pm

Thanks again!
B
26
S
7
G
1
Posts: 74
Reputation: 2,092


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 1 guest