dart-bridge / trestle

Database Gateway and ORM for Dart
MIT License
26 stars 12 forks source link

Rename 'Model' to 'Entity' #1

Open gmosx opened 8 years ago

gmosx commented 8 years ago

...like in Hibernate. Or maybe something like 'PersistentObject' or just 'Persistent'.

emilniklas commented 8 years ago

Are there any reasons for this other than personal preference? I'm totally open for discussion, I just want there to be thought behind whatever name we choose. :grin:

gmosx commented 8 years ago

I think Model is a very generic word, it has nothing to do with persisting with a database. Also, it's kind-of like a plural, i.e. refers to a collection of e.g. Entities that comprise the model. I am not sure what's the right word, but I don't like Model that match.

(On the other hand, Gateway is a very interesting choice ;-))

gmosx commented 8 years ago

Btw, I think a great name would be 'Record' (instead of Model).

emilniklas commented 8 years ago

I've done some googling, and this is what I see most frequently: "data model" is a term used to describe data structures in OOP in association with the persistence layer. "entity" is a term used to describe the thing we're representing.

So this is what it looks like to me:

"To represent the User entity, we create a User model, which the ORM persists in the database."

So... if we assume this is the terminology most frequently used, what should we call the class...?

I'm not sure!

luisvt commented 8 years ago

In JPA it is mainly used the name entity for the annotation that we put at the top of the class

@Entity
public class Person {
...
}

The pattern that @emilniklas is fallowing is different from JPA pattern. He is following the Laravel pattern, which makes every class to extend a Model class.

class Flight extends Model
{
    //
}

So that, in my opinion the name model should be kept.