If you are using an interface-based design approach, how do you name the more behavioural interfaces?

Name the interface as a word or phrase correctly describing any class that implements it. "HasText" is a fine example as it describes the implementor (it has a Text property).

Name the interface as a word or phrase correctly describing any class that implements it. "HasText" is a fine example as it describes the implementor (it has a Text property). Make it specific to the interface."IsAnObject" or "MightHaveData" or "ExistsInCyberspace" is not specific to the interface.

Just an example, assume we have an imlplementation of a real wild animal, say a class Cat with some sensors and a big catalog of behaviours. Now the cat's eye-sensor reports "mouse! ".

The Cat will query it's Collection of Behaviour instances if there's a fit, iaw, if any of the stored Behaviour instances likes to take action. Assume we have an instance of class HuntMouse implements Behaviour stored in the list and this is the best fit, then the cat would call action() on that Behaviour and hunt the mouse. Back to your question - I think, one Behaviour interface with 2-3 methods would be enough, concrete Behaviour objects do not need a prefix or suffix.

And if needed, I suggest -Behaviour (like HuntMouseBehaviour) Initially you asked for Behaviours but your HasText example shows some kind of Feature. Where in this special case, TextProvider could be an a better choice while hasText is more suiteable. Implementing the interface adds the provide some text feature to the class.

Not as an answer to the question but for further reading: List of behavioural design patterns.(BTW - my example above was inspired by real implementations from the robotics area - even though a cat is not a robot ;)).

To be more precise, i'm trying to group common properties between some interfaces, I don't want to use command-like approach because specialized methods like getName() are more readable than get("name"). – Deniz Acay Jul 5 '10 at 9:23 Having a Behavior interface, collections of unknown behaviors, etc. Is fine if you have specific need for it, but isn't such need an exception, not the rule? Two advantages to using getName() instead of get("Name") are that getName gives you static typing (it returns a string, getDate() returns a DateTime, but get("propertyName") returns an object), and that strings (e.g. "Name") do not play well with refactoring tools--e.g. , if you want to change "Name" to "PersonName", you have to resort to find-and-replace.

– apollodude217 Jul 6 '10 at 21:57 @apollodude217 - the example that Deniz added yesterday, is not an interface for a Behaviour but more for a Feature. You wouldn't say something like: 'the class behaves like having a text', it's more like: 'the class has the provide-text feature'. And of course, one would not use inheritance for the main class, not 'a cat is-a behaviour' but 'a cat has-a behaviour'.

Only behaviours would implement a Behaviour interface. – Andreas_D Jul 7 '10 at 6:03 it is a good example of course, just not what I was looking for; but thanks for useful information, voting up... – Deniz Acay Jul 7 '10 at 12:36.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions