37
Root
6y

Legacy code.

Honestly though, this is some of the better legacy code I've worked with at this company. It's a nifty alert system wherein you can trigger sending messages to subscribers of that alert via whatever means (phone/email) they've entered.

I'll save you the technical analysis of its internals, but suffice to say it's actually pretty nice, with good separation of concerns, internal logic hidden away, dead-simple public interface, etc. documentation is kinda crap, but it exists (!), so that's a nice change.

but.

For some unknown and bloody bizarre reason, the thing breaks when a user wants both sms AND email notifications. Either by themselves work totally fine, but both together? nonono. Email alerts give ArgumentErrors, so something internal isn't correct, and SMS alerts complain about uninitialized Twilio::Error constants.

but.
they both work fine otherwise?

also, the two notification preferences aren't stored on the same object anywhere. if a user wants both, the user creates two AlertContact objects with different info, and when performed, the Alert basically iterates over these and does its thing for each, so there is no knowledge shared between them. totally should work the same regardless.

idfgi.

ALSO.
AND THIS PART REALLY PISSES ME OFF.

WHEN THERE'S AN ERROR, THIS THING DOESN'T LOG IT. IT STRINGIFIES THE ERROR OBJECT (basically just extracting the message) AND INSERTS THAT INTO THE DATABASE INSTEAD. WHAT THE CRAP.

So, I don't get a stack trace, line number, or anything. just the basic error message. instead of my alert text. because of course that makes sense and totally helps debugging.

aklsjfak;sldfj.
legacy code.

Comments
  • 16
    That second part is like.

    You go to get your photo taken for the yearbook. The photographer tries taking your picture, but realizes s/he is out of film/storage/fucks. Instead of telling you to come back later, s/he pretends to take your photo, says everything's peachy, and sends you on your way. Afterward, they write down on a sticky note that they're out of whatever it is as a reminder.

    But.

    Come the end of the year, you purchase your yearbook for $60 or whatever, flip to where your photo should be, and find in its place is A PHOTO OF THAT GODDAMN STICKY NOTE.

    ADFAKLSDFJSDLK.
  • 2
    1. That’s absolute bullshit, wtf.

    2. That is an amazing analogy.
  • 2
    @OneOrZero Still? I've only encountered this issue today.
  • 4
    Update:

    If the alert message generation crashes for any reason, the thing silently replaces the message with just the alert's name. No logs, nothing to diagnose with. Sends as normal, just without any data. Yay!
  • 0
    Maybe you can create a base class containing the 2 AlertContact classes? Apart from all the work this implies, it won't change anything when the problem lies in shared dependencies, like @ArcaneEye said.
Add Comment