7 ms·
No matter how I try to accept it, it is a really bad idea to embed views into business logic. You have no clear separation of concerns and this can create a lo
by kensign 11y ago
No matter how I try to accept it, it is a really bad idea to embed views into business logic. You have no clear separation of concerns and this can create a lot of headaches as the sophistication of the application grows. Instacart is a great product, but it has a lot of room to grow still. What happens when you get into some deeper aspects of UX? I presume you do your own UX research and these highly segmented views are going to be a pain to manage.
You'll also need to worry about how you run BDD tests for specifications and scenarios. How can this be achieved in React as you write test suites for user stories and non-UI acceptance tests? How will this impact your continuous delivery/integration systems as well? You'll have to rewrite all your test suites into Jest, right?
There are architectural trade-offs for sure. Can you definitely say you've performed a thorough analysis before making this decision? There's a difference between having a clear strategy to move from one tech to another and knowing that the migration will not just bury you into a deeper whole than the one you think you're escaping.
http://aurelia.io/ http://aurelia.io/ is based on webcomponents (MVVM), ES6, and current web standards. It's amazingly simple and good architects can use their own structural patterns to create code that can actually scale with the product. DDD and BDD methodologies mesh perfectly into the development workflow, especially with Agile product development.
I wish you well, but I really think React is a short sell with dire consequences.
- judofyr 11y agoThere's nothing in React which forces you to embed the views into business logic. React is just a view framework. How you structure your code is entirely up to you.
- sehr 11y agoThere's nothing in React that forces you to use Jest or rethink your testing process.
- anewhnaccount 11y agoThere is a clear separation of concerns. The React component is the view. React doesn't tell you what to do with the other bits (although people seem to have plenty of different ideas). There's generally less lock-in to a particular way of doing things with a view library like React than with a whole framework like the one you're promoting.
- madeofpalk 11y agoWhat you see mixed in with JSX is view logic, not business logic. I see the same thing in the Aurelia examples <h1>${router.title}</h1> <ul class="nav navbar-nav"> <li repeat.for="row of router.navigation" class="${row.isActive ? 'active' : ''}"> <a href.bind="row.href">${row.title}</a> </li> </ul> Which is almost identical in JSX: <h1>{router.title}</h1> <ul className="nav navbar-nav"> {router.navigation.map(row => ( <li className={row.isActive ? 'active' : ''}> <a href={row.href}>{row.title}</a> </li> ))} </ul> For loops and map functions aren't necessarily business logic, but they are view logic (and you'll see them in any sort of tempting or view system). React actually makes it very bad to include any substantial business logic into your templates as the render function is called many many times potentially whenever your data changes, so you want to include very minimal stuff in there. > You'll also need to worry about how you run BDD tests for specifications and scenarios. How can this be achieved in React as you write test suites for user stories and non-UI acceptance tests? How will this impact your continuous delivery/integration systems as well? You'll have to rewrite all your test suites into Jest, right? Exactly the same! At the end of the day, React is just Javascript. You still have your models in their own classes or functions, with your own API helper methods. How you write that doesn't change - no need for Jest. We're testing our entire app - including templates/views - using Mocha (and we're about to run tests in Karma in real browsers pretty soon).
- kensign 11y agoThe JSX is not the same as it is encapsulated in the render() method withing the JS file. This is the whole point of why this implementation is not a separation of concerns. The view is essentially embedded in the controller in order to simplify how a controller passes scope to the view. This isn't the first time people have fallen prey to embedding HTML as a string into JS to write the DOM. 5/10/15 years ago, if we saw this, devs would just shake our heads. If anything React is an old hack, an anti-pattern brought forward again. I misspoke about views in business logic, as you said, it is the controller logic, which should be decoupled from the view itself as well. The naive example of converting a webcomponent to a JSX component may look similar, but more complex components will only require greater complexity for the render() method to handle. I understand your rationalization, but the crux of the arguments here are concerned with the anti-pattern React introduces and why developers who've come across this before have seen this as technical debt. The arguments for React are a matter of opinion, wherein the arguments against it are based on the practical principles for programming UIs, principles have been forged to be tried and true since the 70's. I personally favor standards, such as webcomponents and OO programming for modules. I understand that this may not seem popular at this point and time, but 20 years of dev experience has taught me otherwise.
- Lazare 11y agoIdiomatic React code would not mix views and business logic. (You shouldn't have business logic on your React component's; that belongs in a completely different part of that app.) As for testing, you can do testing a lot of different ways, including BDD or DDD (I'm using a fair amount of DDD in the project I'm working on). But other than being a bit easier to test than many competing techs, there's nothing special about testing React code. And no, basically no one outside of Facebook is using Jest; it's a terrible testing tool. (I don't get the feeling you've spent much time writing or learning React? At any rate you seem to have some odd ideas about testing and React.) Aurelia is great, but I think you're vastly overestimating the differences between an idiomatic Aurelia-based project and an idiomatic React-based project, and underestimating the flexibility which React enables.
- borplk 11y agoThere's nothing in React that makes you "embed views into business logic". It sounds like your experience with React has been limited and based on just looking at things. As with anything else you will have some "view logic" (example: to render "1 item", "2 items") but not necessarily any "business logic". I'm not going to convince you in a comment reply but if you spend a significant amount of time with React you'll see.