Live data from Hacker News

Application Architecture with React: Rethinking Flux

dialelo.github.io

31–40 of 53 posts

Re: Application Architecture with React: Rethinking Flux

#31
post #23

I feel like every new architecture for flux lately comes at the cost of a lot of code complexity. The global state is becoming extremely common too, and it feels like a big anti-pattern. Not really a fan. I do like the more pure-flux Alt at the moment. I felt quickly put off from Redux after going through docs for a while.

Only the states that can be global need to be global. It's not an anti pattern to manage state inside the component.

Re: Application Architecture with React: Rethinking Flux

#32
post #23

I feel like every new architecture for flux lately comes at the cost of a lot of code complexity. The global state is becoming extremely common too, and it feels like a big anti-pattern. Not really a fan. I do like the more pure-flux Alt at the moment. I felt quickly put off from Redux after going through docs for a while.

databases are global state (The design pattern here is separation of code from state. OOP couples code (methods) and state (members))

I realize that about databases, yes. I think the particular ways that frameworks have been trying to handle state are bad patterns. Not sure what would be better at the moment, but currently it's a mess.

Re: Application Architecture with React: Rethinking Flux

#33
Maybe it's just my peers :-) but this highlights to me why I've been reluctant to adopt React. I keep getting eye rolls about not using it - but everyone I encounter seems to in the process of still figuring out application and architecture basics? We weren't an Angular shop, so never had the problems that React seems to target with one-way, etc.

Re: Application Architecture with React: Rethinking Flux

#34
post #27
post #15

Earlier quoted context omitted.

Many developers are capable of learning a second language. If they are stupid about hiring they will insist on experience with ClojusreScript. And lets face it most companies will do that.

Really? Good luck convincing good JS developers that they should actually be doing Clojurescript at work instead. Maybe you'll have better luck at a local frequent clojurescript meetups (probably doesn't exist).

I work near a team of people I'd consider "good JS developers". If I were to just go over to their workspace and say, "We should totally use Clojurescript", they'd look at me with a mixture of "LOL, Emacs" or "This guy's a loon".

However, if I were to give a presentation talking about how I took X and rewrote it as Y in Clojurescript, and the benefits of doing that -- time, ease of debugging, code readability -- I'm pretty sure that they would not dismiss it immediately. (Of course, this would require me to actually learn Clojurescript well enough to rewrite my JS things in it. ;))

Re: Application Architecture with React: Rethinking Flux

#35
post #33

Maybe it's just my peers :-) but this highlights to me why I've been reluctant to adopt React. I keep getting eye rolls about not using it - but everyone I encounter seems to in the process of still figuring out application and architecture basics? We weren't an Angular shop, so never had the problems that React seems to target with one-way, etc.

It takes a while to get a sense of appropriate component boundaries. Like other decisions, this involves tradeoffs.

I've found that I sometimes err in the direction of making components too granular, when this makes the data flows more complex.

Boundaries should exist for encapsulation, but also for change management, reusability, and interfacing with data.

Yes, components can be misused.

I've found that codebases such as rails apps often have so much boilerplate and blind following of conventions (equating to many, many lines of code) that the more fundamental issues like flawed domain modeling or incorrect abstractions are rarely even considered a problem.

Re: Application Architecture with React: Rethinking Flux

#36
post #33

Maybe it's just my peers :-) but this highlights to me why I've been reluctant to adopt React. I keep getting eye rolls about not using it - but everyone I encounter seems to in the process of still figuring out application and architecture basics? We weren't an Angular shop, so never had the problems that React seems to target with one-way, etc.

It takes a while to get a sense of appropriate component boundaries. Like other decisions, this involves tradeoffs. I've found that I sometimes err in the direction of making components too granular, when this makes the data flows more complex. Boundaries should exist for encapsulation, but also for change management, reusability, and interfacing with data. Yes, components can be misused. I've found that codebases su…

Yes true, and to be clear, I think React is fine on it's own. It's just that from my view it's not fundamentally so superior as to warrant rewriting a decently structured app written in one of the other JS frameworks from the past few years. Especially if folks then go and have to reinvent/relearn, well, everything.

A lot of "React" excitement folks shared with me had more to do with using Webpack and ES6, which you can use with other frameworks.

Re: Application Architecture with React: Rethinking Flux

#37
post #5

> Om solves this problem with an abstraction called Cursor, which lets us focus on a path of the global atom and offer the same API as atoms. This allows views to treat the substructure as their data source and even modify it with the same operations as the Atom. I wrote a simple implementation of this concept for using it with atoms and immutable data. FWIW Om Next moves away from cursors and towards something close…

> Om Next moves away from cursors and towards something closer to GraphQL/Relay queries. Can you elaborate, I watched the Om Next talk i think you're referencing and recall David saying this, but I do not really understand why or what Cursors have to do with GraphQL/Relay as they are separate concerns. (Cursors are a way to update deeply nested data structures and don't do I/O, GraphQL and Relay are ways to coordinat…

Both cursors and Relay involve syncing a "database" to a declarative view object- In Om Next, there will be a new query language that maps the database to the views, so it can be used both for in-browser data (like cursors) and server data (like Relay).

What makes Om Next special (or so is the hope, very little specifics are available yet, but the author that makes these claims has a stellar reputation) is that the query syntax gracefully handles component composition and removes a lot of the "magic" of maintaining reliable link with data residing on the server.

Re: Application Architecture with React: Rethinking Flux

#38

Earlier quoted context omitted.

As I understand it, immutability makes management of state on complex objects easier to deal with. Whereas ImmutableJS the library makes immutability performant in JS. Someone please correct me if I'm wrong because I cannot seem to locate my source anymore, but I believe what ImmutabilityJS does is not actually deep-copy complex objects, but reuse references to nested objects that have not changed. Such that you get…

When you use Immutable JS, you are taking a slight performance hit. You are creating a new object every time you change anything and returning it. But the benefit of not having to worry about unexpected changed or sometimes referencing something you didn't mean too is great. The added performance can come from the equality checks. Like, do not do anything if newState === oldState. This has added benefit with somethin…

I think you know this, but just so that nobody gets the wrong idea- the new object created only uses as much memory as the difference between the new object and the old one. Immutablejs keeps track of the diffs and presents an interface to something that acts like a whole new object but consists of the old object + diffs.

So if you are replacing some in-place array mutation with Immutablejs code, this will use slightly more memory. However, if you are replacing native .map, .reduce, or .filter code with the equivalent Immutablejs, you will actually use less memory, because the built in methods clone the entire object.

Re: Application Architecture with React: Rethinking Flux

#39

This feels similar to NuclearJS[1], which I've yet to use in anger, but seems like a pretty nice wrapper on top of using one big immutable data store. [1] http://optimizely.github.io/nuclear-js/

I found Nuclear to be pretty great. It's not as pure or functional as something like Redux, but it has everything you need, and it is well tested and mature.

Re: Application Architecture with React: Rethinking Flux

#40
post #36

Earlier quoted context omitted.

It takes a while to get a sense of appropriate component boundaries. Like other decisions, this involves tradeoffs. I've found that I sometimes err in the direction of making components too granular, when this makes the data flows more complex. Boundaries should exist for encapsulation, but also for change management, reusability, and interfacing with data. Yes, components can be misused. I've found that codebases su…

Yes true, and to be clear, I think React is fine on it's own. It's just that from my view it's not fundamentally so superior as to warrant rewriting a decently structured app written in one of the other JS frameworks from the past few years. Especially if folks then go and have to reinvent/relearn, well, everything. A lot of "React" excitement folks shared with me had more to do with using Webpack and ES6, which you…

I think this is true. One should always very carefully consider the notion that a rewrite is a good idea.
Post reply on HN