Hi. In my code I use a small data-storing class, which is created in different places. To avoid memory leaks and simplify things, I want to use reference counting, so I did
type TFileInfo = class (TInterfacedObject, IInterface)
and removed all my manual calls to TFileInfo.Free. Unfortunately Delphi reported a lot of memory leaks. Sear...
In C#, it's common to have methods like this:
public IPerson GetPerson()
{
// do stuff
return new Person(..);
}
where "IPerson" is an interface used by Person, SpecialPerson, etc. In other words, although the method above returns a Person, a strategy pattern could be implemented such that a SpecialPerson is returned in lieu of a P...
Is an interface + extension methods (mixin) preferable to an abstract class?
If your answer is "it depends", what does it depend upon?
I see two possible advantages to the interface + extension approach.
Interfaces are multiply inheritable and classes are not.
You can use extension methods to extend interfaces in a non-breaking way. ...
In C#, if a class has all the correct methods/signatures for an Interface, but doesn't explicitly implement it like:
class foo : IDoo {}
Can the class still be cast as that interface?
...
I want to build simple console applications, but want something like QT and not like ncurses. Is there such a thing or is it only my dream UI?
...
My java skills are limiting me from doing what I want to do.
I am trying to use the Interactive Brokers Java API to see if I can do some algorithmic trading (on paper initially). I want to call a method called ReqMktDepth() which is in a class called EClientSocket.
The EClientSocket constructor requires an object of type AnyWrapper to ...
I have this C# code:
abstract class MyList : IEnumerable<T>
{
public abstract IEnumerator<T> GetEnumerator();
//abstract IEnumerator IEnumerable.GetEnumerator();
}
As is, I get:
'Type' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'.
remove the comment and I get:
The modifier 'a...
Let's say I write a really kick-ass interface. So kick-ass, in fact, that I'd like some of the builtin types I use to implement them, so that whatever code I write that uses this interface can also use the builtin types.
public interface IKickAss
{
int Yeahhhhhhh() { get; }
}
public static class Woot
{
public int Bar(IKickAss a...
Consider two .net dlls. The first, "application.dll" contains the main business logic and data access code. The second, "webservice.dll" consists mostly of WebMethods that link to objects and methods with application.dll for the purpose of providing webservice calls to existing code.
What changes (e.g. add new classes, add a new field o...
If I have
class B : A {}
I say that "Class B inherited class A" or "class B derives from class A".
However, if I instead have:
class B : ISomeInterface {}
it's wrong to say "B inherits ISomeInterface" -- the proper term is to say "B implements ISomeInterface".
But, say I have
interface ISomeInterface : ISomeOtherInt...
Maybe I'm dumb but ...
I have:
public interface IRequest
{
IList<IRequestDetail> Details { get; set; }
// stuff
}
public interface IRequestDetail
{
// stuff
}
I then have:
public class MyRequest : IRequest
{
IList<MyRequestDetail> Details {get; set; }
// stuff
}
public class MyRequestDetail : IRequestDetail
{...
I'm not really sure how to ask this question. Suppose I have a class that needs to access certain properties of a Control (for example, Visible and Location). Perhaps I want to use the same class to access properties of another item that have the same name, but the class might not derive from Control. So I tried making an interface:
...
Is there any opensource samples of JQuery usages of StackOverFlow-like sites......
Any help in this direction??
...
I want to define an interface MyList which is a list of interface MyThing. Part of the semantics of MyList is that its operations don't have any meaning on objects which do not implement the MyThing interface.
Is this the right declaration?
interface MyList<E extends MyThing> extends List<E> { ... }
edit: (part 2) Now I have another...
I have 2 interfaces IA and IB.
public interface IA
{
IB InterfaceB { get; set; }
}
public interface IB
{
IA InterfaceA { get; set; }
void SetIA(IA value);
}
Each interfaces references the other.
I am trying to serialize ClassA as defined below.
[Serializable]
public class ClassA : IA
{
public IB InterfaceB { ge...
interface I { int J(); }
class A : I
{
public int J(){return 0; } // note NOT virtual (and I can't change this)
}
class B : A, I
{
new public int J(){return 1; }
}
B b = new B();
A a = b;
I ib = b, ia = a;
b.J(); // should give 1
a.J(); // should give 0 (IMHO)
ia.J(); // ???
ib.J(); // ???
I know I could just try it but I...
Suppose I'm implementing an MVP pattern and I have a view interface as such:
interface IView {
string SuperRadString { set; }
}
There's no reason for the presenter to ever need to retrieve this string from the view, so can I safely ignore this error?
...
hi.
i have two classes which have some common methods like
funcA(), funcB()
and some methods are only related to its class...
what i did is made interface of TestInterface
public interface TestInterface
{
void funcA()
void funcB()
}
public class ClassA : TestInterface
{
public void funcA()
{
Console.WriteLine("This...
Basically I wanna know if all the types in a particular namespace implements a particular interface like IEnumerable.
I know I can do:
foreach type ...
if type is IEnumerable
...
But I don't wanna cast the type just to query if it implements an interface, because the cast will be thrown away either way.
...
One thing I see in some DDD enterprise apps that I work on, is the use of interfaces that are identical to the domain entities, with a one-to-one mapping of properties and functions. Indeed a domain object is always used through it's one-to-one interface, and all domain entities have a one-to-one interface in this style.
For example:
...