Why or when is "explicit" preferred when implicit solutions often are more readable and less code? It says "explicit is better than implicit" when for example an implicit loop is better than an explicit loop isn't it?
for every in all: every.updated = True
The above looks implicit to me and better than an explicit counter since a counter is another thing that can go wrong and why not leave to the compiler or other environment instead of requirement an explicit counter variable:
for(int i=0, i<a.length, i++) ...
And there are languages where all looping is "implicit" - what does it mean and when is it preferred? And not explicitly setting a value to
None or likewise seems better to me and I want to rewrite code when I "solve" a requirement by explicitly setting
return null or
String name = null since I think being explicit about what should be null and None should have a more clear solution such as only use a variable if it's needed and if I write return null somewhere I'm probably doing it wrong. When I was writing Java I found myself writing
return null and declaring values as null at some places and I didn't like it and could rewrite it even though the case where I put
return null was reached only in case of error.
I asked the guru at work whether we ever should declare a variable to null, isn't defaults much better?
I'd be glad to know your thoughts about this. An example where it is better to be explicit I can think of is declaring a list and explicitly declaring what type is in the list is better than just a list of objects e.g. it's preferred to declare
ArrayList<ArrayList> instead of just an ArrayList if we know that it's a list of lists.