Howdy, y'all.
Bably Das wrote:I think I need to change the name of the Room class to a more appropriate name of Record class.
Well, I'd say that that isn't very appropriate... we have to think object-oriented, and not in terms of database. The entity in this domain is Room, not Record. We have to be careful, because if we have too many flags or too many "ifs" in the code, then this may be indicating that the code is procedural.
Another thing is, in order to call it
Entity, you'll have to include the number of that record in the Room object. In the Domain-Driven Design Quickly book, in the description of Entity it says that:
There are different ways to create a unique identity for each object. The ID could be automatically generated by a module, and used internally in the software without making it visible to the user. It can be a primary key in a database table, which is assured to be unique in the database.
Or, you can control it somehow without having the record number attribute in the object. Then, it would be a
Value Object.
What you can do is keep the Room object in a List, and if the record is deleted, then the entry is null (something like, if record 1 is deleted, then yourArrayList.add(0, null)). But you'll have to remember that the entry 0 is record 1, entry 1 is record 2, and so on... and when you delete a record, then you simply set its entry to null.