Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
41 views
Java Fluent Api Design Example - Restaurant
Uploaded by
Giuseppe
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save java-fluent-api-design-example_Restaurant For Later
Download
Save
Save java-fluent-api-design-example_Restaurant For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
41 views
Java Fluent Api Design Example - Restaurant
Uploaded by
Giuseppe
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save java-fluent-api-design-example_Restaurant For Later
Carousel Previous
Carousel Next
Save
Save java-fluent-api-design-example_Restaurant For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 5
Search
Fullscreen
DZone, Log In Join Feet Design a Fluent API in Java Fearlessly. Learn how to design an API that invokes a series of methods, making i fluent, wile using Java e te a5) © commenti} Se save Tet 2 £7404 Ves cn he Zone community nl ge the fl member experince In this ate we wl discuss how to desig fluent AP in ava. The term lent nterfoce was coined by ‘Martin ower and Ere Evans Fluent APL neato build a APL in sich way so that t mets the following + The APL ser can understand the APL very easy +The API can perform a serlesofactlons in ofder to fish task, In Java, we can dae witha series of| method calls (cbaining of methods). + Each method's name shouldbe domain-specific terminology. Suppose you want to design an APL ora domal, say Rta so there shouldbe some omion terminology that exists the Retail omsin an for certain content (Tas) tl take series of Now when you design an API you should design it sucha way that when APL users al Bling Servic for invoice generation the users can faenty perform each tp in onder to complete said generation andthe ‘APL will ait users to perform those step upon invoking Bling Service \When an API method snvoked by a user, the method wil perform its asad returns a Domain Objet, ‘which wil assistin what to co nest — until al tepsareeancuted, Unlike a standard API isthe APL ‘se'sjb to cll AP methods in sequential way to successfully performs task Sothe API usershave to iow about the servic step very wll Design A Fluent AP: one) ren Ct Poe) QExample Suppose we want to design an/APLSFS RSE ant ‘As acustomer of this restaurant one should fellow these steps: e - 8 a @-@ Ina standard API design, we wil do the following + create "Restaurant interface, + Create an fimplementaton cass of Restaurant Compose the Mencar las into + Create getters and setters for restaurant properties ke name, addres. ee +n MenuCard maintain a ist of tems Expose some methods ike showmenu),Ontermen( ee + Bach Mem has na 1nd cost properties and corresponding gtters/stters. + Whon the APL user calls thls API he/she wil calla sequence of methods(Enter Restaurant cll, showMenu(). then Ordermenu) et) to perform the above steps shown nthe picture Soitis nt fluent. lat of sequential statements nee to be performed to complete the task andthe APL ser has to know the sequence Now will show you how we vil design afuent APL 1. create an interface Resturant which has two methods «Print ame ofthe restrantnotie the return type returns self because ater displaying name user wants to see menu card bs show( method returns menucant‘Thing to notice: Restarent Implementation Is suggestive as ithas two methods ones name and another show (next operation user wants to perform) 2, IMenu Implementation hes 4 important methods shownnenu(}order(ea()y(-ll methods return Menutlandor implementation sowe can perform one ofthese action. Again this is Suggestive. ode Implementation Java fable tae arc ( te tetramer mes 2 ple etn b "soto concen contrac orale earn ny) le ten ele ny ) pag oma aap ctr, sie tae , Implementation "ech: conceal 2 Ser on ee ees cotrat- en bc cas tron leet Rett , Inner te tel 5 + nes pte meme st a 2 1 pcg oneal Ste frattnserayot 2 te fmt te 2 art cance tap etree ‘unre enn map etree en 2 i a ramet em © pic tnetometnse)| * aiic ta nt | Ct « y : Ne as a Freep“ ra af 3 sp itn Cs st d : te me at ] Of > cy Sam tl « we mi : sae SOU& t : » a eae stiri; my Fe en reine de > sme E Sent pare pe q| =r oo Spates et 4 = ¢ : spenomrinincetiog It > ; * SL pic sew pa 4 : t = Fyne en 6 a oy ° Se ere TS pe he wea ine i Hela o fa Tot pe wld sow Bh fre as mua) m ot hey my Test Fluent API fate cine riowtn f peli mini we n o ‘Output: Look How we perform the steps Nuenty by calling series of methodses Aesaan()name(ARSALANC) shou) -order(0).order(1).eat().pey()s Tiss test example. To make it mare plished we need to work on the fllowing: + The Order method should take Menltem insted of postion, and italso needs to han Exception scenarios if Menutem not found. + Order should beable ta be cancelled cash) + Pay must have payment mode, (ered ar debit cas + Optional ips shouldbe incorporated. + While eating the user shoud be abet order more items, so make an Order functional during that + Twecaleulation should be added. Like This Article? Read More From DZone ae Bot APY Design With Java 8 Optional re ee ea © me 35) Comments) Seve Tet = 47404 Vi Integration Partner Resources “Te Gene Guide to AP integrations: Explore Biakecsonaly syne contact data Between CRM, P| intgratons Blow te Src eo) Norong, and Oaiabase endport
You might also like
Mellor A Java Oop Done Right Create Object Oriented Code You
PDF
No ratings yet
Mellor A Java Oop Done Right Create Object Oriented Code You
202 pages
API Integration Test Strategy
PDF
100% (1)
API Integration Test Strategy
11 pages
SEN 208 Software Construction LN (1)
PDF
No ratings yet
SEN 208 Software Construction LN (1)
16 pages
Designing+RESTful+API+Quick+Guide+v1.0
PDF
No ratings yet
Designing+RESTful+API+Quick+Guide+v1.0
19 pages
Some Principles For REST API Design PDF
PDF
No ratings yet
Some Principles For REST API Design PDF
7 pages
As If Unit Testing Mattered
PDF
No ratings yet
As If Unit Testing Mattered
19 pages
Interview Question
PDF
No ratings yet
Interview Question
11 pages
Whitepaper JavaBeans
PDF
No ratings yet
Whitepaper JavaBeans
114 pages
Pfhais
PDF
No ratings yet
Pfhais
149 pages
APIDesignAndFundamentals M2 APIFirstAndOpenAPISpecifications
PDF
No ratings yet
APIDesignAndFundamentals M2 APIFirstAndOpenAPISpecifications
37 pages
Sun Microsystems Javabeans
PDF
No ratings yet
Sun Microsystems Javabeans
114 pages
API Design For Integration (2023)
PDF
No ratings yet
API Design For Integration (2023)
8 pages
API Design: CPSC 315 - Programming Studio Spring 2009
PDF
No ratings yet
API Design: CPSC 315 - Programming Studio Spring 2009
21 pages
API
PDF
No ratings yet
API
21 pages
2012 Web API Design
PDF
No ratings yet
2012 Web API Design
38 pages
Apigee - Web API
PDF
No ratings yet
Apigee - Web API
38 pages
API Design Ebook 2012 03
PDF
No ratings yet
API Design Ebook 2012 03
38 pages
Java API Best Practices
PDF
No ratings yet
Java API Best Practices
8 pages
Documentation
PDF
No ratings yet
Documentation
13 pages
API - Common-Practices-For-Rest-Api-Development
PDF
No ratings yet
API - Common-Practices-For-Rest-Api-Development
2 pages
The Little Manual of API Design Jasmin Blanchette Trolltech
PDF
100% (1)
The Little Manual of API Design Jasmin Blanchette Trolltech
33 pages
API Design Best Practices V1.0
PDF
No ratings yet
API Design Best Practices V1.0
43 pages
Batch B3 36 Exp.no 01
PDF
No ratings yet
Batch B3 36 Exp.no 01
7 pages
U6 M1 L5 Annotated - Tagged
PDF
No ratings yet
U6 M1 L5 Annotated - Tagged
14 pages
Rest API Example
PDF
No ratings yet
Rest API Example
30 pages
best-java-microservices-coding-practices
PDF
No ratings yet
best-java-microservices-coding-practices
62 pages
Fluent Interfaces: Shushobhickae Singh, Chitrangada Nemani M
PDF
No ratings yet
Fluent Interfaces: Shushobhickae Singh, Chitrangada Nemani M
4 pages
in sem 1 key - set 1 - AOOP - 21CS2116AA-1-15
PDF
No ratings yet
in sem 1 key - set 1 - AOOP - 21CS2116AA-1-15
15 pages
API Design Giude
PDF
No ratings yet
API Design Giude
9 pages
aoop skill week-3
PDF
No ratings yet
aoop skill week-3
12 pages
API Testing Approach
PDF
No ratings yet
API Testing Approach
2 pages
Batch B3 48 Exp.no 01
PDF
No ratings yet
Batch B3 48 Exp.no 01
7 pages
Designing APIs
PDF
No ratings yet
Designing APIs
2 pages
Things Must To Know For Starting Career in Programming
PDF
No ratings yet
Things Must To Know For Starting Career in Programming
3 pages
APApiDesign3.9 Studentmanual 18dec2017 PDF
PDF
No ratings yet
APApiDesign3.9 Studentmanual 18dec2017 PDF
189 pages
API-BP - M4L3V3 - Querying, Filtering and Pagination
PDF
No ratings yet
API-BP - M4L3V3 - Querying, Filtering and Pagination
12 pages
API Structure
PDF
No ratings yet
API Structure
6 pages
Api Design 2 Principles
PDF
No ratings yet
Api Design 2 Principles
47 pages
Api Testing Notes
PDF
No ratings yet
Api Testing Notes
15 pages
api_design_1_bloch
PDF
No ratings yet
api_design_1_bloch
46 pages
Batch B2 26 Exp.no 01
PDF
No ratings yet
Batch B2 26 Exp.no 01
7 pages
Web API Best Practices
PDF
100% (1)
Web API Best Practices
53 pages
Webmethods Flow Service Design and Practice PDF
PDF
100% (1)
Webmethods Flow Service Design and Practice PDF
11 pages
Lecture 20
PDF
No ratings yet
Lecture 20
39 pages
7-API Design and Framework Version 1.2 - 2016-12-01
PDF
No ratings yet
7-API Design and Framework Version 1.2 - 2016-12-01
48 pages
W7D1 - Sprint3 - LoadBalancer & AWS - Presenting Project During Interview (17june)
PDF
No ratings yet
W7D1 - Sprint3 - LoadBalancer & AWS - Presenting Project During Interview (17june)
13 pages
Apis
PDF
No ratings yet
Apis
7 pages
SG 247497
PDF
No ratings yet
SG 247497
690 pages
Linq - Beyond Queries: LINQ For Better Business Logic
PDF
No ratings yet
Linq - Beyond Queries: LINQ For Better Business Logic
15 pages
Code Maintenance: Specification Standards For Class Design: Sunday, 4 November 12
PDF
No ratings yet
Code Maintenance: Specification Standards For Class Design: Sunday, 4 November 12
22 pages
STRENGTH TRAINING FOR DISTANCE RUNNERS
PDF
No ratings yet
STRENGTH TRAINING FOR DISTANCE RUNNERS
6 pages
Document
PDF
No ratings yet
Document
72 pages
QonfX Virtual Agenda
PDF
No ratings yet
QonfX Virtual Agenda
1 page
Patients Registered at a GP Practice, October 2024 - NHS England Digital
PDF
No ratings yet
Patients Registered at a GP Practice, October 2024 - NHS England Digital
7 pages
Vegan Food & Living - December 2022
PDF
100% (1)
Vegan Food & Living - December 2022
128 pages
Patellofemoral Pain Syndrome (Runner's Knee) - Seven Exercises To Stabilize The Knee - InformedHealth - Org - NCBI Bookshelf
PDF
No ratings yet
Patellofemoral Pain Syndrome (Runner's Knee) - Seven Exercises To Stabilize The Knee - InformedHealth - Org - NCBI Bookshelf
9 pages
Mortgage Guide
PDF
No ratings yet
Mortgage Guide
29 pages
Postel Law
PDF
No ratings yet
Postel Law
8 pages
Effective and Scalable Software Compatibility Test
PDF
No ratings yet
Effective and Scalable Software Compatibility Test
12 pages
Testing Microservices With Consumer-Driven Contracts
PDF
No ratings yet
Testing Microservices With Consumer-Driven Contracts
75 pages
State of Agile Development Survey
PDF
No ratings yet
State of Agile Development Survey
16 pages
API Testing
PDF
No ratings yet
API Testing
3 pages
SRP
PDF
No ratings yet
SRP
6 pages