Comments (6)
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton
I think the best way to solve this would be to add Record
suffix to sdk classes. So org.stellar.sdk.Account
will become org.stellar.sdk.AccountRecord
. Do you have a better idea how to name it?
from java-stellar-sdk.
Love the quote. I'd leave the sdk.Account alone, and change the base.Account. The sdk.Account really does represent information about the account, but the base.Account represents access to an account at its current ledger number.
Hence a couple of suggestions (from most to least radical):
a.) Get rid of the base.Account, and the base.TransactionBuilderAccount, and make the transactionbuilder accept a key and a ledger number. Adjust the server to return the ledger number directly.
b.) Get rid of the base.TransactionBuilderAccount interface, and rename the base.Account class to TransactionBuilderAccount.
c.) Rename base.Account to base.TransactionAccount.
d.) Rename base.Account to base.AccountAccessKey.
That's just a handful of brainstormed ideas...
from java-stellar-sdk.
Random note: IMO, this issue here is that we're not properly shielding users of stellar-sdk from the details of stellar-base. The fact that you need to import both base.Account
and sdk.Account
is a design smell, to me.
I agree with @myrle-krantz that killing base.Account
and base.TransactionBuilderAccount
, and personally I would extend that desire to most of the helper objects in https://github.com/stellar/java-stellar-base/tree/master/src/main/java/org/stellar/base. The fact that we have a bunch of helper objects to make it easier to work with memos is indicative, in my opinion, of a poor API.
The motivation for these helper classes that "shadow" the XDR structures is, I believe, to make it easier to work with building the XDR that is required by the stellar protocol. We then further wrap the new "helper" classes in a builder pattern, to ostensibly make it easier to construct the helper objects. This is a mistake IMO: The builder objects that stellar-base exposes should instead directly work upon the xdr objects.
Let me instead propose an alternate "story" of interacting with the stellar network through java-stellar-sdk. I don't think we have a strong vision of what it should be like to use this library, and I think we would be well served by having one.
First, lets divide the experience into two halves: "reading and interacting with data from horizon" for one of the halves, and the other half will be "authoring new transactions for inclusion" into the network. IMO, most integrating will begin with reading from or responding to events from horizon, and so most of the classes we expose should aid in that endeavor. We should provide well-defined paths into the authoring experience of the library that hangs from the reading side.
I've written some psuedo-code that illustrates some of my ideas here: https://gist.github.com/nullstyle/db1e5742819b7eb3f5f9
Some takeaways from the sample:
- We don't need to import classes from java-stellar-base.
- The objects involved provide methods to continue communication with the server. Note that
SubmissionSuccessResponse
has a methodgetTransaction()
that loads more data from horizon - Some of the overloads in the payment builder have inputs that are symmetric to the outputs of the read API. For example,
getFrom()
returns aString
and so one of the overloads ofdestination
takes a String, instead of being restricited to a stellar-baseKeyPair
In standup today bartek made the case for merging java-stellar-base and java-stellar-sdk. I'm not opposed to this. These ideas are just one potential direction, and I'm open to others. I'd bet that you have more experience than either bartek or I when it comes to designing java APIs, so I would love your input. There's an opportunity here to heavily influence the API, if you're interested in helping us.
from java-stellar-sdk.
I too would tend toward merging base and sdk as Bartek suggests.
I like your pseudo-code, Scott, and your use of streams and lambdas is elegant. I would be a little nervous about the client-side filtering of potentially large amounts of data there, but I'm guessing you all have a better understanding of the amount of data involved than I do, and that part's not central to your case.
I disagree that authoring new transactions is secondary. It's the first thing I'll be doing after creating an account (oh wait: I guess that does make it the second thing I'll be doing: o).
But none of this actually solves the problem that you've run into here: you really do have two account objects: one which represents the address of an account and one which represents the data contained in it as retrieved from the server. This probably isn't the only place you'll have this duality either. Transaction looks like another candidate. I wouldn't mix these two separate concerns into all-purpose objects, though I would make it as easy as possible to move from one to the other. (As you intimate, Scott) I would try to create a naming standard which makes it clear which object is on which side of that divide.
For example: AccountAddress, and TransactionAddress vs. Account and Transaction, or AccountId and TransactionId vs AccountRecord and TransactionRecord. Then I'd use the server to go from AccountId to AccountRecord (using one set of names here as an example), and use a factory function to go from AccountRecord to AccountId.
I do love APIs, but getting involved in the naming discussion does feel a bit like inserting my two cents into a marital conflict. I'm happy to make suggestions, but the final decision belongs to you all.
from java-stellar-sdk.
java-stellar-base and java-stellar-sdk merged.
from java-stellar-sdk.
Thank you
from java-stellar-sdk.
Related Issues (20)
- Add the fromXdrBase64, fromXdrByteArray, toXdrBase64 and toXdrByteArray methods to the XDR classes. HOT 3
- Optimize the way of generating XDR classes.
- Preserve existing auth entries after simulation if they're present HOT 1
- Add `SorobanDataBuilder` to prepare sorobanData easily. HOT 1
- Use JDK 11 for building jar.
- Update XDR reference HOT 3
- New soroban_readme.md for Soroban sdk usage HOT 1
- There is a typo in Transaction.isSorobanData. HOT 1
- `AccountConverter.enableMuxed()` not throwing exceptions with trailing characters of a valid mux account
- The dependency on commons-codec conflicts with the commons-codec in lower versions of the Android framework.
- NullPointerException when calling `PaymentOperationresponse.getAsset()` HOT 2
- Updating the SDKs to the stable Protocol 20 release HOT 1
- Protocol 20: Add support for resource leeway in `simulateTransaction`
- Add support for new fields in Soroban RPC's `sendTransaction` endpoint
- Required changes for passing parameters when communicating with Soroban RPC. HOT 1
- Provide documentation for each version on javadoc.io. HOT 1
- Provide the SDK in the Central Maven HOT 1
- How to configure Friendbot for testnet network ? HOT 2
- Protocol 21 SDK Support
- Horizon v2.31.0 and RPC v21.4.0 changes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-stellar-sdk.