r/badcode • • Apr 07 '21

java Apparently Java can only handle 255 parameters in a constructor...

Post image
4.0k Upvotes

249 comments sorted by

View all comments

Show parent comment

133

u/bundabrg Apr 07 '21

I have one vendor who has a single column of 128 characters in a table. Just one column.

It's a hospital thing so patient number is characters 5-8, ward characters 10-13 etc with every char used.

It gets worse. The patient number got too large so.patient number is now characters 5-8, then append character 106 and character 119.

And there's lots more insanity like this. I swear when we got the documentation the person giving them to us sounded ashamed on the phone (not their fault, they inherited it).

63

u/SireBillyMays Apr 07 '21

So, wait. they have a database, where one of the tables is literally one field consisting of 128 chars, then they have subdivided that field into subfields?

Sounds like hell to work with right now, but honestly doesn't sound that hard to fix.

47

u/bundabrg Apr 07 '21

It gets worse (sorta). I have to use SOAP to interface with it :(

10

u/-IoI- Apr 07 '21

That fucking sucks, hopefully something like WCF or LINQ in the middle to ease the pain a bit

32

u/Lost4468 Apr 07 '21

So, wait. they have a database, where one of the tables is literally one field consisting of 128 chars, then they have subdivided that field into subfields?

It sounds like it was originally a paper implementation, in which case this sort of string representation can be incredibly efficient. If I give you a ton of drawers filled with patient details and tell you "find this patient", then if the records were assigned this sort of string, it would be very easy for you to narrow it down to a few records. I don't know how old the system is, but /u/bundabrg maybe it's because of this?

So then when they get digitised people don't want to move to a new system, or more likely you can't even change it because the hospital(s) are running two systems at once for a while. So you end up with weird data structures that make sense for paper records, but make no sense for computers.

Sounds like hell to work with right now, but honestly doesn't sound that hard to fix.

I don't know so again maybe /u/bundabrg could chime in. But one of the problems with this sort of thing is there's frequently literally hundreds of exceptions. Because it's a paper system over the years people have said e.g. "oh let's just start this one with 'OUTSIDE' since it comes from outside the country" or all sorts of weird similar exceptions. Well for 'OUTSIDE' it's easy to write an exception, but there's often so many of these exceptions, and no documentation, the people working there don't have a list of the exceptions they've made over the decades. And then once you end up with enough exceptions you realise there are plenty of ambiguous ones you can't possibly decide by writing basic if statements.

And it's medical as well, so you really don't want to risk mixing up records, violating HIPAA, not properly finding a record, etc. So you end up just being stuck with the stupid system. To fix it you need to go through everything manually and change it all out at once, which requires a fuck ton of time and money.

13

u/EvilPencil Apr 07 '21

Yeah, I think the fix would be to create a view that gives a more "normal" representation and yet doesn't create a second source of truth. Once all the consumers are interacting with the view instead of the underlying tabe, then do a migration and switch the inserts/updates over to the new schema.

6

u/HIPPAbot Apr 07 '21

It's HIPAA!

3

u/Lost4468 Apr 07 '21

Hungry hungry HIPAAs?

6

u/Tornadic_Outlaw Apr 07 '21

If it really is bad enough that you couldn't write code to fix it, then it isn't usable as is. Exceptions nobody knows about aren't exceptions, they are errors, and if a human tried to look at the data they would make the same mistakes the computer made.

And if you are that concerned about losing ambiguous information in the current filing method you could even keep that column for legacy data and not populate it for new records.

3

u/dakta Apr 07 '21

If it really is bad enough that you couldn't write code to fix it, then it isn't usable as is.

This is a great measure for software, or any system really. If it's so bad that you can't add a sane workaround interface on top, then it's not safe to use as-is and should be replaced ASAP.

1

u/Lost4468 Apr 07 '21

If it really is bad enough that you couldn't write code to fix it, then it isn't usable as is. Exceptions nobody knows about aren't exceptions, they are errors, and if a human tried to look at the data they would make the same mistakes the computer made.

There are plenty of situations where humans can read the exceptions and you can't write software to figure it out.

And if you are that concerned about losing ambiguous information in the current filing method you could even keep that column for legacy data and not populate it for new records.

So keep this 128 char column for legacy data, then start using something else from now on? What is the advantage then? You can't really use the new data, you're just going to have to compile it into the old form whenever it's needed.

You're just going to further fragment it if anything. You need to stop and go through and change it all, that's the way out of this mess.

3

u/Tornadic_Outlaw Apr 07 '21

There are plenty of situations where humans can read the exceptions and you can't write software to figure it out.

This is a 128 character code for storing data. If you have a code you are using to store information, you will need some sort of cipher to encode and decode it. This is just as true for a person as it is for a computer. The cipher may be an informal rule with some exceptions, but those exceptions must be known and recognizable in order for a person to figure them out. At this point a computer could be programmed to recognize and handle those exceptions.

The only condition in which this wouldn't be true is if the information necessary to recognize or handle the exceptions aren't included in the coded data. The former is fairly unlikely as it defeats the entire point of having the coded data, and would make it borderline impossible to use.

The later could be addressed by flagging those records for a human to fix, substantially decreasing the workload required to change over, especially if the fix can be delayed until the record is accessed for something.

So keep this 128 char column for legacy data, then start using something else from now on

Not quite. I was suggesting converting all of the existing data to the new system, and storing the old string for all legacy data. So a new record would only have data in the new format, while the old records will have it stored in both. This would allow you to use the old format to find something that was somehow lost in translation if you couldn't find it in the new system. It would require more storage, and as I stated before, I believe it is impossible for something to be stored in the old coded format in such a manner that it couldn't be converted to a new format.

3

u/Lost4468 Apr 07 '21

This is a 128 character code for storing data. If you have a code you are using to store information, you will need some sort of cipher to encode and decode it. This is just as true for a person as it is for a computer. The cipher may be an informal rule with some exceptions, but those exceptions must be known and recognizable in order for a person to figure them out. At this point a computer could be programmed to recognize and handle those exceptions.

The only condition in which this wouldn't be true is if the information necessary to recognize or handle the exceptions aren't included in the coded data. The former is fairly unlikely as it defeats the entire point of having the coded data, and would make it borderline impossible to use.

Sorry but it's not this easy, or anywhere near it. Context matters, and you can't program that in with if else statements, basic logic, lookup tables, etc. It's the exact same reason computer translation is still so poor, you could use this exact argument to say that it should be easy to make a computer that can translate languages well. But it isn't. Can computers do it? Yes. Do we know how to program them to do it? No not yet.

The later could be addressed by flagging those records for a human to fix, substantially decreasing the workload required to change over, especially if the fix can be delayed until the record is accessed for something.

This simply can't be done in medical fields. There is a huge amount of security around it, you would get in huge amounts of trouble if one persons records weren't served up and then they had an allergic reaction or something because of it, or if someone elses records were served up instead.

Also I'm not sure you realise just how large these databases can be. First you're absolutely not going to be passing this job onto medical staff to do, so don't even think about it. So what do you do? Flag them up then check them each day? Now you run into all sorts of other problems from way too many records to handle, to this person's data is being actively processed and if you change it while someone is still accessing the previous record or similar, you could have serious real world impacts. And again there's a good chance as a developer you won't be able to properly formulate all the exceptions, and good luck getting access to the correct medical staff in a timely manor that prevents it all piling up.

I have dealt with this exact problem before and with government data (but not medical). The first factor was the same as above, it's ambiguous and you can't possibly write software by hand to figure out the rules, but a human could figure them out instantly. And also because of legislation around the matter, you seriously can't change it unless you can guarantee you will not lose anything or risk changing anything.

Not quite. I was suggesting converting all of the existing data to the new system, and storing the old string for all legacy data. So a new record would only have data in the new format, while the old records will have it stored in both. This would allow you to use the old format to find something that was somehow lost in translation if you couldn't find it in the new system. It would require more storage, and as I stated before, I believe it is impossible for something to be stored in the old coded format in such a manner that it couldn't be converted to a new format.

Yeah but chances are this is going to require such a huge amount of change to other systems, how staff operate, etc etc.

It might be fixable like you're saying, I'm not suggesting I know it's not. I'm just saying there's a very good chance it can't be fixed easily. Generally these sort of problems look easy and you say "why on earth are they doing this...", but when you look at the actual complexities of the system it becomes clear why they can't change it.

9

u/shh_coffee Apr 07 '21 edited Apr 07 '21

Sounds like it may be getting populated by a COBOL system where they're not dividing the patient record by it's fields when writing to the DB and they're just sending the whole patient record as one DB field. That would also explain the weird patient number append as in COBOL fields have fixed length and that sounds like someone just went "we can add another number by adding a field at the end of the record called ws-patient-num-append" or something so not to mess with the existing field lengths.

Just taking a wild guess though.

7

u/fakehalo Apr 07 '21

I wonder if this is the result of a migration from ancient times where they needed the original "database" structure for some portion of their codebase, which is likely no longer around.

Reminds me of things I've seen from decades ago.

1

u/[deleted] Apr 07 '21

I remember one team at my current job saying they were going to migrate some data as part of some feature they were delivering (believe it was being moved to new tables) but were going to keep the original data/ columns around to reduce the need/ risk for additional data migration. Sigh.

6

u/slower-is-faster Apr 07 '21

I worked for an insurance company that had an oracle database they paid a lot of money for. Their apps “document”, was stored as encrypted XML in a table with just one column - this was what they used oracle for.

1

u/WhenSharksCollide Apr 09 '21

This physically hurts to read.