Why we need multiple address variable declaration for Location Class

Hi,

I just went through the OpenMRS-Core code repository. While referring the code, I couldn’t understand the reason for multiple address variable declaration in the Location Class. I thought, it might be a mistake or issue. So I would like to get some idea about this one.

Location Class : https://github.com/openmrs/openmrs-core/blob/f176a41519fbaec8eb4142a70c272c96f5df8fda/api/src/main/java/org/openmrs/Location.java

Location class have address1 to address15 (altogether 15 variables) for the address assignment and it have 15 get methods and 15 set methods itself. I wonder why this class does not use a string array for this reason. If we use a string array, then we can simply manage multiple address though the index.

Example :

String[] address = new address[15]

public void setAddress (int index, string address) {
this.address[index] = address;
}

I believe, there might be a valid technical reason for this implementation. Could some one explain me the actual idea behind this one?

Thanks.

1 Like

Very good point that I also came across and did not know why exactly. I assume it might be that we didnt want to create a separate table, so we could avoid the join. Since the majority of people might not have many addresses it would be “easier/quicker” to just take the data out of the same table.

But am not sure and would also be interested in the why :slight_smile:

2 Likes

These are not for storing multiple address, but rather for storing multiple configurable structured fields for a single address. E.g. addresses look different in the US, Germany, India, and Kenya.

There are also some fields with more explicit meaning (e.g. city_village) but we have a bunch of general-purpose fields to provide “more than enough” configurability.

See this for more info: https://wiki.openmrs.org/x/OgTX

2 Likes

Thanks @darius and @teleivo for the instructions. I got some great points over there.