Improve Java Slice API's usability
See original GitHub issueAccessing Slice
from Java requires input ByteOps
for each API call which is repetitive and no fun.
Slice
.ofBytesJava(50)
.addInt(data.getInteger(), ByteOps.Java())
.addLong(data.getLongVal(), ByteOps.Java())
.addStringUTF8(data.getString(), ByteOps.Java())
.close();
See example.
Solution
Maybe implement a Java
singleton instance in Slice
which makes the above simpler. For example:
Slice.Java // .java or SliceJava or SliceJ ?
.ofBytes(50)
.addInt(data.getInteger())
.addLong(data.getLongVal())
.addStringUTF8(data.getString())
.close();
With a dedicated Java implementation we could possibly remove ByteOps
all together as long as there are no boxing issues.
Reference code
See SliceTest.java. The end goal is to improve this API.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
How To Design Better JavaScript APIs - Smashing Magazine
Focus on the primary-use cases, only do the things most of your API users will need. Everything else should be left up to...
Read more >Safer typing of complex API usage through Java generics
To explore the feasibility of the approach, gauge its usability, and identify any issues that may crop up in practical usage, we have...
Read more >Improving API Usability - Communications of the ACM
APIs must provide the needed functionality, but even when they do, the design could make them unusable. Because APIs serve as the interface ......
Read more >How to Get a slice of a primitive array in Java? - Tutorialspoint
import java.util.Arrays; public class SlicingAnArray { public static int[] sliceArray(int array[], int startIndex, int endIndex ){ int size ...
Read more >Introduction to Android Slices - Part I - Netguru
Thanks to it, a user can take action immediately in your app just by clicking on Slice. Imagine a bank application which has...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi , can I have a go
The prefixes for Java APIs is inconvenient. There is a better way of doing this so Java APIs are seamless.
I’m going to remove “good first issue” label and work on core tasks. Will visit Java APIs before the release.