But cure gives you the option to safeguard and choose alternate endings. Yes prevention is more desirable than cure. Pure functionsĪvoid side-effects at all cost. Learning about common data types and getting familiar with coercion can help. Use your discretion to determine when specific type checks are required, but if you find yourself type-checking everything it’s clearly because you don’t fully understand what’s going on in the bigger picture of your application. There is not need to type-check every return statement within that abstraction. CureĪt the return statement of the final stage of an abstraction layer or concern that is specifically providing data to another layer, server or the user, etc. You are not obliged to type-check every function within that abstraction but at least the entry point. Ne ar the beginning of what you regard to be an abstraction layer or concern that is receiving data. Prevention + Cure: When “Must” I Enforce Checks? Prevention = is NOT faster, = is explicit, = is implicitįor expressions that are indefinitely booleans and within the same scope as the condition yes below is still explicit type-checking.Ĭonclusion: BE EXPLICIT with all your conditional logic. Yes it is safe and recommended to use null, undefined and NAN.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |