3 ms·
Those are not global variables. They're TypeScript namespaces. Everything is in a namespace. I'm using namespaces to accomplish the "singleton pattern" in TypeS
by ClayFerguson 10y ago
Those are not global variables. They're TypeScript namespaces. Everything is in a namespace. I'm using namespaces to accomplish the "singleton pattern" in TypeScript, and to avoid globals. Most modern Java-Spring Server-side code usually uses lots of singleton services, and i'm doing the same sort of pattern, in TypeScript.
Regarding the generating of the presentation code being done in pure JS/TS rather than a bunch of template files rendered on the server is actually another innovation in disquise. This app is so dynamic that even if it were template-based the templates themselves would be 90% logic, which is why just generating presentation code on the client is ideal. This IS mainly a client-side app, that consumes a server-side JSON API, rather than getting any actual HTML from the server. Yes it's inverted from the way the rest most people are still doing it, but what I'm doing is the future. Learn a bit about microservices and RESTfull stuff and you might begin to see the light, about how a browser can consume an API that sends back JSON DATA rather than rendered HTML. It's the future. I'm doing it right. You just don't get it yet. And if you're irked by my confidence, frankly that makes me happy.
- pier25 10y agoI haven't seen your code, but using lots of Singletons is usually a code smell. > Learn a bit about microservices and RESTfull stuff and you might begin to see the light, about how a browser can consume an API that sends back JSON DATA rather than rendered HTML. It's the future. RESTful APIs are great but you are 10 years late to the party. Using RESTful APIs is exactly the same thing web services were back 15 years ago with XML. https://apievangelist.com/2012/12/20/history-of-apis/ https://apievangelist.com/2012/12/20/history-of-apis/
- ClayFerguson 10y agoI actually don't like RESTful stuff. I used the term to point out that the conversation between client and server is pure JSON which is the technique REST popularized. meta64 has a 'functional' interface to the server, and yes it's state-of-the-art. JSON up and JSON down.
- Kiro 10y agoI'm not talking about namespaces. I mean stuff like "srch" in https://github.com/Clay-Ferguson/meta64/blob/master/src/main/resources/public/ts/panel/timelineResultsPanel.ts https://github.com/Clay-Ferguson/meta64/blob/master/src/main... Also, singletons are simply bad practice so that's just another sign that your code is far from "state of the art". > Yes it's inverted from the way the rest most people are still doing it, but what I'm doing is the future. Of course you consume JSON through a REST API and let the client handle HTML generation when building an SPA. "The future" you're speaking of has been industry standard for 10 years. Nothing radical or innovative about it. How do you think React, Vue or Angular work?
- ClayFerguson 10y agosrch is namespace: I think it was about line 8 in this file: https://github.com/Clay-Ferguson/meta64/blob/master/src/main/resources/public/ts/search.ts https://github.com/Clay-Ferguson/meta64/blob/master/src/main... That's funny that you don't like singletons. Not sure how you got brainwashed about them, but they are good and VERY widely used today by all major codebases. Singleton is literally the "default scope" for all Spring Beans, so you are so completely clueless about that.
- Kiro 10y agoYou need to learn how to deal with dependencies properly. When reading a file it should always be obvious where the dependency comes from. There are a few use cases for singletons but using them as globals to avoid passing dependencies around is simply bad practice. Your code is a tightly coupled and untestable mess at its current state. It's funny that you arrogantly just dismiss every single person in this thread as idiots. You need to take a step back and consider that you might actually be wrong.
- ClayFerguson 10y agoSo it's not obvious to you that 'podcast.open()' is implemented in 'podcast.ts'? There is a naming-convention in effect.