|
Is there something I'm missing that makes configuring Angular TestBeds not a massive headache? Having to create a test module with the dependencies for every child component ends up taking more time than actually writing the tests.
|
# ? Feb 11, 2017 02:15 |
|
|
# ? Jun 10, 2024 11:53 |
|
Munkeymon posted:This is what you're talking about, right? That's exactly what I'm talking about, thanks. The highest rated answer suggests using code:
Plavski posted:My tech lead gets pissed when I bring him examples of complex js optimizations we could make where the difference is 0.01s over 10,000 iterations. "I'd rather have readable code that's slower than unreadable nonsense no-one else will be able to read after we fire you for writing unreadable code." Intern/Junior Developer: writes garbage code that is slow Developer: writes garbage code that is fast Senior Developer: writes garbage code, but less of it, and it is fast enough to meet the needs of the business You should strive to (intelligently and professionally) push back on business requirements, leverage 3rd party libraries when available, lean on the language and framework to provide as many guarantees and to write as little code as possible, and keep it as simple as possible. I've heard this referred to as design by guarantee, which isn't a real thing. The more code you can not write due to guarantees, the fewer bugs you'll have, and the more you can work on the interesting problems in your domain. If your micro optimization doesn't provide tangible value to the company, you wasted your time and probably other people's time. luchadornado fucked around with this message at 02:59 on Feb 11, 2017 |
# ? Feb 11, 2017 02:35 |
|
ddiddles posted:Thanks man. The cure to this one is to do a project where you literally have no idea of how half of it should work when you start out because the client hasn't told you yet and so you just go "gently caress it" and put in stuff that more or less works and go back and change it later (and then again later when the client inevitably changes their mind well after they give you the full spec).
|
# ? Feb 11, 2017 05:58 |
|
Thermopyle posted:That diagram could use someone going over it a few more times, but...it seems pretty straightforward? At least when it comes to forms. Totally agree. People who think forms are easy have just been making terrible forms.
|
# ? Feb 11, 2017 06:01 |
|
Plavski posted:My tech lead gets pissed when I bring him examples of complex js optimizations we could make where the difference is 0.01s over 10,000 iterations. "I'd rather have readable code that's slower than unreadable nonsense no-one else will be able to read after we fire you for writing unreadable code." He's right.
|
# ? Feb 11, 2017 06:03 |
|
Helicity posted:That's exactly what I'm talking about, thanks. The highest rated answer suggests using The need to do this concerns me a bit. Needing to mock out something that you're importing strikes me as a sign that the dependency shouldn't be imported but instead passed in. I mean in the linked example, he has a class called Widget that is importing a function to retrieve data from a server. The class has a constructor with no arguments that could take that function as an import, or just call the function first and create the Widget with the data. Making the side-effect-ful dependency an object passed in to the constructor instead of a static import would also make it much clearer what the widget needs to do its job too, and what kind of side effects it will have. Plus you won't need to worry about mocks since you just pass in data as it would be normally.
|
# ? Feb 11, 2017 06:43 |
|
piratepilates posted:The need to do this concerns me a bit. Needing to mock out something that you're importing strikes me as a sign that the dependency shouldn't be imported but instead passed in. I agree, and so do most of my co-workers. Most of my team has experience in C#, or at least Java, and we keep saying "this kind of feels like we need DI, but ugh..." Where that breaks down, and what is currently stumping us, is when you bring functional programming into it - our stack is React, react-router, and redux. First, we don't have baked in DI like angular or aurelia do. My first guess is to do some sort of monadic, higher order function type thing to be able to wrap any function and pass in parameters as a sort of DI-lite. I guess the real question is: how should you manage your inter and intra-module dependencies in JavaScript while embracing the more functional aspects of the language, and if DI is the answer, what are the best options there when your framework doesn't provide it?
|
# ? Feb 11, 2017 14:25 |
|
What do you guys recommend for Angular R&D? I've still super green on it and trying to find an answer for my question* I either get: Something Unrelated The Answer in AngularJS The Answer in a pre-release of Angular 2 that no longer works. *The question is, how do I make a <select> where the values and text are just integers. From 1 to X (X i suppose could be hardcoded at 10, but ideally object.max if object.max < 10 (otherwise 10) )
|
# ? Feb 16, 2017 15:57 |
|
The Merkinman posted:What do you guys recommend for Angular R&D? What version of Angular are you looking for? 2? Angular doesn't care what types your values/text are. You can use ng-options or even ng-repeat to do it.
|
# ? Feb 16, 2017 16:07 |
|
HaB posted:What version of Angular are you looking for? 2? Angular doesn't care what types your values/text are. You can use ng-options or even ng-repeat to do it. I'm looking for version 2. Aren't ng-options and ng-repeat AngularJS 1.X things? I see them done with: code:
|
# ? Feb 16, 2017 16:34 |
|
The Merkinman posted:I'm looking for version 2. Aren't ng-options and ng-repeat AngularJS 1.X things? Numbers are objects... code:
|
# ? Feb 16, 2017 16:46 |
|
The Merkinman posted:I see them done with: If you already have a list of numbers, then the "object" there is a red herring, it's just iterating over a list. In JS syntax *ngFor is a for...of statement. If you're looking to emulate for (var i = 0; i < x; i++), then yeah you'll have to generate a list and iterate over it.
|
# ? Feb 16, 2017 16:48 |
|
dupersaurus posted:If you already have a list of numbers, then the "object" there is a red herring, it's just iterating over a list. In JS syntax *ngFor is a for...of statement. If you're looking to emulate for (var i = 0; i < x; i++), then yeah you'll have to generate a list and iterate over it. Thanks yeah, I came to the realization that I'm used to doing what you mentioned, but I have to generate that thing elsewhere then use it. EDIT: What about my original question of reseourches for R&D (and documentation) I know the angular docs, but not sure how to 'phrase' a question so I'd find it there.
|
# ? Feb 16, 2017 17:19 |
|
The Merkinman posted:Thanks yeah, I came to the realization that I'm used to doing what you mentioned, but I have to generate that thing elsewhere then use it. I usually start with relatively straightforward questions "how do I make dropdown in Angular" and go from there, keeping in mind that most examples will be poo poo and tell you really dumb things to do, but sometimes there will be an idea or clue in them to figure out something not so lovely.
|
# ? Feb 16, 2017 17:24 |
|
Is there a standard way of conditionally rendering a class based components contents in React? I have a component that will render three completely different views depending on the props passed into it from the redux connect function, (loading indicator, nothing found indicator, and then the data itself). I've been going back and forth, moving all the conditional stuff into a method on the class, and having the render method just call that method every time the components rendered, and on some components, I put the conditional logic inside the render method itself. Both technically work, and the only reason I've mixed and matched is because I usually forget what I did on a previous component. I'd like to stick to one pattern as much as possible, and if there's a generally accepted way to do it I'd rather use that way.
|
# ? Feb 18, 2017 23:19 |
|
Keep as much logic as you can out of components, and the logic as close as you can to the source. In a perfect world, most of your components will be pure functions and have no state.code:
code:
|
# ? Feb 19, 2017 00:38 |
|
Most of my components have no state of their own, more often then not they are getting called by their Container, which is connected to the redux store. I guess it would help if I explained what Im doing. For example, I have a Companies container that connects to my redux store. It calls an action generator with componentWillMount() that grabs a list of all the companies I have stored in firebase, formats that data into an array and dispatches an action with that array as a payload, or dispatches a different action if there wasnt any data returned from FB or there was an error. These actions set some flags on the store that the Companies container also has as props. So in my render method on the Companies container, I have the following logic: 1. If this.props.flags.started is true, return JSX that renders a loading spinner. 2. If this.props.flags.failure is true, return JSX that renders a message saying there wasnt anything found. 3. If an array exists on this.props.companies, then render that list. 4. If none of these are true, it means that the initial action didn't get fired off and theres something wrong with the code. I have another container that grabs a different list of data, but the logic for formatting and displaying it is the same, and in that container, all the logic above is in a renderView() method, and the render() method calls that. Just wondering which way was more "proper", or does it even matter?
|
# ? Feb 19, 2017 01:47 |
|
ddiddles posted:Most of my components have no state of their own, more often then not they are getting called by their Container, which is connected to the redux store. There's no "right" way to do it since it will vary so much based on your app. One approach is to abstract the common patterns ("show a Loading if I'm loading or something else if not") into components (or base classes) al la: JavaScript code:
JavaScript code:
JavaScript code:
JavaScript code:
The key (for me at least) is to think of small things and compose compose compose!
|
# ? Feb 19, 2017 19:35 |
|
Has anyone worked with/built an api adhering to this spec before? http://jsonapi.org/ (Any advice or guidance around using this type of API is appreciated!)
|
# ? Feb 21, 2017 22:13 |
|
I have. I'm not sure what you're looking for. If you strip out all the optional bits, it's pretty straight-forward to hand-roll on both the front- and back-end. Don't do that, though; just look for your language(s) in the list of implementations on that site.
|
# ? Feb 21, 2017 23:06 |
|
I've worked with it before. It's not a gamechanger, but I didn't find any obvious downsides to it and it solves the primary goal of preventing bikeshedding - so it's cool I guess? Even if you ignore the part that takes extra effort, the links, it's helpful if just to standardize the response and error codes/content.
|
# ? Feb 22, 2017 00:20 |
|
I'm really not looking for anything except for any super-important advice that i may not get from scanning the documentation. It does look like the redux implementation library uses redux-thunk which we are currently not using in favor of redux-saga, so I'm not sure if we'll have to roll our own translation to/from the API on the front-end.
|
# ? Feb 22, 2017 00:46 |
|
Tying API data standards to implementation middleware for handling asynchronicity sounds horrible and that's why I hate working in front-end stuff these days. Not a slight on you/your team, more of on the JS world.
|
# ? Feb 22, 2017 01:02 |
|
Ellie, an embeddable jsfiddle-a-like for Elm. Even installs packages.
|
# ? Feb 26, 2017 02:01 |
|
Doc Hawkins posted:Ellie, an embeddable jsfiddle-a-like for Elm. Even installs packages. I desperately want to make a Real Thing in elm. Maybe my next side project should I ever finish the three languishing on my hard drive currently.
|
# ? Feb 26, 2017 06:46 |
|
What do you guys use for your unit/e2e testing?
|
# ? Feb 26, 2017 12:38 |
|
Plavski posted:What do you guys use for your unit/e2e testing? My brain
|
# ? Feb 26, 2017 19:19 |
|
Plavski posted:What do you guys use for your unit/e2e testing? for our react app -- unit -- karma/mocha/chai/enzyme and a couple of karma plugins like karma-webpack e2e - none yet
|
# ? Feb 26, 2017 23:14 |
|
Plavski posted:What do you guys use for your unit/e2e testing? A small army of button-clickers in India. Tests run automatically overnight and generate bug reports and everything.
|
# ? Feb 27, 2017 17:22 |
|
We use Karma/Protractor
|
# ? Feb 27, 2017 18:17 |
|
I'm considering going back to Jest for unit testing...it seems to have improved a lot since I last used it a couple years ago.
|
# ? Feb 27, 2017 22:53 |
|
mocha/sinon/chai/enzyme primarily, although I'm personally trying to limit the use of sinon by leveraging function composition that essentially acts like dependency injection. For personal stuff I prefer should to chai. Our legacy stuff uses karma/phantom and is a pain in the rear end - mainly because it's "unit tests" that are actually more like convoluted integration tests of jQuery widget garbage wrapped in Angular. For anything non-unit test we're using Cucumber, but it is even more problematic than the karma/phantom stuff. Our company wrote years and years worth of Cucumber tests and now our testing monolith is almost as scary as our code monolith. We're had to devote several weeks to reading "Art of Unit Testing" and "Working with Legacy Code" to try and get people up to speed on why this stuff is bad and how to change it. I briefly looked at testdouble, but the author brags about creating testing frameworks from the ground up several times and has some horrible opinions on testing via Reddit/Twitter, so I've automatically discounted it as a piece of poo poo based on that.
|
# ? Feb 28, 2017 14:06 |
|
Thermopyle posted:I'm considering going back to Jest for unit testing...it seems to have improved a lot since I last used it a couple years ago. I'm going to be trying to implement Jest on my current project this week.
|
# ? Feb 28, 2017 17:05 |
|
Today we had some contractors from Cognitect over to help us with our React-Redux components and one of the more illuminating revelations of the meeting was that our tech lead did not understand how React and Redux worked. The contractors shared my horror and frustration at our implementations and code and naturally, it turns out that we're going slow due to the tech lead misunderstanding the point of the framework. No wonder we've been so frustrated and unproductive. I am genuinely kind of pissed off and annoyed here. I'm even more worried for my coworker whose first exposure to front end has been so poor for such a dumb reason. Just another thing on the pile.
|
# ? Feb 28, 2017 21:24 |
|
Pollyanna posted:Today we had some contractors from Cognitect over to help us with our React-Redux components and one of the more illuminating revelations of the meeting was that our tech lead did not understand how React and Redux worked. Based on what you've been asking / telling us in this thread we could have told you that for half what they charged you!
|
# ? Feb 28, 2017 22:21 |
|
Lumpy posted:Based on what you've been asking / telling us in this thread we could have told you that for half what they charged you! Now it's formalized. But will anything actually change? No. A haiku I guess.
|
# ? Feb 28, 2017 22:51 |
|
Pollyanna posted:Today we had some contractors from Cognitect over to help us with our React-Redux components and one of the more illuminating revelations of the meeting was that our tech lead did not understand how React and Redux worked. The contractors shared my horror and frustration at our implementations and code and naturally, it turns out that we're going slow due to the tech lead misunderstanding the point of the framework. No wonder we've been so frustrated and unproductive. I am genuinely kind of pissed off and annoyed here. I'm even more worried for my coworker whose first exposure to front end has been so poor for such a dumb reason.
|
# ? Feb 28, 2017 23:00 |
|
Forgall posted:Could you expound on this a little? I'm learning react and redux and I'm worried I might be misunderstanding things as well. If at all possible I'd get a firm grasp on React before learning Redux.
|
# ? Feb 28, 2017 23:01 |
|
Forgall posted:Could you expound on this a little? I'm learning react and redux and I'm worried I might be misunderstanding things as well. The React and the Redux docs are both really good and not terribly large, so it's hard for me to understand how someone could be a tech lead and not understand how they worked. I mean, there are a decent number of moving parts and I embarrassingly always have to re-read or skim the docs when starting a new project, but just understanding how they works shouldn't be too hard to pick up. Of course, it's a little difficult for someone who has experience to remember exactly what its like to come at something with no experience...but hell I understand how they work and I'm nothing special. A good thing to do in addition to reading the docs is watching these videos by Dan Abramov (creator of Redux): https://egghead.io/instructors/dan-abramov?order=desc&page=1 Kekekela posted:If at all possible I'd get a firm grasp on React before learning Redux. Also, this might be a good idea.
|
# ? Feb 28, 2017 23:06 |
|
|
# ? Jun 10, 2024 11:53 |
|
Kekekela posted:If at all possible I'd get a firm grasp on React before learning Redux. Thermopyle posted:A good thing to do in addition to reading the docs is watching these videos by Dan Abramov (creator of Redux): https://egghead.io/instructors/dan-abramov?order=desc&page=1
|
# ? Feb 28, 2017 23:11 |