Address - VittorioDeMarzi/hero-beans GitHub Wiki
Address
- current version: [Second Iteration]
First Iteration
Idea
- multiple addresses per member, but limit in business rules to 5
- let the Order choose which address is used for billing/shipping
- use snapshots in Orders to preserve history
e.g.:
@Entity
class Order(
@Embedded val shippingAddress: AddressSnapshot,
@Embedded val billingAddress: AddressSnapshot,
@Id @GeneratedValue val id: Long,
)
// snapshot
@Embeddable
class AddressSnapshot(
val street: String,
val number: String,
val city: String,
val postalCode: String,
val countryCode: String,
)
Problems
- if there is different addresses for billing: do we allow billing outside of Germany? -> makes validation / business rules more complex
- if we don't allow for billing outside of Berlin, there is no much use to separate billing and shipping addresses
- requires careful handling inside several layers -> when placing the order, inside the address service etc.
Second Iteration
Idea
- unidirectional relationship with Member
- allow for multiple addresses per user
- limit to 5 inside the address service
- do not differentiate between billing and shipping for now
- allow labels for "Work", "Home" etc.
e.g.:
@Entity
class Order(
@Embedded val address: AddressSnapshot,
@Id @GeneratedValue val id: Long,
)
// snapshot
@Embeddable
class AddressSnapshot(
val street: String,
val number: String,
val city: String,
val postalCode: String,
val countryCode: String,
)