4 ms·
I know it's just an example... But the Slider code is ridiculously overwrought. Building this type of image carousel is trivial with just plain HTML+CSS+JS. Th
by pavlov 9y ago
I know it's just an example... But the Slider code is ridiculously overwrought.
Building this type of image carousel is trivial with just plain HTML+CSS+JS. This example uses "actions", "reducers", "selectors", weird functions from something called "redux-saga/effects", a "promise-based timeout" library AND generator functions to produce the magic ... of switching between images.
If someone I work with came up with this code, I would assume that the person is extremely bored with her job and wants to spruce up her résumé with buzzwords.
- namuol 9y agoI can't really speak for the Kea library directly, but the patterns used in React/Redux land are most valuable in large, evolving projects spanning many developers. Such benefits are therefore subtle and difficult to illustrate with concise examples. It's easy to dismiss these things as "buzzword" soup when the examples are trivial for illustrative purposes, but having real experience employing these patterns at scale is extremely valuable in the real world.
- jiert 9y agoAs you indicate, it's just an example. These libraries aren't for building image sliders, they're for building complex applications that you can't easily provide examples for.
- mariusandra 9y agoHey, indeed it's an example, as you point out. This was the best example I could come up with that demonstrated most of the functionality available, yet remained rather small in size. The point was to show what this library is capable of, so that people with the imagination of your imaginary co-worker could extrapolate its usefulness to real world applications. I have built 3 large applications using kea, and at that scale all these features come in handy.
- pavlov 9y agoJust to clarify, I'm not picking on you; I realize it's hard to come up with meaningful examples. The problem with Slider is that it doesn't readily extrapolate into anything bigger. To put it another way, it's not the embryo of any real world web app. I feel this indicates a larger problem with present-day web dev: due to the complexity of client and server stacks, it's really hard to come up with a self-contained example app that makes any sense as a starting point. Looking back some 20 years, one could look at the example apps from the Win32, Classic MacOS and OpenStep SDKs, and come out with a solid feel for what it's like to build an app on each platform. Today, I could compare the provided examples from twelve different JavaScript frameworks, and I wouldn't feel any closer to understanding their strengths.
- chickenfries 9y agoIt's an example. Do you also comment on new programming languages and say "jeez, all that code to say "hello world"! Why the scare quotes around "promise-based timeout" library? I can guess just by looking at the code that it's a Promise wrapper around setTimeout. It makes the example easier to read, since the API is based around promises and not callbacks. It's probably less than 5 lines of code.
- pavlov 9y agoSee my other reply below: I feel Slider is not a useful example because it doesn't extrapolate into any kind of real world web app -- which is a problem when this library is about helping you build real world web apps. The scare quotes are because it's hardly a library when it provides less than 5 lines of code, as you noted.
- chickenfries 9y ago> The scare quotes are because it's hardly a library when it provides less than 5 lines of code, as you noted. It makes the example easier to read for me, because I can figure out what it does by the context: 1. It's called "delay" 2. It's a function that takes 1 parameter, a number 3. There is a browser API called setTimeout, which takes a function and a number 4. Converting functions that take a callback to a function that returns a promise is a common pattern. I know what delay does without even needing to see it. Maybe if you don't know the 4 things I've listed above, this makes the example harder to read, but then you probably do not need this library. > I feel Slider is not a useful example because it doesn't extrapolate into any kind of real world web app -- which is a problem when this library is about helping you build real world web apps. It's an example on the homepage, not documentation. How many lines of code do you want to see? I feel like if you assume that the author wrote this to scratch their own itch, then you can use your imagination and assume that they work on apps with complicated state that needs to be persisted over a network, that gets fed to functional components. Edit: I read your other comment, and I agree it's really hard to come up with good, non-trivial examples.