Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requiring lowercase class names when declaring tables #50

Closed
kspangsege opened this issue Aug 19, 2012 · 1 comment
Closed

Requiring lowercase class names when declaring tables #50

kspangsege opened this issue Aug 19, 2012 · 1 comment

Comments

@kspangsege
Copy link
Contributor

Currently, classes that are used to declare tables must have uncapitalized names. This is because the code generator generates a cursor class with the same name except that in this case it is capitalized.

I don't like having to write classes with lower case names, and I fear that a lot of Java programmers are going to hate us for it.

I suggest that we either:

  • Rename the cursor class from Employee to EmployeeCursor or EmployeeRow, and thereby allowing for the declaration class to be renamed from 'employee' to Employee.
  • Rename the declaration class from 'employee' to EmployeeRow, or EmployeeDecl, or EmployeeSpec.

In the latter case, the code generator would then strip off the suffix. It might even be made to recognize and strip off any of the three mentioned suffices. Since the declaration table is not actually used for anything, currently, the prettyness of its name should not matter too much.

On the other hand, the declaration class could be made to have some useful purposes, for example, we might want to allow something like the following (this assumes that the declaration class is renamed to 'Employee' and the cursor class is renamed to 'EmployeeRow'):

public void insertEmployees(Set<Employee> employees)
{
    for (Employee employee: employees) {
        employeeTable.add(employee);
    }
}

and

public Set<Employee> extractEmployees()
{
    Set<Employee> employees;
    for (EmployeeRow row: employeeTable) {
        employees.add(row.getEmployee());
    }
    return employees;
}
@ghost ghost assigned bmunkholm Aug 19, 2012
@ghost ghost assigned nmihajlovski Aug 27, 2012
@bmunkholm
Copy link
Contributor

We should be able to name the @table class with also uppercase first letter.
We should also allow the user to define the names of the generated classes.
We should also make it more explicit that e.g. an "Employee" is not the traditional data that will be copied. But by calling it "EmployeeRow", that you do work with a database and and not your normal instance/copy of employee data.
We would like to make it more consistent and not so hard to guess upper/lowercase standard..

Below an example (with default values assumming "prefix" is the name the user has given the table.
@table( row=prefixRow, table=prefixTable, view=prefixView, query=prefixQuery )
class prefix {... }

so
@table class Employee {..} will now generate: EmployeeRow, EmployeeTable, EmployeeView, EmployeeQuery.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants