Best Practices formatting code and why

I love alle the support and good examples, but my “OCD” kicks in when reading unformatted code. :nerd_face:

I understand, I pretty much give up trying when I do it in the Hype editor and do not always want to open it up in another editor.

I generally never like using multiple apps to do one job and honestly would love the Hype editor to have the tools that help with formatting as well as organising.

I named this topic in the hope you can provide some more insight in the ways of doing things in the Hype editor.

One of the things I have mentioned in the past is var names.

It is best practice to name you vars with words that have meaning to the function that that will be used for and not abbreviate to just letters.

( and yes I slip I fall of the wagon every now and then )

Using meaningless letters especially single characters makes the code harder to follow the flow and understand. This is true even for the person writing the code.

i.e

bad

var x = hypeDocument.getElementProperty(ch, 'top')

good

var currentHourTop = hypeDocument.getElementProperty(currentHour, 'top')

Yes, although the recent addition of being able to use the tab key on entire blocks of code in Hype makes the job easier.

I often use a code beautifier before working on a file somebody posts on this forum. Either by opening it in VS code and running it there or pasting it into

https://beautifier.io/

Yes just found I can use vs code to do it.
It has a format document
alt + shift + f

1 Like