1 comment

0

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.