Ruby and duck typing: design by contract impossible?

后端 未结 8 1542
别那么骄傲
别那么骄傲 2020-12-14 09:16

Method signature in Java:

public List getFilesIn(List directories)

similar one in ruby

def get_fi         


        
8条回答
  •  执笔经年
    2020-12-14 09:41

    I would argue that although the Java method gives you more information, it doesn't give you enough information to comfortably program against.
    For example, is that List of Strings just filenames or fully-qualified paths?

    Given that, your argument that Ruby doesn't give you enough information also applies to Java.
    You're still relying on reading documentation, looking at the source code, or calling the method and looking at its output (and decent testing of course).

提交回复
热议问题