r/webdev • • Mar 01 '17

Programmers are confessing their coding sins to protest a broken job interview process

https://theoutline.com/post/1166/programmers-are-confessing-their-coding-sins-to-protest-a-broken-job-interview-process
1.4k Upvotes

341 comments sorted by

View all comments

44

u/Lugicarus Mar 01 '17 edited Mar 01 '17

Hey I'm Lugicarus and I'm a front end developer or web designer - I dont know all titles are made up and I can't remember if display: hidden or display: none does this shit I want it to. Every single time.

Pro tip! It's always display: none.

Edit: y'all are some salty devs. It's satire after all! Sheesh

56

u/iamallamaa Mar 01 '17

display: none vs visibility: hidden. Display will remove the element from the flow of the document, making the element disappear visually as if it wasn't there. Visibility is like setting the opacity down to 0%. It still occupies a space visually and stuff flows around it.

46

u/amoliski Mar 01 '17 edited Mar 02 '17

Says a person who almost certainly just googled that to make sure they were correct before commenting

32

u/madcapmonster Mar 01 '17

I actually know that one from years of banging my head against a wall. It finally stuck. (the concept, not my head)

2

u/midri Mar 02 '17

It's actually really easy to remember. Dispaly: none you use. Visibility: is never used.

1

u/daaaaaaBULLS Mar 02 '17

I was asked the difference in an interview this week and said the correct thing while in my head hoping what I was saying was the correct thing.

4

u/RetroEvolute Mar 02 '17

Although, with visibility: hidden, element events are also disabled, whereas opacity still retains its events even though you cannot see it. So:

  • If you're hiding something and don't want it to take up space or be clickable, use display: none.

  • If you're hiding something and want it to take up space, still be clickable, and want to use a transition to smoothly show or hide it, use opacity.

  • If you're hiding something, still want it to take up space, but don't want it clickable, then use visibility: hidden.

You also used to be able to combine opacity and visibility with some clever transitions and delays to make something fade out and then be non-interactive (which is awesome), but browsers seem to have issue with this in a lot of cases.

Oh, and there's also visibility: collapse which is for tables, but who cares about that one?

1

u/[deleted] Mar 02 '17

visibility:visible is annoying to spell.

3

u/rampage_wildcard Mar 01 '17

I often ask about that in interviews phrased as 'what is the difference betweeen...'

Getting it right is great, but I'll usually give partial credit for 'One respects flow and the other removes it, I just don't remember off the top of my head'.

Everyone jokes about how much Googling people do on the job, but eventually some of these concepts need to start sticking, especially once you're interviewing for a more senior role. It's not an obscure question.

2

u/SomewhatGlayvin Mar 01 '17

Ok, I'm going to bite.

It's not always display none. Sometimes you might want not want the space to be collapsed, but at the same time you don't want the hidden element to capture the users clicks (like simply using opacity:0 would allow). This is common when you need to worry about things like transitions on interactive components.

But that is besides the point.

If I were to hire a seasoned front end developer who didn't know this, I would be asking "why". Do they work only with css frameworks like Bootstrap? Have they never had their code reviewed and corrected? Are they lying about their experience? Does this betray a greater ignorance--E.g., what experience could they have with various rendering strategies if they are not familiar with how to hide elements in css?

You could do any job by googling it, but at certain level you are expected to know the pros and cons of multiple approaches to common problems. That's why we are paid as well as we are.

-1

u/RetroEvolute Mar 02 '17

Yeah, this is actually one of the many things I would expect a front-end developer to understand in depth and have committed to memory. I wouldn't hire someone who didn't know something this basic.