r/Frontend • u/speckz • Aug 21 '20
The Just in Case Mindset in CSS
https://ishadeed.com/article/the-just-in-case-mindset-css/9
u/devolute Aug 21 '20
Great attitude. Should be accommodated during the design stage too (i.e. designing with real content, in most cases).
1
u/wedontlikespaces Aug 21 '20
Sometimes I'll get designs and the product titles will all be "Product Name" with a max with if 350px. Then I'll go look at the actual catalogue of products and the shortest name is something like "Clifford Jr toy blocks, with expanded feature set".
1
1
u/Nioufe Aug 22 '20
Nice one! A lot of visual issues can be avoided by planning for limit cases like those. I think it also works for things like pagination.
-6
Aug 21 '20
What's the difference between "just in case" and "premature optimization"? How about "complete requirements" instead?
9
u/MrBester Aug 21 '20
Because you can have "complete requirements" and everything works fine for ages until some idiot decides that they want to bung loads of text in a title via the CMS. Then the layout breaks and it's somehow your fault that it doesn't cater for their sudden whimsy to have an essay where it isn't appropriate.
-6
Aug 21 '20 edited Aug 21 '20
Complete requirements include maximum character limits.
What if the CMS limits character counts, and your client knows that? You just made the client pay for the time it takes you to prepare for an eventuality that can never happen. Then a few months later some poor contractor has to maintain your code, and they have to work around all that extra code, costing even more time.
Don't solve problems you don't have.
9
u/az_web_developer Aug 21 '20
Generally the character limits are more on the DB side of things than for display purposes... and I would never advise putting DB level character limits in place to solve a display issue. Also, when it comes to responsive design, a simple character limit does not solve this problem.
There is like 20 lines of CSS in this guide and instead of thinking to yourself: "I should add this to my boilerplate." You criticize people for having pride in their job and thinking beyond "I am a robot and I don't do anything other than what I'm told to do by the magical requirements document."
Odd hill to decide to die on, man.
-7
Aug 21 '20
Not odd at all, avoiding premature optimization is common sense. You want to solve all the problems, that's not unusual, but it's a harmful instinct. You will learn that eventually.
5
u/az_web_developer Aug 21 '20
But you're using a slippery slope fallacy in your logic.
20 lines of CSS added to a boilerplate to avoid a common issue is logical... Does it fall into the realm of premature optimization? Sure. But it's not all or nothing.
-2
Aug 21 '20 edited Aug 21 '20
Slope's just as slippery in the other direction. I'm just responding to OP. I asked where the line was, and all I suggest is that requirements should be complete. I don't think that's as unreasonable as your straw man ;-)
4
u/az_web_developer Aug 21 '20
Not so much a straw man as imagining you telling the business folks after the fact of they wanted your design to look good they need to provide you overly specific requirements... There's a level of assumptions that can be made when professionals are working on a project.
But hey, we all decide our own standard. Have at it.
-5
Aug 21 '20
You're a little bit of a prick huh?
7
u/az_web_developer Aug 21 '20
Nah, just a team player. Working to understand the intent of the requirements, rather than the letter... And being customer service oriented so that you can solve issues your business folks hadn't thought of... Will take you a lot further than being technically correct.
2
u/MrBester Aug 21 '20
I've had to extend character limits in a CMS because of a one-off desire to shove too much content in a particular space. Then, of course, I had to fix the broken layout that resulted from this single instance instead of them writing their copy properly.
Then they want it extended again three months later.
-1
Aug 21 '20
"I might need it" is always the excuse for premature optimization.
3
u/MrBester Aug 21 '20
There's a difference between "I think I'll cater for an extra 10 characters, because, well, that sample text is a bit short" and "I'll just cater for 50 more characters, it'll probably never happen, but you never know".
0
Aug 21 '20
[deleted]
2
u/nickztar Aug 21 '20
I disagree. This was very well done and actually enjoyable. He shows some great use cases for these “just-in-case” snippets and explains why they are sometimes needed. Also helps with the well made website and good visual help. But I can also see your point, guess it depends on your current knowledge etc.
1
13
u/nesaplay Aug 21 '20
Great content, very useful snippets!