Answer the question
In order to leave comments, you need to log in
Why does an invariant violation indicate a vendor error?
Who knows the terminology of the client, supplier and invariant in contract programming, the question is for you.
Argument your opinion on the account of who is guilty of the violation and why do you think so?
Answer the question
In order to leave comments, you need to log in
I take the first link to Wikipedia https://ru.wikipedia.org/wiki/%D0%9A%D0%BE%D0%BD%D...
about the quote invariant
The main idea of contract programming is a model of interaction between the elements of a software system, based on the idea of mutual obligations and benefits ... obligations to fulfill specific properties - invariants that must be fulfilled when a message is received by the supplier, as well as when the method exits.
EmailSender
{
BlockingQueue<MessageToSend> queue;
public void addToQueue(String text, String targetEmail)
{
validateText(text); // реализация опущена - предусловие входного параметра
validateEmail(targetEmail);// реализация опущена - предусловие входного параметра
lock(queue)
{
queue.add(new MessageToSend(text, targetEmail));
}
// инвариант - в очередь добавлено сообщение (если предусловия пройдены)
}
// периодическая отправка по таймеру (вызов опущен)
private void sendByTick()
{
lock(queue)
{
// отправить все из queue
queue.clear();
}
// инвариант 1 - после вызова queue стал пуст
// инвариант 2 - если во время вызова sendByTick были попытки добавить с помощью addToQueue то они не потеряются (за счет lock)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question