Skip to main content
Tweeted twitter.com/#!/StackProgrammer/status/457166391263920128
deleted 1 character in body
Source Link

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

For this Entity I have a repository for this entity.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think the first way is redundant. But it also seems wrong to use repository for partial entity updates like in the 2nd way. WhatWhich way is the correct one? Maybe I missed something?

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

For this Entity I have a repository.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think the first way is redundant. But it also seems wrong to use repository for partial entity updates like in the 2nd way. What way is the correct one? Maybe I missed something?

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

I have a repository for this entity.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think the first way is redundant. But it also seems wrong to use repository for partial entity updates like in the 2nd way. Which way is the correct one? Maybe I missed something?

personal stuff removed // http://meta.stackoverflow.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts
Source Link
gnat
  • 20.5k
  • 29
  • 117
  • 309

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

For this Entity I have a repository.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think the first way is redundant. But it also seems wrong to use repository for partial entity updates like in the 2nd way. What way is the correct one? Maybe I missed something?

Thanks in advance.

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

For this Entity I have a repository.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think the first way is redundant. But it also seems wrong to use repository for partial entity updates like in the 2nd way. What way is the correct one? Maybe I missed something?

Thanks in advance.

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

For this Entity I have a repository.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think the first way is redundant. But it also seems wrong to use repository for partial entity updates like in the 2nd way. What way is the correct one? Maybe I missed something?

added 8 characters in body
Source Link

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

For this Entity I have a repository.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think the first way is redundant. But it also seems wrong to use repository for partial entity updates like in the 2nd way. What way is the correct one? Maybe I missed something?

Thanks in advance.

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

For this Entity I have a repository.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think first way is redundant. But it also seems wrong to use repository for partial entity updates like in 2nd way. What way is the correct one? Maybe I missed something?

Thanks in advance.

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags:

class Entity
{
    /** @var EntityFlags */
    private $flags;
    ...
}

For this Entity I have a repository.

My goal is to modify flags in the DB. There are two ways I see:

  1. Get entity from the repository, modify flags like $entity->getFlags()->set($name, true) and save it: $repository->save($entity).
  2. Create an additional method in the repository, e.g. modifyFlags(EntityId $id, EntityFlags $flags)

I think the first way is redundant. But it also seems wrong to use repository for partial entity updates like in the 2nd way. What way is the correct one? Maybe I missed something?

Thanks in advance.

deleted 1 character in body; added 1 character in body
Source Link
Loading
Source Link
Loading