Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 3
    Can your "record" a real data feed and "play" it later into the third party library? Commented Oct 6, 2015 at 15:57
  • 2
    Someone could write a book on problems like this. In fact, Michael Feathers did write just that book: c2.com/cgi/wiki?WorkingEffectivelyWithLegacyCode In it, he describes a number of techniques for breaking difficult dependencies so that code can become more testable. Commented Oct 6, 2015 at 16:52
  • 2
    The adapter around the third party library? Yes, that's exactly what I recommend. Those unit tests won't improve your code. They won't make it more reliable or more maintainable. You're just partially duplicating someone else's code at that point; in this case, you're duplicating some poorly written code from the sound of it. That's a net loss. Some of the answers suggest doing some integration testing; that's a good idea if you just want an, "Is this working?" sanity check. Good testing is hard, and it takes just as much skill and intuition as good code. Commented Oct 7, 2015 at 0:15
  • 4
    A perfect illustration of the evil of built-ins. Why does not the library return a Timestamp class (containing any representation they want) and provide named methods (.seconds(), .milliseconds(), .microseconds(), .nanoseconds()) and of course named constructors. Then there would have been no issues. Commented Oct 7, 2015 at 8:41
  • 2
    The saying "all problems in coding can be solved by a layer of indirection (except, of course, the problem of too many layers of indirection)" comes to mind here.. Commented Oct 7, 2015 at 10:54