interface

In Delphi is it possible to bind an interface to an object that doesn't implement it

六眼飞鱼酱① 提交于 2019-12-09 09:18:26
问题 I know Delphi XE2 has the new TVirtualInterface for creating implementations of an interface at runtime. Unfortunately I am not using XE2 and I'm wondering what kind of hackery is involved in doing this sort of thing in older versions of Delphi. Lets say I have the following interface: IMyInterface = interface ['{8A827997-0058-4756-B02D-8DCDD32B7607}'] procedure Go; end; Is it possible to bind to this interface at runtime without the help of the compiler? TMyClass = class(TObject, IInterface)

Delphi plugin framework

妖精的绣舞 提交于 2019-12-09 09:18:23
问题 I want to design Delphi plugin framework. There are three options: 1. DLL 2. BPL 3. COM interface Every option has some disadvantage. DLL - Promblem with MDI apllication, forms from plugin cannot be embeded to the host exe - mdi application. BPL - Every *.bpl plugin and *.exe host application must be compiled with the same version of Delphi. COM - Interfaces {xxx-xx-xxx-xx} must be registered in system, (regsvr) So plugin framework cannot be portable! Is everything true what I wrote above? If

Interface without any members - bad practice? [duplicate]

你离开我真会死。 提交于 2019-12-09 07:46:38
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: What is the purpose of a marker interface? Is it bad practice to create a completely empty interface such as: public interface ISomething { } There is a case where I would like to treat certain objects differently than others, but I don't require any new behavior. 回答1: I personally think that empty interfaces are not a good thing. Interfaces are meant to describe behavioral contracts. An empty interface doesn't

Is there an idiom in Java for empty methods which exist to satisfy an interface?

纵然是瞬间 提交于 2019-12-09 07:38:13
问题 Let's say I have a class Foo implementing an interface such as MouseListener . The MouseListener interface consists of five methods but I only wish to override one of them ( mouseClicked() ). Is there a standard, idiomatic way of formatting the other methods? My inclination was to write the following: @Override public void mouseClicked(MouseEvent e) { // (...) <-- actual code here } @Override public void mouseEntered(MouseEvent e) { // Do nothing. Exists to satisfy MouseListener interface. }

Do PHP interfaces have properties?

蓝咒 提交于 2019-12-09 07:20:47
问题 Do interfaces in PHP have properties, or do they only have methods? 回答1: It depends what you mean by "properties". If you mean actual fields, then no, they don't. If you're referring to properties such as those in C#, then yes they can (since the property accessors are strictly syntactic sugar for accessor methods anyway). The same goes for events (though of course, in each case, no implementation is specified for the get / set or add / remove accessors). Update : Since PHP does not have

Interface Inheritance in C++

岁酱吖の 提交于 2019-12-09 05:09:05
问题 I have the following class structure: class InterfaceA { virtual void methodA =0; } class ClassA : public InterfaceA { void methodA(); } class InterfaceB : public InterfaceA { virtual void methodB =0; } class ClassAB : public ClassA, public InterfaceB { void methodB(); } Now the following code is not compilable: int main() { InterfaceB* test = new ClassAB(); test->methodA(); } The compiler says that the method methodA() is virtual and not implemented. I thought that it is implemented in

VB.NET Interfaces

回眸只為那壹抹淺笑 提交于 2019-12-09 05:00:10
问题 I am not quite clear as to why or when to use Interfaces. Can someone post a complete, simple and small example of an Interface using VB.NET in a Console Application. How is it extensible? 回答1: In short: Favor Composition over Inheritance Interfaces are simply a common set of member definitions that you want one or more classes to support. The key is that you have to provide the functionality explicitly when you implement an interface. You can achieve similar results using inheritance since

How to separate interface from implementation in Grails services?

家住魔仙堡 提交于 2019-12-09 04:39:04
问题 I was wondering if it's possible to create a service interface on Grails and I can't find a proper way of doing it. This explanation isn't satisfactory, since it seems to mix Java and Groovy: http://www.grails.org/doc/latest/guide/8.%20The%20Service%20Layer.html It seems to me like a bad design flaw of the framework, given that the interface mechanism is one of the best features of Java (and most OO languages). Any idea to clarify this issue? Thanks! Mulone 回答1: You can have an interface, but

Where do you keep Constants used throughout your application?

左心房为你撑大大i 提交于 2019-12-09 04:37:11
问题 Is interface an acceptable place to store my public static final Foo bar Do you extrapolate them to be read from outside of the program? Do you make up a super class for it? How do you do it, when situation presents itself? 回答1: I'd put each constant into the class or interface it's most closely related to (e.g. because it will be use by its methods). A very seductive but ultimately very foolish idea is to have one "constants class" (or interface) that contains all constants used in the

How to define interfaces in Dart?

。_饼干妹妹 提交于 2019-12-09 04:30:39
问题 In Java, I might have an interface IsSilly and one or more concrete types that implement it: public interface IsSilly { public void makePeopleLaugh(); } public class Clown implements IsSilly { @Override public void makePeopleLaugh() { // Here is where the magic happens } } public class Comedian implements IsSilly { @Override public void makePeopleLaugh() { // Here is where the magic happens } } What's the equivalent to this code in Dart? After perusing the official docs on classes, it doesn't