qcubed / qcubed

The official QCubed framework git repo
https://qcubed.eu/
57 stars 47 forks source link

Generate meaningful names for ORM objects #133

Open olegabr opened 11 years ago

olegabr commented 11 years ago

For now Person::__toString() contains just

return sprintf('Person Object %s',  $this->intId);

statement, that leads for strings like "Person Object 4" in every place where Person object is referenced

It is the first and very tedious task I've always do after codegen run for my new project or after new table added.

In the same time each table that should be exposed to customer, contains a descriptive column named as "name", "description", "desc", "short_desc", "long_desc", etc.

It whould be great to have an ability to describe this list of choices in a codegen_settings.xml and let the codegen find the right column as a first good one from this list. The resulting code should be like this:

return $this->strName;

And the last but not least, it should support records like "last_name first_name". The resulting code should be like this:

return sprintf('%s %s',  $this->strLastName, $this->strFirstName);
scottux commented 11 years ago

I agree, we should scan for common field names like name, first_name, last_name, title and adjust the toString method accordingly. We would probably need a way to define precedence (if there is both a name and title field) and custom fields to use.

vaibhav-kaushal commented 11 years ago

I have tables with IDs named like: ppid_ert, prtf_ret, pord_s_dec and so on. What can you do with that? It is easier to change that field once than create an algorithm to detect 'common' names. I am not against the idea but I do think it would be a waste of time.