interface

How to model the use of one interface as parameter to a method of another interface in UML?

I am using Visual Paradigm for UML to model our class hierarchy. I often have the case where one of our interfaces has a method requires an implementation of another of our interfaces as parameter to a method. Example (C++, interface = abstract class): class IFoo { public: virtual void bla() = 0; }; class IBar { public: virtual...

Reflection: optimize performance

Hello, i want to know if i could optimize the reflection part of my app. Background information: the vb.net windows application checks if database records apply on different rules. So i created an Interface iRule and (so far) 54 rules-classes that are implementing it. They all belong to the same project(Rule.dll). Because people shou...

why use spring ??

hi, I am very much confused whether i should use spring Reason - I want to develop a loosely coupled code which i think can be developed using Factory pattern and interfaces... and dependency injection can be implemented without using spring too...(by passing parameters).. why should i use spring then ?? Which are the other benefits ...

Landscape/Portrait conflict - iOS

hey, Just when i thought I had everything figured out .. i got this problem. the scenario. I got a simple tableView. and with a search bar in navigation item's titleView. The SearchBar is added to navItems titleView via a uibarbuttonitem in view controllers toolbar. NOW, normally After initiating the searchbar with [beginResponde...

Why can unrelated c# interface references be compared without compiler error?

I was surprised recently to discover that the compiler is apparently not strict about comparing interface references and am wondering why it works this way. Consider this code: class Program { interface I1 {} interface I2 {} class C1 : I1 {} class C2 : I2 {} static void Main(string[] args) { C1 c1 = new...

How do I create a class specifically for the purpose of using SharedPreferences?

I have a couple activities in my app that I would like to utilize shared preferences. Initially, I created a method in each activity to utilize SharedPreferences, which worked fine. However, since there are multiple activities that use the same data, I’m basically tucking similar methods in multiple places. So it seemed like it made m...

Should methods that implement pure virtual methods of an interface class be declared virtual as well?

I read different opinions about this question. Let's say I have an interface class with a bunch of pure virtual methods. I implement those methods in a class that implements the interface and I do not expect to derive from the implementation. Is there a need for declaring the methods in the implementation as virtual as well? If yes, why...

How to enforce interface contracts (in C) at compile time?

Background: We're modeling the firmware for a new embedded system. Currently the firmware is being modeled in UML, but the code generation capabilities of the UML modeling tool will not be used. Target language will be C (C99, to be specific). Low power (i.e. performance, quick execution) and correctness are important, but correctnes...

UIScrollView moves on its own

I have a full screen UIScrollView that has several possible layout configurations. It is basically a "contact" card eith some buttons, imageViews, Labels , and text fields. When it loads, buttons will be moved or removed based on the content available. Oddly, the Scorll View does not always start in the same position. Sometimes it loads...

Linking like in XCode's Interface Builder

Hello! I want to create a functionality in a program to link two views (inside another view) using links like when CTRL+Dragging in Interface Builder. In the implementation I have currently, there are 2 (or more) subclassed NSControllers (called Nodes) and inside those nodes there are 1 (or more) subclassed NSControllers (called Outlets...

Non-generic interface as a synonym for generic one

I have one generic interface in c#, and almost always I use it with one of the types. I want to create a non-generic interface for that type and use it. Let's say, I've the following code: public interface IMyGenericList<out T> where T : IItem { IEnumerable<T> GetList(); } public class MyList<T> : IMyGenericList<T> where T : IItem...

Multiple interfaces with same method names

Hello, I have a class which inherits from two different interfaces. Both interfaces declare a method with the same name. How can I provide a different implementation for each interface ? In C#, the answer is there, but it does not work in java: http://stackoverflow.com/questions/2371178/inheritance-from-multiple-interface-with-the-same...

c# plugin system question

so I implemented a really simple plugin system. i have the following Assemblies: MainApp IPlugin PluginApp Both MainApp and PluginApp conatin a reference to the IPlugin. Now, in MainApp I scan a plugins folder and search for things that implement the IPlugin interface. However, it is not working because both MainApp and PluginApp r...

Class design, Interfaces or Concrete classes

Hi all, I have a problem regarding the use of interfaces vs concrete classes. I have a base class that implements some common properties/methods. Now i have two possible extensions. Either this base class can have some property called Parameters, Or it can have another property called Children, or it can have both. The way i see it i c...

Alternative for static method in interface - enforce implementing class-level methods in asp.net custom controls

I have a hierarchy in my website project as below: [CustomControl1 - folder] - CustomControl1.ascx - CustomControl1.css - CustomControl1.js I load css and js files dynamicaly based on which controls are used on particular page. I am doing it by using following code: protected void Page_Load(object sender, EventArgs e) { CustomCon...

C#: Can I code public class MyGenericClass<T> where T:MyClass AND implement an Interface?

I see this: public class MyGenericClass<T> where T:IComparable { } and I have this: public class ProductRepository : IRepository<Product> { } How would you code something like this? public class ProductRepository<T> where T : Product : IRepository<Product> {} After all that, I thought I could simply make a single Repository clas...

Introducing interfaces into an existing class hierarchy in Delphi

Are there any side effects to changing a class hierarchy's ancestor from TObject to TInterfacedObject so that I can implement interfaces further down the inheritance chain? I've programmed in Delphi for several years but never encountered interfaces. I became accustomed to using them in other languages. Now that I'm involved in a Delphi...

C# explicitly implementing an interface with an abstract method

Here is my interface: public interface MyInterface { bool Foo(); } Here is my abstract class: public abstract class MyAbstractClass : MyInterface { abstract bool MyInterface.Foo(); } This is the compiler error: "The modifier 'abstract' is not valid for this item. How should I go on about explicitly implementing an abstract...

Using Java generics in an interface to enforce implementation of a method with the implementing type as a parameter

I have an interface like this: public interface DataObject { ... public void copyFrom(DataObject source); ... } And a class that implements it: public class DataObjectImpl implements DataObject { ... @Override public void copyFrom(final DataObject source) {...} public void copyFrom(final DataObjectImpl so...

One function implementing Generic and non-generic interface

Lets say I have a class, which implements a generic interface public interface IItem {} public interface IStuff<out TItem> where TItem : IItem { TItem FavoriteItem { get; } } public class MyStuff<TItem> : IStuff<TItem> where TItem : IItem { public TItem FavoriteItem { get { throw new NotImplementedException(); }...