﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>David Cuccia commented on What is wrong with this API?</title><description>(Or the method name should be TryVeto)
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment43</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment43</guid><pubDate>Sat, 13 Nov 2010 21:07:23 GMT</pubDate></item><item><title>David Cuccia commented on What is wrong with this API?</title><description>The method doesn't make sense - if the caller has already decided to veto the message, why would it call a method just to get a boolean back to say that it was vetoed (or not).
  
  
Instead, the return type should be void and the default implementation should either do nothing or *actually veto* the message.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment42</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment42</guid><pubDate>Sat, 13 Nov 2010 00:29:27 GMT</pubDate></item><item><title>Kevin L commented on What is wrong with this API?</title><description>On the surface, this method looks fine, but a descendant class being allowed to override the method creates a grammatical ambiguity:
  
  
public bool override VetoMessage(,,,) {...}
  
  
By definition a veto cannot be over-ridden.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment41</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment41</guid><pubDate>Fri, 12 Nov 2010 23:08:44 GMT</pubDate></item><item><title>Michael D. commented on What is wrong with this API?</title><description>Inability to chain filters that can prevent from the message from being sent?
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment40</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment40</guid><pubDate>Fri, 12 Nov 2010 19:21:52 GMT</pubDate></item><item><title>Sony Mathew commented on What is wrong with this API?</title><description>There is nothing technically wrong with this API. However, it would be better if this API were exposed via a modified Observer pattern.
  
  
E.g. 
  
addVetoAuthority(VetoAuthority v)
  
  
where:
  
  
interface VetoAuthority {
  
  boolean isVetoed(IncomingMessage m);
  
}
  
  
Sony
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment39</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment39</guid><pubDate>Fri, 12 Nov 2010 18:38:23 GMT</pubDate></item><item><title>Jackknife commented on What is wrong with this API?</title><description>Disencourages ask - don't tell?
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment38</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment38</guid><pubDate>Fri, 12 Nov 2010 18:23:43 GMT</pubDate></item><item><title>lowds commented on What is wrong with this API?</title><description>Whether an incoming message has been vetoed or not represents a state of the message and this state would ideally be a property on the message itself.
  
  
Having a method on the IncomingMessage class that takes a list of extensions would solve this, something like:
  
  
message.AssertVeto(extensions);
  
  
(or what ever a better name for AssertVeto would be)
  
  
This would let the message track it's own state and then implement any additional logic required rather than have this in a seperate controller-like class.  Any other class can then query the state of the message rather than pass around a boolean.
  
  
Equally if you wanted to have a message that cannot be vetoed you can create a subclass of IncomingMessage and override the AssertVeto implementation.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment37</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment37</guid><pubDate>Fri, 12 Nov 2010 17:22:43 GMT</pubDate></item><item><title>Tom commented on What is wrong with this API?</title><description>Should return an int or enum for greater flexability
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment36</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment36</guid><pubDate>Fri, 12 Nov 2010 16:11:39 GMT</pubDate></item><item><title>Richard Dingwall commented on What is wrong with this API?</title><description>If there are multiple extensions each with this method, which one do you listen to?
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment35</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment35</guid><pubDate>Fri, 12 Nov 2010 15:26:16 GMT</pubDate></item><item><title>jonnii commented on What is wrong with this API?</title><description>One more thing, this is very similar to what Mike suggested, but I prefer returning the result instead of putting it in a context because that way you can write:
  
  
if(foo.VetoMessage(m).IsVetoed){...}
  
  
instead of 
  
  
var context = ..,;
  
foo.VetoMessage(m, context);
  
if(context.IsVetoed()){...}
  
  
And it means you can make the response immutable, another win for SCIENCE!
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment34</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment34</guid><pubDate>Fri, 12 Nov 2010 15:07:41 GMT</pubDate></item><item><title>jonnii commented on What is wrong with this API?</title><description>I know this has already been said but I believe that the reason is because it doesn't give the end user enough discovery as to why the message was vetoed.
  
  
I'd rather have something like (forgive the crappy names):
  
  
public virtual MessageVeto VetoMessage(IncomingMessage message){
  
   return MessageVeto.MessageOk;
  
}
  
  
where MessageVeto is something like:
  
  
class VetoMessage{ 
  
    static VetoMessage Ok(){...}
  
     string Reason { get; set; }
  
     bool IsVetoed { get { !string.IsNullOrEmpty(Reason); } }
  
}
  
  
This means if you're using the API for the first time and you're wondering why your messages are being vetoed you can look at the reason and make the change.
  
  
The other option is that you can have an enum as the return type which gives you more indication as to why the message was vetoed if there are classifications, which means you don't want to add another class, that's still more discoverable than a boolean and gives you options to add more reasons later without, hopefully, breaking the API.
  
  
If you absolutely must return a boolean for some reason you could add an event that gets raised when a message is vetoed with a reason.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment33</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment33</guid><pubDate>Fri, 12 Nov 2010 15:05:52 GMT</pubDate></item><item><title>Jason Meckley commented on What is wrong with this API?</title><description>My first thought was the context is missing. And I still think that is the number 1 problem with the method. After reading the comments I agree that the name of the message should  be changed to ShouldVetoMessage.
  
  
VetoMessage sounds like this will veto, not whether is should veto.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment32</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment32</guid><pubDate>Fri, 12 Nov 2010 14:13:28 GMT</pubDate></item><item><title>WishCow commented on What is wrong with this API?</title><description>The method's name is misleading, because VetoMessage(message) leads you to believe that you pass a message that you want to veto, but the doc comment states that the method will only decide if the message is vetoed, or not, and does not mark a message as vetoed.
  
  
The method should be renamed to isVetoed(message).
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment31</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment31</guid><pubDate>Fri, 12 Nov 2010 13:53:54 GMT</pubDate></item><item><title>Brian Frantz commented on What is wrong with this API?</title><description>Should be a protected method - meant for internal logic, not for the end-user of the class.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment30</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment30</guid><pubDate>Fri, 12 Nov 2010 13:43:11 GMT</pubDate></item><item><title>Trey commented on What is wrong with this API?</title><description>The fact that the method is public seems to imply that the decision to veto can be bypassed (i.e. - It seems to be the responsibility of the caller to choose whether or not to evaluate the possibility of vetoing the message).
  
  
The exact context and responsibility of the example itself is unclear to me (is the method intended to actually perform the logic for vetoing the message, or simply decide whether or not the message should be vetoed.....what is the overall responsibility of the base class, etc.), so the decision to make this public could very well be by design.  Just my humble two cents.  :)
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment29</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment29</guid><pubDate>Fri, 12 Nov 2010 13:29:10 GMT</pubDate></item><item><title>Mike Minutillo commented on What is wrong with this API?</title><description>Callers will (potentially) be able to tell who vetoed a message but not why (unless you have some very fine grained message checkers). It would be better to have something like:
  
  
public virtual void VetoMessage(IncomingMessage message, VetoContext context) {
  
  if( someCondition ) {
  
    context.VetoMessage(someReason);
  
  }
  
}
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment28</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment28</guid><pubDate>Fri, 12 Nov 2010 12:47:22 GMT</pubDate></item><item><title>Andrey Shchekin commented on What is wrong with this API?</title><description>It does not allow to specify a reason?
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment27</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment27</guid><pubDate>Fri, 12 Nov 2010 12:41:40 GMT</pubDate></item><item><title>Adam B commented on What is wrong with this API?</title><description>Violates Open/Closed principal? Looks open for modification.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment26</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment26</guid><pubDate>Fri, 12 Nov 2010 12:36:47 GMT</pubDate></item><item><title>Nick commented on What is wrong with this API?</title><description>I think the comment does not make sense. 
  
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment25</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment25</guid><pubDate>Fri, 12 Nov 2010 12:29:02 GMT</pubDate></item><item><title>Dan Plaskon commented on What is wrong with this API?</title><description>@Koen: Couldn't that be prevented by sealing the class though?
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment24</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment24</guid><pubDate>Fri, 12 Nov 2010 12:05:33 GMT</pubDate></item><item><title>Dan Plaskon commented on What is wrong with this API?</title><description>I think Andrew's on the right track..I think more context would be helpful here...eg how is VetoMessage called/used for these plugins by the infrastructure?
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment23</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment23</guid><pubDate>Fri, 12 Nov 2010 12:02:38 GMT</pubDate></item><item><title>Koen commented on What is wrong with this API?</title><description>Veto-ing is about overruling in a hierarchical system. A concrete class can inherit the base class and execute logic to decide if a message is blocked as some sort of superior.
  
  
However, you can inherit from that class again, override the method again and at the same time overrule your "superior". I guess that's a flaw...
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment22</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment22</guid><pubDate>Fri, 12 Nov 2010 12:02:00 GMT</pubDate></item><item><title>wouzer commented on What is wrong with this API?</title><description>Maybe you are missing the context to base the decision on?
  
  
public virtual bool VetoMessage(QueueContext context, IncomingMessage message)
  
{
  
return true;
  
}
  
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment21</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment21</guid><pubDate>Fri, 12 Nov 2010 12:01:42 GMT</pubDate></item><item><title>Andrew commented on What is wrong with this API?</title><description>There's no way to explicitly allow a message (and prevent a veto)?
  
  
You may want a VetoResult { Permit, Deny, Ignored } result instead so that an extension can explicitly permit or deny the message from being propagated; or decide to have no action on the message (Ignored).
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment20</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment20</guid><pubDate>Fri, 12 Nov 2010 11:57:19 GMT</pubDate></item><item><title>Oleg commented on What is wrong with this API?</title><description>We cannot tell by looking at signature what exactly it's return value refers to?
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment19</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment19</guid><pubDate>Fri, 12 Nov 2010 11:53:20 GMT</pubDate></item><item><title>Stefan Wenig commented on What is wrong with this API?</title><description>mind to give some context? the problem might be that you need to derive from some (what?) base class only to get to veto - and then maybe someone else derives too and now you got two competing implementations? might be better to enlist everyone whoi might need to veto, maybe using cancelable events.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment18</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment18</guid><pubDate>Fri, 12 Nov 2010 11:52:10 GMT</pubDate></item><item><title>alwin commented on What is wrong with this API?</title><description>Well for me it's not clear if true means that this message is passed or denied.
  
  
Maybe this would be better?
  
public virtual bool AllowMessage(IncomingMessage message){
  
   return true;
  
}
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment17</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment17</guid><pubDate>Fri, 12 Nov 2010 11:36:43 GMT</pubDate></item><item><title>Sean Kearon commented on What is wrong with this API?</title><description>Usually you will accept the message, so the default should return false and let specialisms do the vetoing.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment16</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment16</guid><pubDate>Fri, 12 Nov 2010 11:33:19 GMT</pubDate></item><item><title>Evgeny Shapiro commented on What is wrong with this API?</title><description>Why should one subclass? Interceptor might be a more appropriate solution.
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment15</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment15</guid><pubDate>Fri, 12 Nov 2010 11:30:58 GMT</pubDate></item><item><title>Ayende Rahien commented on What is wrong with this API?</title><description>  
Rik,
  
This is the default impl, sub classes can choose to override this method or not.
  
The XML comment grammer is pretty much the standard for me, I am afraid, that isn't what I meant.
  
And the problem isn't in the method name either
</description><link>http://ayende.com/4689/what-is-wrong-with-this-api#comment14</link><guid>http://ayende.com/4689/what-is-wrong-with-this-api#comment14</guid><pubDate>Fri, 12 Nov 2010 11:20:03 GMT</pubDate></item></channel></rss>