COBOL never died. It just migrated to databases. Look at this shit.
CREATE TRIGGER check_book_pages
AFTER INSERT ON chapter
FOR EACH ROW
BEGIN
DECLARE total_pages INTEGER;
DECLARE new_pages INTEGER;
IF @new_pages > @total_pages THEN
SIGNAL SQLSTATE '45000'
END IF;
END ^;
A book has a maximum number of pages? In the database? What? If a programmer can see something is invalid then the constraint belongs in the database. That's the best place for it. You suck it up and you write that COBOL. But if only a manager can say something is invalid? Those constraints should go in a domain model somewhere. He's going to change his mind.
1 comment
0 u/ScionOfZion 21 Apr 2020 15:07
COBOL never died. It just migrated to databases. Look at this shit.
A book has a maximum number of pages? In the database? What? If a programmer can see something is invalid then the constraint belongs in the database. That's the best place for it. You suck it up and you write that COBOL. But if only a manager can say something is invalid? Those constraints should go in a domain model somewhere. He's going to change his mind.