3 ms·
I was just asking for a simple code example not a philosophical debate about assumptions, orthodoxy and doctrine. Isn't it possible to connect your abstract id
by thomashop 5y ago
I was just asking for a simple code example not a philosophical debate about assumptions, orthodoxy and doctrine.
Isn't it possible to connect your abstract ideas to a real world example? And why create en extremely obfuscated react class implementation of something that can be done in 3 lines of functional react code?
- deleted 5y ago[deleted]
- kristopolous 5y agoSure. All of them can be organized as hierarchies and that's the point, the organization is codependent with the communication. Let's say you have things with locations and a map (scooters, restaurants, hidden gold, whatever). You click a thing, it highlights it on the map. You click the map, it highlights a thing. The obvious to me way of doing this is singletons (or globals). You've got some routine itemhighlight(thing) or mapcenter(thing) and you generate the things on the page and use something simple like html data attributes to pass things around. In react there's a fairly unorthodox hack I've got to do things like this but normally you'd have a map component and then some list component with item components. Then when you tap the map, the stuff is passed up to a container component that gets passed to the list component that goes back to the item component, so long as you create some connections for that to happen. Everything goes up and down the hierarchy. You don't just directly talk horizontally. Now sure, there's arguments for and against both approaches and they are as contentious as type systems and editors. But the question was about the "scolding nanny". Without react you can do both approaches, the first of which requires competency and skill to do well without creating a mess sure. But in react you are precluded from doing the first unless you wrangle it and work around the framework. It disciplines and limits your freedom. I understand corporate hierarchies, pecking orders, and reasons for doing this. I'm a true anarchist though and that limitation really pushes my buttons. Given all that, I use react regardless because I first and foremost try to be responsible adult and think it's the current most popular and professional way to do things for the day I'll eventually move on and hand over my code to someone else. But I fucking hate it. It's a seething and very unhealthy vitriolic hate.
- thomashop 5y agoYou can have global singletons in React too that trigger events without passing them through the component hierarchy. It's just not clean design in my opinion. The same reason we avoid global variables in most applications, frontend or not. If you want to go for a sane way of managing global state you can use redux or context which don't require you passing state up and down the component hierarchy. But in my experience, usually when you design your hierarchy and your data well it makes most sense actually using the hierarchy to your advantage. There's something fractal about it where the higher-level components deal with higher-level state and problems. In the case of the map you have a shared state between the map and the controls which should be explicit in my opinion and not hidden in one of the components' html data attributes. The more complex applications I develop, the more appreciate the concept of having a "single source of truth" and not sprinkling states in child components.
- kristopolous 5y agoRight, I claim that limitation was self-imposed and then they found out how unreasonable it was so now they have multiple workarounds in order to emulate the functionality you'd get without them there at all. So instead of the direct path, now you are doing a much more complicated circuitous path because the orthodoxy had to be amended. Again, you're going to say this is good and I'm going to say it's bad. I see a problem where you see a solution. This is not reconcilable, that's why there's so many different programming languages. There's no right answer here and I'm ok with merely having a collection of opinions. It's like politics and religion. Whatever, people are different.