I'm struggling with logic that is duplicated in the front end code and the database. Right now, I just put a comment.
Here is a small example (the current system has a lot of much more complicated formulas).
In the front end, I have a single property that everything use to see the result.
Class CartItem
' The same formula is found in the database view V_CART_ITEM
Public Readonly Property Cost As Decimal
Get
Return Price * Amount
End Get
End Property
End Class
In the database, I have a view that all queries and report use.
CREATE OR REPLACE VIEW V_CART_ITEM AS
-- The cost formula is also found in the class CartItem
select cart_item_id, price * amount as cost
from cart_item;
I think it's not to bad since the formula is only duplicated once in the whole system and a new developer would know what to do if there are any changes to be made. I'm wondering if there's a better way.