Better HN
topnewbestaskshowjobs
Log inSign up

lambdamn

4 karma · joined Apr 26, 2018 (8y ago) · 1 submissions

Submissions

comment 8y ago · link · parent

You can still do something like User.create(data) using a bottom up approach in designing the interface. If we had a module User, we could do something like (using Haskell syntax, since that's the functional language I know):

create = User (validate . format $ data)

Only the create function needs be exposed, but the useful bit is that the create function is built out of the composition of smaller functions which makes it easy to change or completely swap out a component of the whole process. A top-down User.create function would likely be a rather large, monolithic chunk of code.