Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
besides: https://javascript.info/coding-stylestyle-guides The JavaScript language - Code quality - Coding Style Is there any thing to recommend as far as coding styles are supported in Coppercube. Long time ago when i was young you had procedural programming and Object Oriented Programming and spagetti code, that was all basically. In JS there is: - AMD style ( the Asynchronous Module Definition (AMD) API for JS ) -CommonJS's module specification is widely used today, in particular for server-side JavaScript programming with Node.js -UMD Universal Module Definition -Module Pattern and many more and it get quite confusing. It bothers me because if i want to use different path finding methods, say Astar for enemy type A and DepthFirstSearch for enemy type B then I get overlap in NameSpace, Objects and Functions for say: Matrix(), node(), path, vertex(), edge, sort etc and that leads to difficult bugs. So i want to lock variables and functions to their NameSpace and combine entire methods / recipies into single files. Any ideas advice tips ? |
||||
|
My JS code looks more like Basic. I don't care. It's got to be stabile, reliable, readable. There's a simple fact of global namespace outside functions and local namespace inside functions. Things like nonlinear multithreading with promesis etc. are not a feature IMHO, but a paininthea we have to live with. Anyway, when I marry two parts of code, there's always a chance of namespace conflict, so what I did was I wrote a tool that would simply prefix all variables, functions and other userdefined names with a certain, unique string like "GUI1__" for one file and "GUI2__" for the second (in case I had to have two GUIs in a program, yes silly example, however). This method successfully applies the KISS method, but it also requires a list of javascript reserved words, so you don't prefix those. For a language like js, that is rather flexible, such a prefixer tool would be quite some work. Maybe it already exists somewhere. BTW I was using mine for Blitz3D, not js. |
|