Search Results

Search found 14402 results on 577 pages for 'interface builder'.

Page 25/577 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • The Java interface doesn't declare any exception. How to manage checked exception of the implementat

    - by Frór
    Let's say I have the following Java interface that I may not modify: public interface MyInterface { public void doSomething(); } And now the class implementing it is like this: class MyImplementation implements MyInterface { public void doSomething() { try { // read file } catch (IOException e) { // what to do? } } } I can't recover from not reading the file. A subclass of RuntimeException can clearly help me, but I'm not sure if it's the right thing to do: the problem is that that exception would then not be documented in the class and a user of the class would possibly get that exception an know nothing about solving this. What can I do?

    Read the article

  • Can someone explain this java interface to me please?

    - by Karl Patrick
    I realize that the method run must be declared because its declared in the runnable interface. But my question comes when this class runs how is the Thread object allowed if there is no import call to a particular package? how does runnable know anything about Thread or its methods? does the runnable interface extend the thread class? Obviously i dont understand interfaces very well. thanks in advance. class PrimeFinder implements Runnable{ public long target; public long prime; public boolean finished = false; public Thread runner; PrimeFinder(long inTarget){ target = inTarget; if(runner == null){ runner = new Thread(this); runner.start() } } public void run(){ } }

    Read the article

  • Does C++ have a proper implementation of interface that does not use vtable?

    - by gilbertc
    Does C++ have a proper implementation of interface that does not use vtable? for example class BaseInterface{ public: virtual void func() const = 0; } class BaseInterfaceImpl:public BaseInterface{ public: void func(){ std::cout<<"called."<<endl; } } BaseInterface* obj = new BaseInterfaceImpl(); obj->func(); the call to func at the last line goes to vtable to find the func ptr of BaseInterfaceImpl::func, but is there any C++ way to do that directly as the BaseInterfaceImpl is not subclassed from any other class besides the pure interface class BaseInterface? Thanks. Gil.

    Read the article

  • Does C++ have a static polymorphism implementation of interface that does not use vtable?

    - by gilbertc
    Does C++ have a proper implementation of interface that does not use vtable? for example class BaseInterface{ public: virtual void func() const = 0; } class BaseInterfaceImpl:public BaseInterface{ public: void func(){ std::cout<<"called."<<endl; } } BaseInterface* obj = new BaseInterfaceImpl(); obj->func(); the call to func at the last line goes to vtable to find the func ptr of BaseInterfaceImpl::func, but is there any C++ way to do that directly as the BaseInterfaceImpl is not subclassed from any other class besides the pure interface class BaseInterface? Thanks. Gil.

    Read the article

  • How to add a slot to my main window in Qt builder?

    - by George Edison
    I am using Qt Builder to create a simple window. I used the menu editor to add a menu. Now, I figured out how to connect one of the menu items to the close() method of the main window. My problem is how to add a slot to the main window. Here is what I have: private slots: void OnAbout(); However, I can't get this method to show up in the 'Signals and Slots Editor'. How can I get it to show up?

    Read the article

  • Casting as Interface? Awesome.

    - by cam
    I was just experimenting around with one of my programs, trying to make it looks prettier and I found something interesting. I have an interface that 4 classes inherit from. I found that if I pass the Class as an object to a method like so: ClassTest classtest = new ClassTest(); DoOperation(classtest); private void DoOperation(object o) { ((InterfaceClass)o).DoThis(); } So I can pass any type of class that inherits from InterfaceClass, and it will preform the proper interface operation? This is the coolest thing I've ever found from OOP (something I've never really studied) I really thought interfaces were created for the sole purpose of organization for developers. Are there more uses for interfaces than this?

    Read the article

  • Alternate to control+drag to connect view element with file owner in xCode interface builder?

    - by yldave
    Working on an iPhone application through a TightVNC connection into a Mac Mini; the control+drag operation in Interface Builder to connect a view element to file owner doesn't work - I don't see the connecting line. It does work when I connect keyboard, mouse and monitor to the Mini and work on it directly, however it is a lot more convenient for me to run it through a VNC connection. Must be some quirk of the TightVNC connection that is preventing this. I tried different TightVNC settings for the cursor (let server handle it and so on) but no luck. Is there an alternative to control+drag to hook up outlets?

    Read the article

  • What's is the point of PImpl pattern while we can use interface for same purpose in C++?

    - by ZijingWu
    I see a lot of source code which using PIMPL idiom in C++. I assume Its purposes are hidden the private data/type/implementation, so it can resolve dependence, and then reduce compile time and header include issue. But interface class in C++ also have this capability, it can also used to hidden data/type and implementation. And to hidden let the caller just see the interface when create object, we can add an factory method in it declaration in interface header. The comparison is: Cost: The interface way cost is lower, because you doesn't even need to repeat the public wrapper function implementation void Bar::doWork() { return m_impl->doWork(); }, you just need to define the signature in the interface. Well understand: The interface technology is more well understand by every C++ developer. Performance: Interface way performance not worse than PIMPL idiom, both an extra memory access. I assume the performance is same. Following is the pseudocode code to illustrate my question: // Forward declaration can help you avoid include BarImpl header, and those included in BarImpl header. class BarImpl; class Bar { public: // public functions void doWork(); private: // You doesn't need to compile Bar.cpp after change the implementation in BarImpl.cpp BarImpl* m_impl; }; The same purpose can be implement using interface: // Bar.h class IBar { public: virtual ~IBar(){} // public functions virtual void doWork() = 0; }; // to only expose the interface instead of class name to caller IBar* createObject(); So what's the point of PIMPL?

    Read the article

  • Piloting Microsoft Word With Ole in C++ Builder : how to put Word in the foreground.

    - by Getz
    Hi! I've got a code (which works fine) for piloting word with C++ Builder. It's useful for reaching different bookmarks in the document. Variant vNom, vWDocuments, vWDocument, vMSWord, vSignets, vSignet; vNom = WideString("blabla.doc"); try { vMSWord = Variant::GetActiveObject("Word.Application"); } catch(...) { vMSWord = Variant::CreateObject("Word.Application"); } vMSWord.OlePropertySet("Visible", true); vWDocuments = vMSWord.OlePropertyGet("Documents"); vWDocument = vWDocuments.OleFunction("Open", vNom); vSignets = vWDocument.OlePropertyGet("BookMarks"); if (vSignets.OleFunction("Exists", signet)) { vSignet = vSignets.OleFunction("Item", signet); vSignet.OleFunction("Select"); } But once the document is opened, the user can no longer see when an other bookmark has been reached, since the application stays in background. Does anyone know how i can do to make Word displayed in the foreground, or to light-up the document in the taskbar? Thanks!

    Read the article

  • Why the compiler is not compiling a line in C++ Builder?

    - by MLB
    Hi boys: I was programming an application in C++ Builder 6, and I had encountered this rare problem: void RotateDice() { Graphics::TBitmap *MYbitmap = new Graphics::TBitmap(); Randomize(); int rn = random(6) + 1; switch (rn) { case 1: { //... break; } //... Some cases... } ShowDice(); //it's a function to show the dice delete MYbitmap; //the compiler don't get it!!!! } In the line "ShowDice()", the compiler jumps to the final of the RotateDice() method, it doesn't "see" the line "delete MYbitmap". When I compile the program, every compiled line shows a little blue point in its left side, but that line don't show the blue point... it's like the compiler don't "see" the line of code. What's happening with that???? Note: Some days ago, I was writing a program in Delphi and I was advice of that problematic issue. Some like that happened to me in Delphi 7... So, waht the problem with that? I am so sorry about my English. I am from Cuba.

    Read the article

  • UML interface: URL iframe integration

    - by Bernd
    I have two applications, A and B, both with a web-based user interface. Both applications are integrated via an URL iframe mechanism. A user can click on a link in application A and then gets the UI of application B as am iframe in application A. Now, since both applications have an interface between each other (do they?): Who provides the interface and who requires the interface, in the UML sense? What is the main information flow on this interface?

    Read the article

  • Flex unit testing with ANT vs Flash Builder 4

    - by peterlindstrom21
    I have just tried setup unit testing in Flash Builder 4, and it working nicely. A setup of a parallel test source structure and using Flash Builder 4:s new TestCase and new TestSuite I was up and running with some testcases within minutes. But now I want to compile them from a ant flex task, the Flash Builder generates FlexUnitApplication.mxml and FlexUnitCompilerApplication.mxml. Is there a nice way to build the unit tests with ant using these? I cant find any sample where this is done.

    Read the article

  • When using Data Annotations with MVC, Pro and Cons of using an interface vs. a MetadataType

    - by SkippyFire
    If you read this article on Validation with the Data Annotation Validators, it shows that you can use the MetadataType attribute to add validation attributes to properties on partial classes. You use this when working with ORMs like LINQ to SQL, Entity Framework, or Subsonic. Then you can use the "automagic" client and server side validation. It plays very nicely with MVC. However, a colleague of mine used an interface to accomplish exactly the same result. it looks almost exactly the same, and functionally accomplishes the same thing. So instead of doing this: [MetadataType(typeof(MovieMetaData))] public partial class Movie { } public class MovieMetaData { [Required] public object Title { get; set; } [Required] [StringLength(5)] public object Director { get; set; } [DisplayName("Date Released")] [Required] public object DateReleased { get; set; } } He did this: public partial class Movie :IMovie { } public interface IMovie { [Required] object Title { get; set; } [Required] [StringLength(5)] object Director { get; set; } [DisplayName("Date Released")] [Required] object DateReleased { get; set; } } So my question is, when does this difference actually matter? My thoughts are that interfaces tend to be more "reusable", and that making one for just a single class doesn't make that much sense. You could also argue that you could design your classes and interfaces in a way that allows you to use interfaces on multiple objects, but I feel like that is trying to fit your models into something else, when they should really stand on their own. What do you think?

    Read the article

  • Is there anything like Unity for simple things that don't require an interface?

    - by Dave
    Perhaps I'm misapplying Unity, but here goes. I have a couple of applications, both of which load the same plugin assemblies. All assemblies require a library, and I want them to be able to access this library via Unity. However, in order to use Unity, or any other IoC framework, I'd have to write an interface for this library. I will probably do this, but since an interface isn't really needed for anything other than to support Unity, I am afraid that this means that I am 1) missing the point, or 2) misapplying the framework. If I avoid something that offers me DI, then I'd have to make the library class a singleton, and then pass it to all of the plugin constructors, or via a public property, and I don't want to do this. That said, and without actually implementing anything with Unity yet, I'm not getting one other detail -- although Unity will let me request the library via Resolve<, my plugins will still need to have a reference to the Unity instance that is created in the main applications. So is this a case where your only option is to pass the Unity reference to all of the plugins, but then it's convenient from that point on, merely because you can use Unity to get at all of the other dependencies?

    Read the article

  • make local only daemon listening on different interface (using iptables port forwarding)?

    - by UniIsland
    i have a daemon program which listens on 127.0.0.1:8000. i need to access it when i connect to my box with vpn. so i want it to listen on the ppp0 interface too. i've tried the "ssh -L" method. it works, but i don't think it's the right way to do that, having an extra ssh process running in the background. i tried the "netcat" method. it exits when the connection is closed. so not a valid way for "listening". i also tried several iptables rules. none of them worked. i'm not listing here all the rules i've used. iptables -A FORWARD -j ACCEPT iptables -t nat -A PREROUTING -i ppp+ -p tcp --dport 8000 -j DNAT --to-destination 127.0.0.1:8000 the above ruleset doesn't work. i have net.ipv4.ip_forward set to 1. anyone knows how to redirect traffic from ppp interface to lo? say, listen on "192.168.45.1:8000 (ppp0)" as well as "127.0.0.1:8000 (lo)" there's no need to alter the port. thanx

    Read the article

  • What would be the safest way to store objects of classes derived from a common interface in a common

    - by Svenstaro
    I'd like to manage a bunch of objects of classes derived from a shared interface class in a common container. To illustrate the problem, let's say I'm building a game which will contain different actors. Let's call the interface IActor and derive Enemy and Civilian from it. Now, the idea is to have my game main loop be able to do this: // somewhere during init std::vector<IActor> ActorList; Enemy EvilGuy; Civilian CoolGuy; ActorList.push_back(EvilGuy); ActorList.push_back(CoolGuy); and // main loop while(!done) { BOOST_FOREACH(IActor CurrentActor, ActorList) { CurrentActor.Update(); CurrentActor.Draw(); } } ... or something along those lines. This example obviously won't work but that is pretty much the reason I'm asking here. I'd like to know: What would be the best, safest, highest-level way to manage those objects in a common heterogeneous container? I know about a variety of approaches (Boost::Any, void*, handler class with boost::shared_ptr, Boost.Pointer Container, dynamic_cast) but I can't decide which would be the way to go here. Also I'd like to emphasize that I want to stay away as far as possible from manual memory management or nested pointers. Help much appreciated :).

    Read the article

  • How to Implement an Interface that Requires Duplicate Member Names?

    - by Will Marcouiller
    I often have to implement some interfaces such as IEnumerable<T> in my code. Each time, when implementing automatically, I encounter the following: public IEnumerator<T> GetEnumerator() { // Code here... } public IEnumerator GetEnumerator1() { // Code here... } Though I have to implement both GetEnumerator() methods, they impossibly can have the same name, even if we understand that they do the same, somehow. The compiler can't treat them as one being the overload of the other, because only the return type differs. When doing so, I manage to set the GetEnumerator1() accessor to private. This way, the compiler doesn't complaint about not implementing the interface member, and I simply throw a NotImplementedException within the method's body. However, I wonder whether it is a good practice, or if I shall proceed differently, as perhaps a method alias or something like so. What is the best approach while implementing an interface such as IEnumerable<T> that requires the implementation of two different methods with the same name? EDIT #1 Does VB.NET reacts differently from C# while implementing interfaces, since in VB.NET it is explicitly implemented, thus forcing the GetEnumerator1(). Here's the code: Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of T) Implements System.Collections.Generic.IEnumerable(Of T).GetEnumerator // Code here... End Function Public Function GetEnumerator1() As System.Collections.Generic.IEnumerator Implements System.Collections.Generic.IEnumerable.GetEnumerator // Code here... End Function Both GetEnumerator() methods are explicitly implemented, and the compile will refuse them to have the same name. Why?

    Read the article

  • How to Implement an Interface that Requires Duplicate Member Names in C#?

    - by Will Marcouiller
    I often have to implement some interfaces such as IEnumerable<T> in my code. Each time, when implementing automatically, I encounter the following: public IEnumerator<T> GetEnumerator() { // Code here... } public IEnumerator GetEnumerator1() { // Code here... } Though I have to implement both GetEnumerator() methods, they impossibly can have the same name, even if we understand that they do the same, somehow. The compiler can't treat them as one being the overload of the other, because only the return type differs. When doing so, I manage to set the GetEnumerator1() accessor to private. This way, the compiler doesn't complaint about not implementing the interface member, and I simply throw a NotImplementedException within the methods body. However, I wonder whether it is a good practice, or if I shall proceed differently, as perhaps a method alias or something like so. What is the best approach while implementing an interface such as IEnumerable<T> that requires the implementation of two different methods with the same name?

    Read the article

  • Is it advisable to have an interface as the return type?

    - by wb
    I have a set of classes with the same functions but with different logic. However, each class function can return a number of objects. It is safe to set the return type as the interface? Each class (all using the same interface) is doing this with different business logic. protected IMessage validateReturnType; <-- This is in an abstract class public bool IsValid() <-- This is in an abstract class { return (validateReturnType.GetType() == typeof(Success)); } public IMessage Validate() { if (name.Length < 5) { validateReturnType = new Error("Name must be 5 characters or greater."); } else { validateReturnType = new Success("Name is valid."); } return validateReturnType; } Are there any pitfalls with unit testing the return type of an function? Also, is it considered bad design to have functions needing to be run in order for them to succeed? In this example, Validate() would have to be run before IsValid() or else IsValid() would always return false. Thank you.

    Read the article

  • C# What is the best way to determine the type of an inherited interface class?

    - by Martijn
    In my application I work with criterias. I have one base Criteria interface and and other interfaces who inherits from this base interface: ICriteria | | ---------------------- | | ITextCriteria IChoices What I'd like to know is, what is the best way to know what Type the class is? In my code I have a dropdown box and based on that I have to determine the type: // Get selected criteria var selectedCriteria = cmbType.SelectedItem as ICriteria; if (selectedCriteria is IChoices) { //selectedCriteria = cmbType.SelectedItem as IChoices; Doesn't work IChoices criteria = selectedCriteria as IChoices;//cmbType.SelectedItem as IChoices; SaveMultipleChoiceValues(criteria); //_category.AddCriteria(criteria); } else { //ICriteria criteria = selectedCriteria; //cmbType.SelectedItem as ICriteria; if (selectedCriteria.GetCriteriaType() == CriteriaTypes.None) { return; } //_category.AddCriteria(criteria); } _category.AddCriteria(selectedCriteria); selectedCriteria.LabelText = txtLabeltext.Text; this.Close(); My question is, is this the best way? Or is there a better way to achieve this? The chance is big that there are coming more interfaces based on ICriteria.

    Read the article

  • Making an interface for input in C - How?

    - by tloszk
    I have a big question. I started to develop a simple 3D engine (or should I call it framework?). I use OpenGL for rendering and it is developed for Windows. It is all written in C. But I don't know, how to write an "interface" for the keyboard/mouse input. I would like to keep it as simple as possible and nice - what the Win32 "native" input system is not. If anyone has suggestions about the topic, please, tell me. Thanks for everyone, who answers to my question!

    Read the article

  • Where and how to reference composite MVP components?

    - by Lea Hayes
    I am learning about the MVP (Model-View-Presenter) Passive View flavour of MVC. I intend to expose events from view interfaces rather than using the observer pattern to remove explicit coupling with presenter. Context: Windows Forms / Client-Side JavaScript. I am led to believe that the MVP (or indeed MVC in general) pattern can be applied at various levels of a user interface ranging from the main "Window" to an embedded "Text Field". For instance, the model to the text field is probably just a string whereas the model to the "Window" contains application specific view state (like a persons name which resides within the contained text field). Given a more complex scenario: Documentation viewer which contains: TOC navigation pane Document view Search pane Since each of these 4 user interface items are complex and can be reused elsewhere it makes sense to design these using MVP. Given that each of these user interface items comprises of 3 components; which component should be nested? where? who instantiates them? Idea #1 - Embed View inside View from Parent View public class DocumentationViewer : Form, IDocumentationViewerView { public DocumentationViewer() { ... // Unclear as to how model and presenter are injected... TocPane = new TocPaneView(); } protected ITocPaneView TocPane { get; private set; } } Idea #2 - Embed Presenter inside View from Parent View public class DocumentationViewer : Form, IDocumentationViewerView { public DocumentationViewer() { ... // This doesn't seem like view logic... var tocPaneModel = new TocPaneModel(); var tocPaneView = new TocPaneView(); TocPane = new TocPanePresenter(tocPaneModel, tocPaneView); } protected TocPanePresenter TocPane { get; private set; } } Idea #3 - Embed View inside View from Parent Presenter public class DocumentationViewer : Form, IDocumentationViewerView { ... // Part of IDocumentationViewerView: public ITocPaneView TocPane { get; set; } } public class DocumentationViewerPresenter { public DocumentationViewerPresenter(DocumentationViewerModel model, IDocumentationViewerView view) { ... var tocPaneView = new TocPaneView(); var tocPaneModel = new TocPaneModel(model.Toc); var tocPanePresenter = new TocPanePresenter(tocPaneModel, tocPaneView); view.TocPane = tocPaneView; } } Some better idea...

    Read the article

  • RPi and Java Embedded GPIO: Sensor Hardware for Java Enabled Interface

    - by hinkmond
    Now here's the hardware you'll need to make a Java app interface with a static charge sensor connected to your Raspberry Pi via the GPIO port. It means another Fry's run of course. That's not too bad during Christmas since you can browse all the gadget and toys while doing your shopping for sensor hardware for your RPi. Here's a your shopping list: 1 - NTE312 JFET N-channel transistor (this is in place of the MPF-102) 1 - Set of Jumper Wires 1 - LED 1 - 300 ohm resistor 1 - set of header pins Grab all that from Fry's or your local hobby electronics shop and come back here for how to connect it together. Oh, and don't go too crazy buying all the other electronic toys and gadgets that catch your eye because of the holiday displays at the store. Hinkmond

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >