How to signal "not implemented yet"?

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.

ie: something like:

  • UnsupportedOperationException in Java
  • NotImplementedException in .Net Framework (C#)

  • You should raise NotImplementedError

    raise NotImplementedError
    

    ruby-doc


    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.


    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.

    链接地址: http://www.djcxy.com/p/25852.html

    上一篇: RSpec重试抛出异常,然后返回值

    下一篇: 如何发信号“尚未实施”?