How to signal "not implemented yet"?

RubyException HandlingCoding StyleConventions

Ruby Problem Overview


In the initial drafting of a new gem I need to leave some method implementations empty ( to be implemented in the next )

Therefore, I would like to signal a "not implemented yet" exception

I'm wondering if there is a best practice or standard conventions specific to the Ruby language to code this kind of placeholder / exception.

i.e: something like:

Ruby Solutions


Solution 1 - Ruby

You should raise NotImplementedError

raise NotImplementedError

ruby-doc

Solution 2 - Ruby

You may use the todonotes-gem

There is a documentation with some examples.

It doesn't implement an exception, but a logging mechanism and a possibility for temporary solutions.

Solution 3 - Ruby

Looks like the original answer, which suggested raising NotImplementedError, was removed. I'll take a crack at it: write documentation.

Don't add code that's just a placeholder. You wouldn't want folks coding against that API so don't even give them a chance (yourself included). Instead, document the road map you are currently planning on in the class and/or README. Then be open to it changing. Odds are by the time you get around to solving whatever problem is in the road map you'll have new thoughts on what is the appropriate solution. I think this is the right course of action in any language/framework, but I think Ruby in particular encourages us to not write code that you don't plan on having executed.

Solution 4 - Ruby

Do not mention the unimplemented methods in the documents, or mention that they are not implemented yet. That is all.

Solution 5 - Ruby

Ruby will raise a NoMethodError for you anyway, when calling a non-existing method. That should be good enough for most cases.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFranco RondiniView Question on Stackoverflow
Solution 1 - Rubypasha.zhukovView Answer on Stackoverflow
Solution 2 - RubyknutView Answer on Stackoverflow
Solution 3 - RubyChrisView Answer on Stackoverflow
Solution 4 - RubysawaView Answer on Stackoverflow
Solution 5 - RubyJörg W MittagView Answer on Stackoverflow