4 ms·
Thanks for the links! I am watching [2] at the moment and I would just like to give my perspective on how I would approach this problem. To rehash, the questi
by neemetamm 9y ago
Thanks for the links!
I am watching [2] at the moment and I would just like to give my perspective on how I would approach this problem.
To rehash, the question in the video is that just by looking at the following code:
for entry in entries:
entry.data.validate()
What does it do? Without context it is hard to know and one would have to search for all functions named validate(), which is hard. Or to rewrite it in statically typed language, which is impossible.
The way I've been solving these situations is that I look into the unit test of the relevant function to understand what is going on. Unit tests also act as concise examples on how to use the code with example data. Also, if necessary, I can just debug the relevant unit test and step through the function and see in real-time what is going on.
But I am not trying to claim that type annotations are a bad idea, I just haven't used them myself yet.