Ruby Conf 12 - Boundaries by Gary Bernhardt
ConfreaksYouTube ↗
Further reading 7
Why does testing a business rule need a database? →Separate who qualifies for a reminder from whether the reminder can be delivered.Why do tests pass when the program is wrong? →Gary Bernhardt’s isolated tests and Andrej Karpathy’s neural network both deliver good news when the code is wrong.Can you isolate side effects in the language you already use? →Separate a decision from the code that reads a database or sends mail. The boundary depends on how data flows, and can be introduced within an existing language.Where do side effects belong? →Overwatch concentrates side effects on one side of an interaction. A functional core similarly leaves database access and email to its surrounding shell.Can small components still be tightly coupled? →Changing component size and changing how components communicate are separate decisions. Passing a value can remove a dependency on a synchronous call.Where should a business rule end? →Separating independent concerns becomes concrete in a functional core: compute the decision from values, then let another layer carry out its effects.What should cross a module boundary? →Values have meanings that callers can inspect independently. A boundary that passes values makes decisions easier to exercise without setting up the surrounding infrastructure.
Caption notes
Move decisions into a functional core and leave databases and mail in an imperative shell. Tests can then check decisions without mocks that might disagree with production objects.
Original passages · 5
if you don't stub the boundary correctly, your test will pass and your production system will be wrong.the expired users class makes all the decisions and the sweeper class has all the dependencies.Values in your system afford shifting process boundaries.we now have values as boundaries.an imperative shell that surrounds the functional core.