question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve Java Slice API's usability

See original GitHub issue

Accessing 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:open
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
hemantgscommented, Nov 15, 2021

Hi , can I have a go

0reactions
simerplahacommented, Dec 1, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found