Public service announcement for Dart developers, especially those publishing packages on Pub.

Don't go crazy with noSuchMethod.

noSuchMethod is kind of like QR codes.

While funny, I think this goes a bit too far.

I do think there are cases where QR codes are useful, but they are limited. Kinda' like noSuchMethod.

Don't use noSuchMethod to be lazy

I know! I'll use noSuchMethod to emulate getters and setters on my class instead of writing them out by hand. I'll just store all of the values in a Map. My code will seem pretty and I won't have to worry about adding new properties as I think them up. Oh, and I won't have to worry about updating the constructor either!

Don't use noSuchMethod to be clever

I know! I'll use noSuchMethod to automagically support method_name usage for methodName using reflection since some people like to access members with underscores!

Don't use noSuchMethod to make Dart look like Ruby

I know! I can use noSuchMethod to make setting up this...uh...thing look like a DSL...uh...thing because a blog once said that DHH or RMS or BBQ or someone smart said that's cool.

Creating a mock for testing? Probably.
Creating a proxy for something dynamic? Maybe.

Next time you think about using noSuchMethod, right click on something real in the Dart Editor.

See all of that awesome!

Before the VI guys get all huffy puffy about IDE wimps, let me stress this is not just about the IDE.
  • This is about getting helpful warnings and errors in checked mode.
  • This is about generating valid, small, efficient Javascript.
  • This is about generating helpful documentation, even if you don't annotate anything.
  • This is about the sanity of future users of your libraries and maintainers of your code.
So please.

Don't use noSuchMethod unless you have to.

When in doubt, DON'T!