Rename Your Functions
Yeah, so this looks much better to me. One more thing for refactoring that I can see here before we move into maybe also catching this error then and where you would do that, is that
load_model() doesn’t really seem to be the best name anymore for what this function does at that point. Again, this might make sense in the original codes, but I would also argue that since we came to a point by cutting down this code where there is a different functionality that we’re actually talking about, this might actually deserve its own function. So also in the original code, maybe the person would want to refactor their
load_model() function and take out the piece of functionality that we are talking about here, and maybe name it
validate(). Okay, because what’s happening there is that we don’t load a model, but we are validating a source and a target input, and therefore we should say how it is: the function in line 8 does validation, and we call it
validate(). Yeah, exactly.
Become a Member to join the conversation.