Using interfaces is a very easy way to remove dependencies, but what happens when one of your classes needs a method not defined by the interface? If you're using constructor injection or a factory, how do you access that extra method without casting? Is this possible?
Here is an example of a factory with this problem. Am I trying to do...
I'm getting my feet wet with DI/IoC and MEF in particular.
I have a web application that has two types of parts (maybe more someday) defined by interfaces which need access to the whole environment. The application has a list with concrete implementations for each type, composed by MEF.
The environment consists of:
several repositori...
I want to write a simple class (PHP5) that can 'run' an unknown amount of subclasses. These subclasses are best translated as 'checks'; they all will more or less do the same thing and give an answer (true / false). Think of it as system startup checks.
Over time new checks (subclasses) will be added to a directory and they should autom...
I just started figuring out the difference between implicit and explicit interface implmentation in .Net. Since I come from a Java background the idea is still a bit confusing. I am hoping knowing which Java does will make it more obvious what the difference is. I am assuming the Java is explicit???
...
I want to create an implementation of the IDictionary(Of TKey, TValue) interface to provide some wrapper functionality.
Public Class ExtendedDictionary(Of TKey, TValue)
Implements IDictionary(Of TKey, TValue)
Private _Dictionary As Dictionary(Of TKey, TValue)
Public Sub Add(ByVal key As TKey, ByVal value As T) Implements I...
First, an example of something that works as expected: (all code was executed in VS2008 immediate window)
25 is IComparable
>> true
25.GetType().GetInterfaces()
>> {System.Type[5]}
>> [0]: {Name = "IComparable" FullName = ...
>> [1]: {Name = "IFormattable" FullName = ...
>> ...
So far so good. Now let's try on an object where t...
I'm writing a game engine in Java for a two player card game for which my students are going to write AI players.
The AI players will take turns playing cards onto their 'field' a part of the 'table' in front of them. They can attack with a card from their field a card in the other player's field. Cards may be face up or face down.
T...
I'm refactoring all my repository interfaces of various types. Most of them contain very similar methods like Add, Update but some have methods which only makes sense for a specific type. This is a best practices question.
I thought about using generics to straighten things up.
public interface IRepository<T>
{
T Get(int id);
...
I am trying to generate a new set of wcf interfaces based on existing interfaces.
I am using the Reflection.Emit namespace to accomplish this. My problem is how to copy the old custom attributes from one method to the new method. Every example I have seen of SetCustomAttributes() requires knowing the attribute type beforehand. I need ...
I'm implementing a set of classes and corresponding interfaces where I want each class to have a set of common properties and a set of specialised properties that are specific only to that class. So, I'm considering defining interfaces along the lines of:
interface ICommon {...} // Members common to all widgets
interface IWidget1 {...}...
Well I was going to ask what the difference is but it's been answered before. But now I'm asking why did they make these differences? (I'm speaking about java here, I don't know if the same applies to other languages)
The two things seem very similar. Abstract classes can define a method body whilst interfaces can't, but multiple interf...
Since I started to develop in a test/behavior driven style, I appreciated the ability to mock out every dependency.
Since mocking frameworks like Moq work best when told to mock an interface, I now implement an interface for almost every class I create b/c most likely I will have to mock it out in a test eventually.
Well, and programmin...
If we have a class that inherits from multiple interfaces, and the interfaces have methods with the same name, how can we implement these methods in my class? How we can specify that which method of which interface is implemented?
...
It seems to me that both interface and abstract public function are quite similar,
it's like an order that some method must be implemented,
so what's the difference?
...
Hi there, I have a clue about Object Oriented Programming:
I need to have a parent class HandlerException which needs to define the sign of three methods (MethodA, MethodB, MethodC).
Then, I have a child class BusinessHandler which inherits from HandlerException and defines ONLY the MethodA of its parent class.
Then, I have a child c...
I am a C# programmer but I have to work with some VB.Net code and I came across a situation where I have two methods on an interface with the same name but different method parameters. When I attempt to implement this interface in a class, VB.Net requires explicitly declaring "Implements MethodName" after the method signature. Since both...
I'm trying to define a GUI layout using XML files in Android. As far as I can find out, there is no way to specify that your widgets should use a custom font (e.g. one you've placed in assets/font/) in XML files and you can only use the system installed fonts.
I know that, in the Java code, I could change the font of each widget manuall...
I want to be able to apply an attribute to an interface so that every method in any class that implements that interface will have the attribute applied to it.
I assumed it would look something like this:
[Serializable]
[AttributeUsage(AttributeTargets.All, Inherited = true)]
public sealed class TestAttribute : OnMethodBoundaryAspect
{...
I'm going to need to write a program that takes a list of persons and connects them together in a directed-graph-like manner. The GUI aspect of the whole project is very important. The graph must allow a lot of interaction. Such as selecting several people and hiding the others, moving them around.
Additionally, the software will need t...
Question: I'm trying out to convert this here:
http://support.microsoft.com/kb/828736
to VB.net
I got it to work in C#, and it should work without problems in VB.net, the only problem is the managed class won't compile, i get this error:
Error Class "ManagedClass" has to implement "Function Add(Number1 As Integer, Number2 As Integer) As...