K
K
Kirill Tekord2017-10-26 00:32:50
PHP
Kirill Tekord, 2017-10-26 00:32:50

What is the best name for a structure linking several logically related objects?

There are the following objects:
- Goods (Product);
- Cart (Cart), which stores positions;
- Position (Cart Position) is a format structure (product id, product options, position hash for which it is available in the cart). The position is stored in the session, therefore it does not store an instance of a specific product, but only its ID.
Considering that the position does not store an instance of a specific product, I request the product from the database every time I work with the basket: output on the order page, checking the availability of the product when placing an order, etc. I need to have a structure that would link the Cart, Position and Product instance from this position. More or less like this:

class CartItem {
  protected $ownerCart;

  protected $position;

  protected $product;

  public function __construct(Cart $ownerCart, CartPosition $position, ProductInterface $product) {
    $this->ownerCart = $ownerCart;
    $this->position = $position;
    $this->product = $product;
  }

     // Тут геттеры корзины, позиции и товара

How would you advise to name such a structure to reflect its essence : this is a connecting structure, the elements of which make sense separately, but the combination of these elements also has its own meaning and purpose.
My first options are: CartItemInstance, CartItemReference, CartItemAggregate.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Nesmeyanov, 2017-10-26
@SerafimArts

What would you call an item that has goods, "cash" (basket) and stuff? Shop - suitable?

S
Stalker_RED, 2017-10-26
@Stalker_RED

Why not cart? What then does cart do if one more entity is needed to bind the goods to the basket?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question