I have a class named Change
which should be abstract and have some basic methods.
I have classes Insert
, Update
and Delete
that extends Change
.
In the case of Insert
, Update
I just use extend and add no logic!
public class Insert extends Change {}
In the Delete
class I have an extra method that doesn't exist in the Change
class (which is the base abstract class).
It seems to be wrong design, that I have classes like Insert
and Update
that extend from Change
but don't do anything (no logic in this classes) .
What do you think? what should be the hierarchy?
EDIT:
There is an endpoint in the service that returns an object named ChangedEntities
and the consumer of this endpoint which is another service use this endpoint to insert/update/delete entities in the DB.
So the consumer of this endpoint gets,
public class ChangedEntities {
private Insert inserations;
private Update updates;
private Delete deletions;
}
public class Change {
private List<Entity> entities = new ArrayList();
public void addEntity(Entity entity) {
entities.add(entity);
// the logic is more complex and is common to insert/update/delete
}
}
public class Insert extends Change {}
public class Delete extends Change {
public void logDeletion() {
System.out.println("Deleted successfully");
// this should be some complex method
}
}
Change
(and its child classesInsert
,Update
,Delete
) only to keep track of changes? Or, do they have other executable content? In other words, areChange
classes commands, or just "receipts" ? – Nick Alexeev Nov 21 '18 at 0:18Delete
supposed to be able to supportaddEntity
? This seems wrong if it is. As it stands, it's hard to see the purpose ofChange
itself, or why functionality forInsert
is in that class, rather thanInsert
. – David Arno Nov 21 '18 at 11:37