> Don’t only write code for the happy scenario.
I always have had problems communicating this to my colleagues, managers and stakeholders.
I remember having this discussion with a stakeholder once when I was a consultant:
PM: "How long would it take to have a page with a table with this payment data and this design?"
Me: "The page you're looking for doesn't exist exactly, it's more complex than that."
PM: "What do you mean?"
Me: "There is a page that maybe, eventually will have this table".
PM: "But I want this"
Me: "Okay, but when the user lands on the page, there is still no data, it is being fetched from our backend service. We need to give the user some feedback and tell him his data is loading".
PM: "Okay, add a spinner or something".
Me: "But that's not enough. What if the server hasn't answered after 5 or 10 or 60 seconds? How would the user react? Should we retry the call? Should we give him some other feedback? What if the response actually contains no data, because for the given filters there are no payments? What if the data is malformed? This may crash the application. What if the user is not authenticated or not authorized for the data? Isn't this an admin-only route? Estimating the table itself is one job, but defining all the requirements and handling all the non-happy-cases or edge cases is a totally different game".
Problem is, explaining this to stakeholders, and sometimes even colleagues that "don't care and just want the task to be over" isn't always simple and the solution is generally "we will fix backend so it sends you always correct data in acceptable times".
And then, you spend much more time fixing these edge cases after you go in prod and it becomes a giant spaghetti ball.
A seasoned and experienced backender very well understands that a (well formed) 200 is just one of possible answers he's gonna give back based on the request and database data, and yet we keep treating the less probable outcome as the only scenario.