mjhm / cucumber-api

Cucumber JS step definitions for API testing
MIT License
0 stars 0 forks source link

Lowercase for property/field identifiers #10

Open mjhm opened 8 years ago

mjhm commented 8 years ago

We generally want to match casing conventions as data crosses among module boundaries. In this case the column names in sqlite are all lowercase and they map to Title case struct field names. (Unwinding these sorts of things in big legacy code bases is crazy painful.)

https://github.com/mjhm/cucumber-api/blob/master/example/testapp/src/user/user.go#L7

allonsy commented 8 years ago

So go doesn't have public private keywords so the way it decides what to export from each module is by which fields/methods are upper case (all uppercase identifiers are exported). Therefore, if we make this lowercase, we won't be able to refer to these fields. But, I don't like upper case field names either so we can go a couple of routes: 1) Keep it as is and blame it on google's golang team 2) We can make the field private and expose getters and setters that are uppercase 3) Match the uppercase convention in sqlite

mjhm commented 8 years ago

Interesting. It looks like this is the conventional practice.

allonsy commented 8 years ago

Ah yes, this would fix the json. So, as long as we are happy having the field names and sql columns have different cases, I can implement this.

mjhm commented 8 years ago

If we can keep the SQL column names and the JSON consistent that will be perfect. Whatever happens within Go is not exposed, so "when in Go, do as Go-nans" internally is fine.

allonsy commented 8 years ago

agreed