interface

Closing all TCP sockets on interface Down

Hi there, I need to close all ongoing Linux TCP sockets as soon as the Ethernet interface drops (ie cable is disconnected, interface is down'ed and so on). Hacking into /proc seems not to do the trick. Not found any valuable ioctl's. Doint it by hand at application level is not what I want, I'm really looking for a brutal and global wa...

Why classes tend to be defined as interface nowadays?

Hi, These 2-3 last years, many projects I see, like Cuyahoga open source C# CMS, tends to define persistent and non persistent classes as Interface. Why? Is there a good reason? TDD? Mocking? A design pattern? ... ...

protected field vs. protected method vs. implementing interface for action handlers

I have a class that represents a basic page with "go back", "go forward", and "canel" buttons in Wicket. But not all pages have all the buttons, e. g. the first page doesn't have "go back" obviously. My idea is to define a generic ActionHandler public interface ActionHandler { void perform(); } and let subclasses return the actions...

How to import several instances with MEF ?

I have coded a service like that : public interface IMyInterface { ... } [Export(typeof(IMyInterface))] internal class MyService : IMyInterface { ... } Now, I'd like to import several instances of MyService with MEF in my main program. How can I do that ? With [Import] private IMyInterface MyService { get; set; } I only get 1 i...

what are the use of interfaces and diffrences with respect to interfaces

What are the major advantages of interfaces in designing application and the differences with respect to inheritance. can any body provide me with the brief example. ...

Are accessors in Python ever justified?

I realize that in most cases, it's preferred in Python to just access attributes directly, since there's no real concept of encapsulation like there is in Java and the like. However, I'm wondering if there aren't any exceptions, particularly with abstract classes that have disparate implementations. Let's say I'm writing a bunch of abst...

Why cast to Closeable first?

While reading some Java source, I came across this line: ((Closeable) some_obj).close(); some_obj is obviously an instance of a class which implements the Closeable interface. My question is, why do they first cast some_obj to Closeable before invoking close(). Couldn't I just do some_obj.close(); ...

C# cast to interface with List and GroupBy

I'm a bit stumped about how to perform the necessary cast in the following: public IList<IMyClass> Foo() { IList<IMyClass> foo = SomeQuery(); var result = foo.GroupBy(x => x.bar).Select(x => new MyClass()).ToList(); // So now I have a List<MyClass> which needs casting as IList<IMyClass> return result; } using an ex...

User Interface for Student's Grades and Attendance

I'm working on a design project and I'm having a hard time figuring out the UI for the last part: grades (1 to 10 + date of grade) and attendance (date of missed class). This is the admin side, which includes adding, editing and deleting both grades and attendance. Each student will have on their page a list of all the subjects, like so:...

Java Interface Implementation Problem

Hello everyone. I have a little problem. Class ll: interface jj{ public class ll implements gg{ public static String j ="C:\\"; //some code here } } Class ggg: interface gg{ public class ggg extends JFrame implements jj{ //bunch of code + a textfield textField = new JTextField(); textFi...

iPhone compose email interface designing

Can someone please tell me the elements used to create the 'compose email' page in the iPhone? More specifically, what elements are used to create the light blue 'bubbles' that display the contacts in the To:/CC:/BCC: fields? I need to make a screen similar to that, except populated with a data source of my own. ...

Adding view created in Interface Builder to Progmatically created view - can it be done?

Ok so I've downloaded an open source project that I'm looking at customising for personal use (unless it turns into a great project in which case who knows) but in either case I'm having some difficulty. From a starting point I'm finding creating UI elements using progmatic methods rather difficult, just can't find a good tutorial out t...

Delphi: How to implement QueryInterface of IUnknown?

In Delphi, IUnknown is declared as: function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; Note: The output parameter is untyped In my TInterfacedObject descendant i need to handle QueryInterface, so i can return an object that supports the requested interface: function TFoo.QueryInterface(const IID: TGUID; out Obj): ...

How to provide a cross platform, asynchronous service interface

What is the best way to provide an asynchronous service interface to multi-platform (primarily java and .net) clients? The backend service is implemented in java. We are looking at asynchronous web service and message queues, but apparently cross platform asynchronous web service* is not supported yet in java (as far as I know) and fo...

how to use jaxws for a class referencing an interface

I have a java class which I need to annotate up for a web service. Everything is set up and compiles etc, the wsdl is generated using the maven plugin for wsprovide... the problem I have is that the class references an interface... @WebService(name = "myWebService", targetNamespace = "......") @SOAPBinding(style = SOAPBinding.Style.RPC...

Difference in using Attributes/Interfaces in C#

This is not properly a question but something more like a thought I had recently. I'm taking XmlAttribute to XmlSerialize a class as an example: you can set attributes to a class to choose which properties should be serialized, but the same thing can be done quite easy by implementing a teorical interface IXmlSerializable (it does exist ...

Adding Invariants to Interfaces in Java

I've been thinking about creating a Java framework that would allow programmers to specify invariants (pre- and post-conditions) on interfaces. The purpose would be to make code more robust and reduce the number of unit tests that would need to be written for different implementations of the same interface. I envisage creating some way ...

Interface without any methods - bad practice?

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. ...

When to implement an interface and when to extend a superclass?

I've been reading a lot about interfaces and class inheritance in Java, and I know how to do both and I think I have a good feel for both. But it seems that nobody ever really compares the two side by side and explains when and why you would want to use one or the other. I have not found a lot of times when implementing an interface woul...

How can I make the Win32 API window more modern looking?

Hey, I ordered Programming Windows Fifth Edition a few days ago, and started working with it. I'm starting to learn the win32 api, however, I got a question. The windows do not look modern winxp/win vista/win 7 style at all. How do I fix this? It currently looks like this, crap font and all. Thanks in advance! Machiel ...