Skip to content

Commit

Permalink
AbstractRpcClient: add more to composition-over-inheritance TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
msgilligan committed Jul 25, 2022
1 parent bb9fc54 commit 4feae75
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
// A. The set of JSON-RPC methods that are supported, e.g. `getblockcount()` (which creates potential conflicts with `send()` etc)
// B. The JSON mapping implementation. Which for now and the foreseeable future is Jackson only.
// C. The transport implementation.
//
// As we want to support both HttpUrlConnection vs. java.net.http while transitioning to java.net.http, we don't want to force
// subclasses like `BitcoinClient` to choose one or the other. So making (C) transport implementation a separate, composable object
// is the first step. Later we can look at separating (A) and (B).
// is the FIRST STEP. Later we can look at separating (A) and (B).
//
// To separate (C) the easiest way is probably via a constructor parameter.
// The proper separation for (A) is probably a complete separation. There should be no required inheritance to implement
// a client with a set of methods. Internally the client would have a transport and a mapper and those could optionally be made available
Expand All @@ -24,6 +26,11 @@
// of the `result` field in the JsonRpcResponse<RSLT>. It might be helpful to think of this as two functional mappings:
// (1) Map Java method name and parameters to a JSON-RPC request (either map to set of Java Objects _or_ all the way to JSON)
// (2) Map from received JSON-RPC response to JsonRpcResponse<RSLT> -- this response mapper function is configured as part of making the request.
//
// The SECOND STEP is to abstract the specifics of Jackson from the (two) transport implementations. Basically methods/functions to
// map from request to string/stream and to map from string/stream to response. The java.net.http implementation has already defined
// some functional interfaces for this, so coming up with an interface that both the java.net.http implementation and the HttpUrlConnection
// implementation can use will lead to this "SECOND STEP"
/**
* Abstract Base class for a strongly-typed, Jackson-based JSON-RPC client. Most of the work is done
* in default methods in {@link JacksonRpcClient} This abstract class implements the constructors, static fields, and
Expand Down

0 comments on commit 4feae75

Please sign in to comment.