AbacusUtil Docs | Download | Javadoc | FAQ | Community

Model/Entity

Model/Entity is the abstraction of real world. defining a good Model/Entity will make programming much easier, for example:

// Without Model/Entity object.
Document doc = new Document();
doc.put("gui", N.uuid());
doc.put("firstName", "jack");
doc.put("lastName", "ye");

// With Model/Entity object.
Account account = new Account().setGUI(N.uuid()).setFirstName("jack").setLastName("ye");

Here the differences are not jsut about lines of code, you have to deal with tens/hundreds of key names and the data types. Someone may think: "I'm using NoSQL. Model/Entity object is unnecessary". That's not true. Model/Entity decides how the data/logic in real world will be processed in program, which is not related to the technologies of data store. Defining a good model/entity will:

  • Make reading/saving/transfering/manipulating data much easier
  • Simplify the system design and implementation
  • Reduce a lot of extra headaches which could be introduced by bad/no Model/Entity
  • ...
  • There is also a good example about how programming can be simplified by Model/Entity: SQLite Executor

    Model/Entity is not just key/value, it's much more than the key/value structure Map/Document/ContentValues...