Currently, the generated code is strongly coupled to Thrift. This locks the whole codebase into Thrift, or forces developers to manually duplicate types and convert between them. Instead, the generated code could decouple from Thrift. Here's a simplified example.
struct Address {
1: required string address1
2: optional string address2
}
Currently this generates:
object Address {
...
}
trait Address
extends ThriftStruct
with ... {
...
def address1: String
def address2: Option[String]
...
}
I am suggesting generating completely decoupled trait:
trait IAddress {
def address1: String
def address2: Option[String]
}
object Address...
trait Address
extends ThriftStruct
with IAddress // <= NOTE: the existing trait now extends the new decoupled trait
with ... {
...
def address1: String
def address2: Option[String]
...
}
Now because of this subtyping relationship, any codebase that wants to stay decoupled from Thrift–say, domain model or business logic code–can use the decoupled IAddress trait instead of the strongly-coupled Address trait.
Note that the naming is a suggestion only, it's not the important part of this proposal; the important part is the decoupling from Thrift.
Currently, the generated code is strongly coupled to Thrift. This locks the whole codebase into Thrift, or forces developers to manually duplicate types and convert between them. Instead, the generated code could decouple from Thrift. Here's a simplified example.
Currently this generates:
I am suggesting generating completely decoupled trait:
Now because of this subtyping relationship, any codebase that wants to stay decoupled from Thrift–say, domain model or business logic code–can use the decoupled
IAddresstrait instead of the strongly-coupledAddresstrait.Note that the naming is a suggestion only, it's not the important part of this proposal; the important part is the decoupling from Thrift.