interface

Delphi: keystroke or IDE option to populate interface elements on a class

百般思念 提交于 2019-12-10 03:07:29
问题 I am looking for any IDE menu option, keystroke, shorcut, mouse clicks or something to populate all interface elements (methods, properties, etc) inside a class implementing it. Are there any way to do it ? 回答1: There is no such shortcut, sadly. A rather similar question was asked recently here: How to automatically implement inherited abstract methods in Delphi XE 回答2: There is a shortcut that will let you autocomplete your class: Ctrl + Shift + C will autocomplete your functions, procedures

do interfaces belong in files of their own

混江龙づ霸主 提交于 2019-12-10 03:05:50
问题 As as rule of thumb I generally put classes in a file of their own. Visual studio seems to encourage this but what is appropriate with regards to interfaces? e.g. I have Class Foo that implements interface Bar public interface IBar { } public class Foo : IBar { } it seems natural to group these within the same file until another class implements the interface but to dedicate a file to 2 lines code seems excessive but correct. What is appropriate? 回答1: I would split them into 2 files. I often

Interface, Abstract, or just virtual methods?

不问归期 提交于 2019-12-10 03:01:02
问题 I have a bunch of systems, lets call them A, B, C, D, E, F, G, H, I, J . They all have similar methods and properties. Some contain the exact same method and properties, some may vary slightly and some may vary a lot. Right now, I have a lot of duplicated code for each system. For example, I have a method called GetPropertyInformation() that is defined for each system. I am trying to figure out which method would be the best approach to reduce duplicate code or maybe one of the methods below

Enum class member with interface cannot find methods internally

半城伤御伤魂 提交于 2019-12-10 02:52:26
问题 I'm having a strange issue which I'm not sure if it's a compiler problem or my understanding of enums with interfaces. I'm using IntelliJ IDEA 12, building an Android project, and I have a class like this: public class ClassWithEnum { private MyEnum myEnum; //Trying to access it internally here throws the error public boolean isActionable() { return myEnum.isActionable(); } public enum MyEnum implements Action { ACTIONABLE() { @Override public boolean isActionable() { return true; } }, NOT

How to write solid Pure Aggregation (composition) Game Objects in Java?

左心房为你撑大大i 提交于 2019-12-10 02:52:22
问题 So I am just at the beginning of writing a game in Java and I am writing my game objects. Now I have read here in Evolve Your Hierarchy that you should build your games as compositions and not as a big class hierarchy. As this image from the previous link shows: However, when actually getting down to the implementation I have one small question about where to apply the interfaces. Lets say you have a class called Player and the interfaces Moveable and Renderable. Do you implement this using

Can Eclipse auto-generate an interface of a 3rd party library class?

纵然是瞬间 提交于 2019-12-10 02:49:59
问题 I'm working with Apache's FTPClient class in the Apache commons net library. Sadly it doesn't implement an interface for most of the functionality which makes testing classes which use it tricky. So, I thought I'd create my own class which wrappers this one and implements an interface. Anyway that's the background. My question is, is it possible in Eclipse to generate an Interface (similiar to Refactor->Extract Interface) but for 3rd party code sitting in a jar file? Just to clarify, I'm not

Generically implementing a Java Single-Abstract-Method interface with a Scala closure?

牧云@^-^@ 提交于 2019-12-10 02:48:56
问题 As I understand it, when they finally come along, we will be able to substitute a Java closure for the equivalent single-method interface. Is there a standard Scala idiom for doing the same - implementing a Java Single Abstract Method interface with a Scala closure? Ideally I'd like the following to automagically work test("Closure") { var event: PropertyChangeEvent = null var label = new JLabel() label.addPropertyChangeListener( {e: PropertyChangeEvent => event = e} ) label.setText("fred")

What's the difference between a Contract in Laravel and an Interface in PHP?

五迷三道 提交于 2019-12-10 02:22:00
问题 As far as I can tell, Laravel refers to the interfaces it extends as Contracts because they are used by Laravel. But this seems a bit like circular reasoning. There is no value added in changing the terminology of an existing PHP feature simply because your project uses it. Is there something more to it? What's the logic behind coining a new term for something that's a standard PHP feature? Or is there some feature of Contracts that are not already in Interfaces? Edit : To clarify, it's the

Golang type interface {} is interface with no methods

我是研究僧i 提交于 2019-12-10 02:11:56
问题 Currently Im having something like this main.go gojob.NewJob("every 2 second", "pene", func() { t := gojob.Custom("pene") log.Println(t) }, struct { Id int }{ 1, }) And my gojob package func NewJob(t string, name string, c func(), v interface{}) { e := strings.Split(t, " ") job := process(e) job.log = false job.name = name job.action = c job.custom = v jobs = append(jobs, job) } And func Custom(name string) interface{} { for i := range jobs { if jobs[i].name != name { continue } return jobs[i

When to use Interfaces in PHP

回眸只為那壹抹淺笑 提交于 2019-12-10 02:08:21
问题 I have always had a hard time understanding the real value of Interfaces when coding with Objects in PHP (could be other languages I imagine) From what I understand you use an Interface to enforce or guarantee that when a Class is using an Interface that that class will have the methods defined in the Interface inside of that class. So from my litte knowledge of using them, wouldn't that mean you would only find an Interface beneficial when defining more then 1 class that needs those Methods?