FlightMechanics.jl icon indicating copy to clipboard operation
FlightMechanics.jl copied to clipboard

Antipattern: Not implemented exceptions

Open AlexS12 opened this issue 5 years ago • 1 comments

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.

AlexS12 avatar May 04 '20 09:05 AlexS12

Yes, you should definitely avoid this anti-pattern!! Just create functions without any methods!

zsunberg avatar May 09 '20 22:05 zsunberg