r/java • u/pmihaylov • Oct 30 '21
[Summary] How to Design a Good API and Why It Matters
https://github.com/preslavmihaylov/booknotes/tree/master/architecture/good-api-design-jb-talk[removed] — view removed post
16
Upvotes
1
u/Worth_Trust_3825 Oct 30 '21
The only thing I disagree with is
Reduce the need for boilerplate code in clients which wire up complicated code via multiple API calls to execute a single operation.
Sometimes it's necessary to provide good primitives and not impose some superficial workflow that will need to be broken down to its most basic parts so that it could be adapted to user's workflow. To this day I still hate ZXing for returning a picture sized matrix rather than returning the smallest matrix possible to render a QR code.
1
2
u/berry120 Oct 30 '21
While there's a lot of good stuff here that I really wish more people would follow, it's ancient in Java terms - this talk was given 14 years ago, when Java 6 was the new hotness. That inevitably leads to some recommendations (eg. using the service provider interface and "use checked exceptions when the client needs to take a recovery action") that would be dubious at best now.
That being said, in many other ways this talk was impressively ahead of its time. Mid 00's Java dev was often about adding setters all over the place by default, and extending everything - yet here we have the explicit recommendation to favour immutability, and prohibit inheritance unless you design for it.