FlightMechanics.jl
FlightMechanics.jl copied to clipboard
Antipattern: Not implemented exceptions
Current situation After reading https://white.ucc.asn.au/2020/04/19/Julia-Antipatterns.html, I realised that, currently, this situation occurs for some types in the code: https://github.com/AlexS12/FlightMechanics.jl/blob/master/src/models/aerodynamics.jl#L24 https://github.com/AlexS12/FlightMechanics.jl/blob/master/src/models/dynamic_systems.jl#L10 https://github.com/AlexS12/FlightMechanics.jl/blob/master/src/models/propulsion.jl#L5
More may be found...
Objective Adopt language paradigms and really obtain helpful error messages
Solution proposal As suggested in: https://white.ucc.asn.au/2020/04/19/Julia-Antipatterns.html
MethodError indicates this quite well and as shown gives a more informative error message than you will write. An often overlooked feature is that you can declare a function without providing any methods.
When one is in this situation, defining a interface that another package would implement, one can provide a test-suite for testing it was implemented correctly. This is a function they can call in their tests to at least check they have the basics right. This can take the place of a formal interface (which Julia doesn’t have), in ensuring that a contract is being met.
Yes, you should definitely avoid this anti-pattern!! Just create functions without any methods!