- Joined
- Jan 11, 2014
- Messages
- 53
- Reaction score
- 64
- First Language
- English
- Primarily Uses
Hey there!If I alias a method in a 'child class' where the method is only defined in the 'parent class', would this have any negative consequences ?
Would I be better to simply call 'super' rather than call the aliased method?
Actually... Now that I think about it, having an extra aliased method floating around cant be a good thing... I will just stick with super on this occasion.
While I am asking though, are there any other 'more deadly' negative impacts of aliasing a method as previously described?
It's not that big of a deal. Either would be fine, although, it would be a "good programming practice" to use super instead of alias as much you can. Don't let those good programing practices take all over though, heh. But, yes, it would be more standard and a more predictable solution.
However, if you may need to alias it several times in your code, you can either make sure the one that uses super is executed first, always, or just use alias for all if you think your code order may change in the future (either within the file or moving the file order).
Lastly, but not least, if a script uses alias on that method and is inserted before your code, you will overwrite it with your non aliased definition of that method. Super, in that case, will call the parent method, not the aliased method by the script, and it will cause unwanted behavior or even crashes.
So... It comes down to the situation
Hope that clears the panorama

