This is how good engineers do estimates in software as written down by Sean Goedecke:
I gather as much political context as possible before I even look at the code. I go to the code with an estimate already in hand. I spend more time worrying about unknowns than knowns. I go back to my manager with a risk assessment, not with a concrete estimate. My job is to figure out the set of software approaches that match that estimate.
https://www.seangoedecke.com/how-i-estimate-work/
Unfortunately this is so obvious to me by now that I’d have a hard time writing this down.
