by ClayFerguson · 9y ago · 0 comments
To prove my point: Here's the code for the Audio Player in meta64.
https://github.com/Clay-Ferguson/meta64/blob/master/src/main...
No one can possibly argue that an HTML template for that would be easier to read, than the TypeScript I've written. I think the way meta64 uses Polymer, TypeScript, generated-HTML, etc is the ideal architecture for the modern app.
BTW: I just picked a random example of my generated code from meta64. I do agree the CSS embedded in that would be better as a CSS class. I am not arguing for dynamically created CSS, but only dynamically created HTML (i.e. no templates). My point was that if you have clean code, you can make your HTML-code-generation look almost like the HTML itself, or be 'as readable' as it would be if it were an HTML template. Readability is the key here. That's all that counts. If you can achieve that in JS/TS then it beats a template approach easy, because of its power in terms of OOP, reuse, etc, which templates are just awkward with.
https://gist.github.com/anonymous/e506ac871c32b169ce5760de9d...
I think I still prefer the html style markup, but probably only because I am used to it.
Or specifically ():, I know arrow functions.
the colon refers to flow and typescripts type annotation "colon something". none-objects are lowercased
build(): string { ...
but they generate different JavaScript. The way it's written will give each instance its own reference to the function. The "build(): string" above will add the function to the prototype, which is shared by all instances.I'm not sure whether the code takes advantage of this difference in some way or not. If not, it's just a slightly more awkward and less efficient way of defining a method.
I think without the typing it would just be build = () => {
var build = function(){...} //return a string
Rather than some other commenters, and I would have thought given arrow functions; var build = function(string){...}(35 years experience)