Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
luchadornado
Oct 7, 2004

A boombox is not a toy!

neurotech posted:

Can anyone share some good examples of resumes that they've seen? I'm particularly interested in hearing from people who hire web designers and developers. If not, any suggestions on where I could find some good examples?

I've done probably two dozen interviews for interns up to architects in the last year. I look to hire people that are competent enough to not break poo poo requiring me to deploy code at 3am, work well on the team and with other people, and want to learn/get better. The last one is probably what I look for most.

1) Keep it short and relevant - two page resumes annoy me, three page resumes piss me off. I love one page resumes because it says to me that you value my time and you can say things succinctly and get to the point. I will ask about anything I'm interested in that you didn't put down.
2) Don't exaggerate - if you put down "C# (expert)" I will loving grill you on minutiae about memory allocation on the stack and other obscure things that I barely remember myself. If you say "I'm a lovely developer, but I'm less lovely every year" that's the perfect answer in my mind. Don't put down things that you've tried once, put down things that you have used at least several times but preferably on like a weekly basis at the least.
3) Be prepared to talk about poo poo you've done and problems you've solved. I don't care about whiteboarding or trivia (more on that later) - I care what problems you've faced and how you've solved them because it's unlikely you'll never need to implement a bubble sort or the fibonacci sequence in the real world. I don't care about "leading a team on 100 projects that created full stack synergy across silos blah blah blah". Can you make poo poo? Can you see problems and think of elegant solutions?
4) I love when people have personal Github pages even with stuff no one contributes to or personal sites with custom built stuff. I think I've hired everyone who said "I had a need, so I built this thing, here is what I built". That's way more useful to me than asking you to whiteboard something.

Regardless of what I said above, I usually do ask some trivia type questions and have people whiteboard. I do this to gauge their real world experience, their familiarity with their toolset, and see how they react when they don't know something or have a clean slate and no IDE to help them. Since my line of work is all about serving up lots of web pages using lots of services I love asking about caching, concurrency, and aggregation.

edit: I personally don't get hungup on which package manager you use or which MV* framework or whatever you picked. That's cool if you like Angular, Browserify, node, and LESS. I expect that you can verbalize your reasons for picking various aspects of a stack and also that you're happy to use something else if your personal preference isn't the right thing for the project, though.

luchadornado fucked around with this message at 02:23 on Jun 9, 2015

Adbot
ADBOT LOVES YOU

obstipator
Nov 8, 2009

by FactsAreUseless
I completely agree that motivation to learn is the key determining factor in whether or not I want you on my team. The last two guys that made it onto my team were junior guys that showed that they're interested in learning. Linking your github that shows you are interested in frameworks or solving problems or just plain contributing to things will prove that you would enjoy the job and are looking to improve, so in my eyes it is safe to assume that you won't end up like some slacker that does the bare minimum.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
As someone who has sat on the other side of the table unsuccessfully, it really does seem that some kind of a portfolio is a good thing to have. I really didn't have anything to show when I went to my first interview in a long time, but even the things I mentioned were discussed.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
In

Horn posted:

I have a react question that I've having a hard time googling and I'm hoping you fine gents could help me out. I'm writing an app that displays data, some of which is html. I've been using __dangerouslysethtml and things have been great (its scrubbed serverside). However, I'd like to replace some of the HTML with custom controls. IE someone might have a post that has something like <span>I love <span class="blue">react</span> <img src="www.facebook.com/react.png">. Is there a way to parse HTML and get back a collection of react components? For example, I'd like to be able to replace the img tags with a custom component.

All of this is loaded from a server so I don't believe I can use the clientside JSX renderer but I'd love to be proven wrong.

Inlining components to render really depends on your use cases, what goes in what. What you could do is one of two things:

Have a data structure which separates blocks of html and components, iterate over it, and keep the components as part of the render structure ie
code:

[{
  'type': 'html',
  'content': '<span>React is good</span>'
}, {
  'type': 'componentName',
  'props': {}
}]

This would require a wrapping element around each section of raw html, which may not be ideal.

Alternatively, render the lot as dangerous HTML, with intended components rendered like:
code:

<div data-component="componentName" data-props='{"inline": "json"}' class="reactComponent"></div>

Then after the component updates with the HTML, you iterate over it and mount components directly on instances of .reactComponent - however you'll lose those bindings every time the HTML needs to change so that may not fit the needs.

First approach is probably better if you can make it work.

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

Helicity posted:

I've done probably two dozen interviews for interns up to architects in the last year. I look to hire people that are competent enough to not break poo poo requiring me to deploy code at 3am, work well on the team and with other people, and want to learn/get better. The last one is probably what I look for most.

1) Keep it short and relevant - two page resumes annoy me, three page resumes piss me off. I love one page resumes because it says to me that you value my time and you can say things succinctly and get to the point. I will ask about anything I'm interested in that you didn't put down.
2) Don't exaggerate - if you put down "C# (expert)" I will loving grill you on minutiae about memory allocation on the stack and other obscure things that I barely remember myself. If you say "I'm a lovely developer, but I'm less lovely every year" that's the perfect answer in my mind. Don't put down things that you've tried once, put down things that you have used at least several times but preferably on like a weekly basis at the least.
3) Be prepared to talk about poo poo you've done and problems you've solved. I don't care about whiteboarding or trivia (more on that later) - I care what problems you've faced and how you've solved them because it's unlikely you'll never need to implement a bubble sort or the fibonacci sequence in the real world. I don't care about "leading a team on 100 projects that created full stack synergy across silos blah blah blah". Can you make poo poo? Can you see problems and think of elegant solutions?
4) I love when people have personal Github pages even with stuff no one contributes to or personal sites with custom built stuff. I think I've hired everyone who said "I had a need, so I built this thing, here is what I built". That's way more useful to me than asking you to whiteboard something.

Regardless of what I said above, I usually do ask some trivia type questions and have people whiteboard. I do this to gauge their real world experience, their familiarity with their toolset, and see how they react when they don't know something or have a clean slate and no IDE to help them. Since my line of work is all about serving up lots of web pages using lots of services I love asking about caching, concurrency, and aggregation.

edit: I personally don't get hungup on which package manager you use or which MV* framework or whatever you picked. That's cool if you like Angular, Browserify, node, and LESS. I expect that you can verbalize your reasons for picking various aspects of a stack and also that you're happy to use something else if your personal preference isn't the right thing for the project, though.

obstipator posted:

I completely agree that motivation to learn is the key determining factor in whether or not I want you on my team. The last two guys that made it onto my team were junior guys that showed that they're interested in learning. Linking your github that shows you are interested in frameworks or solving problems or just plain contributing to things will prove that you would enjoy the job and are looking to improve, so in my eyes it is safe to assume that you won't end up like some slacker that does the bare minimum.

Thank you very much. This is really helpful. I'm in the middle of building a personal portfolio/resume site. When I have a draft ready I'll be sure to share it for feedback.

Horn
Jun 18, 2004

Penetration is the key to success
College Slice

Maluco Marinero posted:

In


Inlining components to render really depends on your use cases, what goes in what. What you could do is one of two things:

Have a data structure which separates blocks of html and components, iterate over it, and keep the components as part of the render structure ie
code:
[{
  'type': 'html',
  'content': '<span>React is good</span>'
}, {
  'type': 'componentName',
  'props': {}
}]
This would require a wrapping element around each section of raw html, which may not be ideal.

Alternatively, render the lot as dangerous HTML, with intended components rendered like:
code:
<div data-component="componentName" data-props='{"inline": "json"}' class="reactComponent"></div>
Then after the component updates with the HTML, you iterate over it and mount components directly on instances of .reactComponent - however you'll lose those bindings every time the HTML needs to change so that may not fit the needs.

First approach is probably better if you can make it work.

Thanks, I went with the first method. Wasn't too bad, I have a function that takes the HTML string and an array of tags and it returns a list of matches with their start + end indexes. From there I can create a collection of span's or custom tags and dump it to the page.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I just spent a few hours doing something that made me super happy I've got great unit (and other types) test coverage.

I've got a project that has been sitting around without me working on it for about 6 months. It's got 18 libraries in "dependencies" and 22 in "devDependencies" (in package.json), and 90% of them had minor to major updates since I last touched the project. Of course, this being modern web development, only a couple of the libraries had useful changelogs listing breaking changes and the like.

Now, I could have just let well enough be and kept working with everything pinned at the versions I've got, but since I've got over 400 tests, I figured what the hell and started updating the version numbers in package.json one by one and fixing any errors that popped up when the unit tests ran.

It was actually a nice and straightforward process.

Remember your tests!

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo
So I've read that it's bad to use $scope now. Is the same true for $rootScope? I have a service that polls data and I want it to show up in the controller, so I'm using $rootScope.$broadcast in the service and listening in the controller. Looking through stack overflow and blog posts, it looks like I could also either (1) just use the observer pattern or (2) assign ctrl.theData = theService.theData when the controller is initialized. #1 feels like it'd be reinventing the wheel a bit, and #2 seems like it would have a performance penalty.

What's the best way to do this? Actually more important than this specific question is I'm looking for a good resource on what you should do in angular nowadays, rather than just what you can do. I use john papa's style guide already but I guess I'm looking for something broader.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Thermopyle posted:

I just spent a few hours doing something that made me super happy I've got great unit (and other types) test coverage.

I've got a project that has been sitting around without me working on it for about 6 months. It's got 18 libraries in "dependencies" and 22 in "devDependencies" (in package.json), and 90% of them had minor to major updates since I last touched the project. Of course, this being modern web development, only a couple of the libraries had useful changelogs listing breaking changes and the like.

Now, I could have just let well enough be and kept working with everything pinned at the versions I've got, but since I've got over 400 tests, I figured what the hell and started updating the version numbers in package.json one by one and fixing any errors that popped up when the unit tests ran.

It was actually a nice and straightforward process.

Remember your tests!

What are you using for JS / React testing these days? I unit test my objective-C religiously, my python... not as much, but my JS... :smith:

HaB
Jan 5, 2001

What are the odds?

Flat Daddy posted:

So I've read that it's bad to use $scope now. Is the same true for $rootScope? I have a service that polls data and I want it to show up in the controller, so I'm using $rootScope.$broadcast in the service and listening in the controller. Looking through stack overflow and blog posts, it looks like I could also either (1) just use the observer pattern or (2) assign ctrl.theData = theService.theData when the controller is initialized. #1 feels like it'd be reinventing the wheel a bit, and #2 seems like it would have a performance penalty.

What's the best way to do this? Actually more important than this specific question is I'm looking for a good resource on what you should do in angular nowadays, rather than just what you can do. I use john papa's style guide already but I guess I'm looking for something broader.

The last thing I read on this (which admittedly was a few months back) was that $rootScope is fine if you keep it to a minimum. By 'a minimum' I mean you don't have 100 objects hanging off $rootScope for other stuff to look at. Your alternative is to create a service of some sort, or just inject the service you need. I'm surprised that passing data between controllers isn't a better solved problem these days. Seems like a fairly common problem.

It's probably against "best practice" but I have been creating "state objects" which is basically a service that holds onto a set of values which get used by multiple controllers. I realize one of the style guides explicitly says "don't create a service just to hold a bunch of globals" but I have yet to hear a good alternative that doesn't involve a stupid amount of hoop jumping.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
Does there exist any tool that parses a page's source to produce a report on the dependencies being used?

Eg, It'd be rad to have a brower plugin that can report to component X is rendered with react, that the page is styled with bootstrap, etc etc.

The March Hare
Oct 15, 2006

Je rêve d'un
Wayne's World 3
Buglord

Newf posted:

Does there exist any tool that parses a page's source to produce a report on the dependencies being used?

Eg, It'd be rad to have a brower plugin that can report to component X is rendered with react, that the page is styled with bootstrap, etc etc.

Wappalyzer for (at least) Chrome does this, though I'm not sure how good/accurate it is.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Lumpy posted:

What are you using for JS / React testing these days? I unit test my objective-C religiously, my python... not as much, but my JS... :smith:

To actually run my tests I use mochify.

React testing is something similar to this.

chai, sinon, sinon-chai, and mockdate are all used in my tests.

The most important tool that I use in writing my tests is proxyquire which eases mocking dependencies when you're using CommonJS-style require.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

The March Hare posted:

Wappalyzer for (at least) Chrome does this, though I'm not sure how good/accurate it is.

Cool, thanks. I was having trouble searching for this without getting 'web scraper' results.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Flat Daddy posted:

So I've read that it's bad to use $scope now. Is the same true for $rootScope? I have a service that polls data and I want it to show up in the controller, so I'm using $rootScope.$broadcast in the service and listening in the controller. Looking through stack overflow and blog posts, it looks like I could also either (1) just use the observer pattern or (2) assign ctrl.theData = theService.theData when the controller is initialized. #1 feels like it'd be reinventing the wheel a bit, and #2 seems like it would have a performance penalty.

What's the best way to do this? Actually more important than this specific question is I'm looking for a good resource on what you should do in angular nowadays, rather than just what you can do. I use john papa's style guide already but I guess I'm looking for something broader.

It's bad to use $scope to hold your variables, now that bindToController can abstract the $scope away entirely. If you want to use the built in functions like $on, $emit, $broadcast, $watch, that's what it's there for. However, $broadcasting everything from $rootScope is poor practice. I'm very pleased with using AmplifyJS to allow communication across controllers. I then use Typescript to wrap around it and strongly type the callback & publish signatures. I have a service which contains a series of the below objects, which lets Intellisense tell you every kind of message you have, and exactly what it needs to work properly.

code:
public get DoThing() {
	var key = "DoThing";

	return {
		subscribe: (callback: (stuff: string[] ) => any) => {
			amplify.subscribe(key, callback);
		},
		unsubscribe: (callback: (stuff: string[]) => any) => {
			amplify.unsubscribe(key, callback);
		},
		publish: (stuff: string[]) => {
			amplify.publish(key, stuff);
		},
		key: () => {
			return key;
		}
	};
}
PS: AmplifyJS is a synchronous message bus, you can use Postal if you want an async one.

HaB posted:

It's probably against "best practice" but I have been creating "state objects" which is basically a service that holds onto a set of values which get used by multiple controllers. I realize one of the style guides explicitly says "don't create a service just to hold a bunch of globals" but I have yet to hear a good alternative that doesn't involve a stupid amount of hoop jumping.

I think this is warning against creating services which are just blobs of variables which anyone can modify. If you treat it like a data layer, with get/set methods, I don't see a problem with it.

Skandranon fucked around with this message at 21:55 on Jun 12, 2015

spacebard
Jan 1, 2007

Football~

Skandranon posted:

I think this is warning against creating services which are just blobs of variables which anyone can modify. If you treat it like a data layer, with get/set methods, I don't see a problem with it.

That's reassuring. I have a Settings service in my chrome (and theoretically any browser) extension angular app that I use to get some config. for connecting to an arbitrary domain for this API. So I have a getter that wraps the browsers storage layer for extensions. Most of my controllers have it injected.
I was also thinking about using the same sort of service to store some arbitrary enumerated values from the API that I connect into. Basically I'm writing an extension to get around this project management tool's lovely front end :clint:

kloa
Feb 14, 2007


you must be this hip to work here

HaB
Jan 5, 2001

What are the odds?

spacebard posted:

That's reassuring. I have a Settings service in my chrome (and theoretically any browser) extension angular app that I use to get some config. for connecting to an arbitrary domain for this API. So I have a getter that wraps the browsers storage layer for extensions. Most of my controllers have it injected.
I was also thinking about using the same sort of service to store some arbitrary enumerated values from the API that I connect into. Basically I'm writing an extension to get around this project management tool's lovely front end :clint:

Reassuring indeed, and we are service naming bros, you and I. I too have Settings service. :cool::hf::cool:

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I've seen a library that did object validation in a manner very similar to React's propTypes. In fact, it was explicitly all about emulating propTypes for arbitrary objects, but now I can't remember what this library was called and I can't seem to find it via Google.

Anyone have any idea what I'm talking about?

Kekekela
Oct 28, 2004
In general, what is the process you guys go through to start a new project? (e.g. do you have a "boilerplate" template that you start from? use a scaffolding tool like yeoman? just start from an empty folder every time? other?)

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Kekekela posted:

In general, what is the process you guys go through to start a new project? (e.g. do you have a "boilerplate" template that you start from? use a scaffolding tool like yeoman? just start from an empty folder every time? other?)

A shell script that makes directories, copies a couple files over, and links global NPM packages for me. I have been told this what yeoman is.

gbaby
Feb 6, 2015
Make your own boilerplate for projects! Search github for ones with good file structure and libraries that you'll use often.

Edit: woops wrong thread!

gbaby fucked around with this message at 05:01 on Jun 21, 2015

Kekekela
Oct 28, 2004
In this video Jafar Husain breaks down promises, observables, generators, and iterators and how they all relate in a way that even I was able to understand, which is frankly amazing. Also apparently ES6/ES7 are now ES2015/ES2016.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Kekekela posted:

In this video Jafar Husain breaks down promises, observables, generators, and iterators and how they all relate in a way that even I was able to understand, which is frankly amazing. Also apparently ES6/ES7 are now ES2015/ES2016.

Good video.

Reminds me a lot of python 3.5.


In other news: I'm rethinking my testing strategy when it comes to React components. I'm thinking maybe its too easy to get down in the weeds so to speak and worry about testing too much of a components internals. I'm thinking now instead that there's not much you need to unit test on a well-designed React component that has very little state and with its behavior determined by props and your Flux stores. Maybe just testing that it acts on the DOM like you expect it to...like making sure that when a List component is mounted it creates some li's or whatnot.

There's lots of blog posts out there about unit testing these bitches, but really I think there's a lot of crap out there...or if not crap, just a lot of competing ideas.

Anyone have any thoughts about testing React components?

rsjr
Nov 2, 2002

yay for protoss being so simple that retards can win with it

Thermopyle posted:

Maybe just testing that it acts on the DOM like you expect it to...like making sure that when a List component is mounted it creates some li's or whatnot.

If you consider a React component as a function that takes params (via props) and returns HTML as output, there's nothing wrong with your method of unit testing.

luchadornado
Oct 7, 2004

A boombox is not a toy!

Thermopyle posted:

Anyone have any thoughts about testing React components?

Don't write unit tests unless they save you headaches in the long run. I read your original post about using like 4 frameworks or whatever and my first thought was "that's more complicated than my entire React app, and that's 2000 lines of Javascript."

I personally think 5-10 years ago no one did very good testing and then the pendulum swung in the opposite direction and now people spend more time writing and maintaining tests than they do making new things. With build/deploy CI being a common thing now, I can deploy a massive web site to two dozen instances across two data centers in two minutes if I screw up. Not that I want to be doing that frequently anyways, but the point is it's not hard for some types of development to correct mistakes quickly.

Everyone should be analyzing how many false errors your tests drudge up, how many real errors they prevent, and how many errors they miss. Sometimes more tests are just busy work, and you should automatically be wary of someone trying to push code coverage or line coverage checks in your build process.

luchadornado fucked around with this message at 02:26 on Jun 24, 2015

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Helicity posted:

Don't write unit tests unless they save you headaches in the long run.

Well...yeah.

Helicity posted:

I read your original post about using like 4 frameworks or whatever and my first thought was "that's more complicated than my entire React app, and that's 2000 lines of Javascript."

1. The post you're talking about was following my post wherein I described exactly the huge headache they saved me.

2. It's not complicated at all. I mean...it's not even close to being complicated. In fact, it's the exact opposite of complicated. The setup reduces complexity. It only sounds complicated because JS has basically no standard library.

3. 2000 lines is a pretty small application.


Helicity posted:

I personally think 5-10 years ago no one did very good testing and then the pendulum swung in the opposite direction and now people spend more time writing and maintaining tests than they do making new things. With build/deploy CI being a common thing now, I can deploy a massive web site to two dozen instances across two data centers in two minutes if I screw up. Not that I want to be doing that frequently anyways, but the point is it's not hard for some types of development to correct mistakes quickly.

Everyone should be analyzing how many false errors your tests drudge up, how many real errors they prevent, and how many errors they miss. Sometimes more tests are just busy work, and you should automatically be wary of someone trying to push code coverage or line coverage checks in your build process.

Catching/correcting mistakes is a very small part of the point of unit tests.

gbaby
Feb 6, 2015

Kekekela posted:

In this video Jafar Husain breaks down promises, observables, generators, and iterators and how they all relate in a way that even I was able to understand, which is frankly amazing. Also apparently ES6/ES7 are now ES2015/ES2016.

I've recently started developing apps with Meteor and while watching this vid I can relate a lot of the things he's saying to things Meteor is trying to do. Things like waiting, observe, producer/consumers. I don't have the long-term experience as the developers who are probably at that conference but after using Meteor I just think - drat that stuffs so easy with Meteor(w/ CoffeeScript/Jade/MongoDB, etc.). And I can do some of that stuff with JS server side too.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Why use node instead of phantomjs for tests? Alternatively, why use phantomjs instead of node for tests?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
PhantomJS gives you an actual browser engine so that you can test code that does stuff like DOM manipulation without mocking it or using a fake that may not behave like the real thing, but it adds a bunch of overhead and ideally most of your tests shouldn't need that. Broadly speaking you should run unit tests on node, and integration tests on PhantomJS.

luchadornado
Oct 7, 2004

A boombox is not a toy!


I look at having a lot of dependencies (especially ones written by individuals) and lots of modularity as being a threat to maintainability, and requiring several libraries to do simple unit tests is a huge turn off for me. Sure, I can figure it out, but I don't *want to* in this case. I'll keep my heavy business logic to a strongly typed language with well-vetted and commonly used testing suites, and use React more like a view engine. So my thoughts on testing React, to answer your question, are that React components should be light-weight and shouldn't require much testing.

I think that 2000 lines is a decent sized web app if you're consuming robust APIs, using concise syntax, and not over-abstracting everything like you're being paid by the line. Embracing the modularity of an ecosystem like NPM while saying 2000 lines of Javascript is "pretty small" is amusing to me. We're probably just operating in different environments with different circumstances and constraints, so my answer and my general outlook on architecture might not jive with yours I guess.

quote:

Catching/correcting mistakes is a very small part of the point of unit tests.

Unit testing is all about assuring the quality and functionality of the code, which an error/mistake would compromise. Is there a more important use of unit testing that I'm neglecting?

edit: this is honestly not me doing a typical programmer thing and arguing for the sake of arguing - I've never been happy with my viewpoint on tests and am actually interested in how others deal with them.

luchadornado fucked around with this message at 17:47 on Jun 24, 2015

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Helicity posted:

I look at having a lot of dependencies (especially ones written by individuals) and lots of modularity as being a threat to maintainability, and requiring several libraries to do simple unit tests is a huge turn off for me. Sure, I can figure it out, but I don't *want to* in this case. I'll keep my heavy business logic to a strongly typed language with well-vetted and commonly used testing suites, and use React more like a view engine. So my thoughts on testing React, to answer your question, are that React components should be light-weight and shouldn't require much testing.

I think that 2000 lines is a decent sized web app if you're consuming robust APIs, using concise syntax, and not over-abstracting everything like you're being paid by the line. Embracing the modularity of an ecosystem like NPM while saying 2000 lines of Javascript is "pretty small" is amusing to me. We're probably just operating in different environments with different circumstances and constraints, so my answer and my general outlook on architecture might not jive with yours I guess.


Unit testing is all about assuring the quality and functionality of the code, which an error/mistake would compromise. Is there a more important use of unit testing that I'm neglecting?

edit: this is honestly not me doing a typical programmer thing and arguing for the sake of arguing - I've never been happy with my viewpoint on tests and am actually interested in how others deal with them.

So, the problems here are several-fold. (And I don't mean you have problems...there are problems between the two of us on base case assumptions, there are problems with JS and its ecosystem, etc)

1. Applications today are more and more almost all on the front end.

Sure, if you're comparing a CRUD app where all your business logic is on the server, to other CRUD apps where all your business logic is on the server, a couple thousand lines of JS is a big app. I mean, you're just going to have a few hundred to a few thousand lines of JS on the front end managing your views, and your unit tests are going to be very simple. Unfortunately, I don't think you can assume this as the default case, for new projects going forward whenever we're talking about JS in general. I mean, it might be what you prefer, and that is a fine and consistent position to take. Writing in a real language like Java or C# is a tempting idea. But it certainly isn't what you can assume is the case about new JS applications nowadays.

2. The libraries I mentioned in that earlier post are "well-vetted and commonly used testing suites"...

... or if they're not they're just simple little things that would cause little-to-none turmoil if they disappeared or blew up.

3. When you say "errors and mistakes" you're probably thinking of something different from me.

I guess everything that is not what you want is an "error". But, for example, unit testing aids you in effectively using modularity when you want to swap out one library for another. Or maybe you you need to do a large refactoring...unit tests are a big aid in that too. Neither one of those are things I'd label as an error or mistake, but I guess you could in a looser sense. I'm not sure how the ability to deploy "a massive web site to two dozen instances across two data centers in two minutes if I screw up" is of much help with either of those scenarios.

Of course, if you just have 2000 lines of js and don't use libraries or modularity than you wouldn't encounter such a thing.

4. JS does suffer from an overabundance of libraries and just too much stuff.

I mean, there's 6 build systems, a dozen test runners, assertion libraries, blah blah blah all competing for your attention. I certainly don't think they've all got a future.

On the other hand, I'm certainly not going to reinvent the wheel when I can use libraries and frameworks that solve sufficiently complex problems and are hammered on a lot more than I could possibly do in-house.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Plorkyeran posted:

PhantomJS gives you an actual browser engine so that you can test code that does stuff like DOM manipulation without mocking it or using a fake that may not behave like the real thing, but it adds a bunch of overhead and ideally most of your tests shouldn't need that. Broadly speaking you should run unit tests on node, and integration tests on PhantomJS.

Yeah, I that's what I thought. I was just wondering if I was missing something.

I'm just going to continue using phantomJS because the overhead is basically zero. I mean, yeah its a big download and runs a whole headless browser...but I don't care. I care about time spent running tests. The difference between running my tests in node vs running in them in phantom will add up to like one second per week and because of ~reasons~ it's just easier for me to stick with phantom.


...


In other testing news, I'm really liking React's new(ish) shallow rendering.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
When I last used it, PhantomJS had a very noticeable startup time (like 10+ seconds). That was about two years ago though, so if that's been fixed I'd just use it for everything.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

It might still on a reasonable system, I dunno. I've got a really high end dev machine here so I haven't noticed.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
My feeling on testing React components is this, state changes should go through unit tests, but the layout of the component itself, I feel like perceptual diffing (screenshot tests) is the only way to get a reasonable level of coverage matching time invested.

This dovetails in really nicely with having a component library automatically generated from all your *.react.js files. I've got a project structure in mind for this approach real soon, that's going to aim to have absolutely everything except the wrapping boilerplate rendered by React.

Seems like shallow rendering will be just the ticket to handle the remainder of testing potentially.

Heisenberg1276
Apr 13, 2007
I'm not sure if this is the right thread for it so please redirect me if not.

I'm interested in learning how to better manage my CSS. I'm working on a project that's growing big and my structure is good except for the CSS which is becoming a bit of a mess. I'd like to sort it out before it becomes too difficult.

I know of the existence of OOCSS, BEM, and SMACSS and I'm sure there are plenty of other styles, but I don't really know much about them.

Which would people recommend me to learn? and what are the best resources for this? Mostly I've just seen a lot of separate wiki posts on occasional blogs about them - I'd prefer something a bit more substantial if it exists.

HaB
Jan 5, 2001

What are the odds?

Heisenberg1276 posted:

I'm not sure if this is the right thread for it so please redirect me if not.

I'm interested in learning how to better manage my CSS. I'm working on a project that's growing big and my structure is good except for the CSS which is becoming a bit of a mess. I'd like to sort it out before it becomes too difficult.

I know of the existence of OOCSS, BEM, and SMACSS and I'm sure there are plenty of other styles, but I don't really know much about them.

Which would people recommend me to learn? and what are the best resources for this? Mostly I've just seen a lot of separate wiki posts on occasional blogs about them - I'd prefer something a bit more substantial if it exists.

Use sass or less and never worry about it again, basically. I can't think of the last time I wrote actual vanilla css.

I'm Crap
Aug 15, 2001
Stylus also seems pretty pro from my short time using it, particularly if you like Jade.

Adbot
ADBOT LOVES YOU

luchadornado
Oct 7, 2004

A boombox is not a toy!

sass is pretty awesome. Some people are more familiar with less because of Bootstrap, but there are a few things that bug me about it. Between sass/bourbon and inline styles with React, I've solved a lot of headaches. Pick bourbon if you just want something lightweight and great grid support, pick compass if you want a comparatively larger Ruby-based framework that gives you a ton of power and customization.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply