Post

📣 call for feedback! I'm having second thoughts about the naming of the functions in my #webGL library. TL;DR: is it ok to have functions starting with "use" in a vanilla JS library ? explanation in thread 🧵

I like the hook-style naming with "use" because the functions actually behave like hooks (output destructuring, re-render when updated etc), but I wonder if they could be confused with "real" hooks or composables in a react or vue codebase. I'm not sure if it would be a big issue though.

Also, I don't know what other names to use: I can't remove the "use" because the functions would have the name of the object they return. e.g, "const compositor = compositor(...)" is not possible. And I don't want to prefix "createXXX" on all functions. So yeah, I would appreciate some feedback!

Most functions create and/or initialize something so it would rather be createXXX, but I don’t really like that 🤔

Julien Sulpis@jsulpis.dev

Ok I understand, in my case I think it would be something like « createRenderPass(…) », but it seems a bit verbose to me. I also thought about a « gl » prefix, like glRenderPass(). It’s shorter and allow to separate WebGL related stuff from JS utils. I think I like this one. What do you think ?

0 reposts0 likes

No replies yet.