Questions tagged [interface-design]

33 questions
152
votes
5 answers

Is there a pattern for initializing objects created via a DI container

I am trying to get Unity to manage the creation of my objects and I want to have some initialization parameters that are not known until run-time: At the moment the only way I could think of the way to do it is to have an Init method on the…
62
votes
9 answers

Best practices for developing larger JavaScript applications

Having a strong background in Java/C++ i wonder if it is possible to develop a somewhat larger JavaScript application without having to cut back on quality. Any hints are appreciated regarding: Development Enviroment Debugging Techniques Unit…
mibollma
  • 14,959
  • 6
  • 52
  • 69
23
votes
1 answer

Designing an Python API: Fluent interface or arguments

I'm playing around with a simple port of the Protovis API to Python. Consider the simple bar chart example, in Javascript: var vis = new pv.Panel() .width(150) .height(150); vis.add(pv.Bar) .data([1, 1.2, 1.7, 1.5, .7, .3]) …
Tristan
  • 6,776
  • 5
  • 40
  • 63
10
votes
10 answers

Static Methods in an Interface/Abstract Class

First off, I understand the reasons why an interface or abstract class (in the .NET/C# terminology) cannot have abstract static methods. My question is then more focused on the best design solution. What I want is a set of "helper" classes that all…
jerhinesmith
  • 15,214
  • 17
  • 62
  • 89
7
votes
4 answers

High level design pattern for image editing tools

I have recently begin creating an image editing tool which will cater to a very specific need. This is as much for the people who are going to use it as it is for my own entertainment. however, I have hit a bit of an architectural snag early on. …
Ed S.
  • 122,712
  • 22
  • 185
  • 265
6
votes
3 answers

Binary compatibility when using pass-by-reference instead of pass-by-pointer

This question is intended as a follow up question to this one: What are the differences between a pointer variable and a reference variable in C++? Having read the answers and some further discussions I found on stackoverflow I know that the…
5
votes
3 answers

Plug In Design for .NET App

I’m looking at rewriting a portion of our application in C# (currently legacy VB6 code). The module I am starting with is responsible for importing data from a variety of systems into our database. About 5-6 times a year, a new client asks us to…
Tim Lentine
  • 7,782
  • 5
  • 35
  • 40
5
votes
2 answers

How to design my C# jQuery API such that it isn't confusing to use?

I'm making a jquery clone for C#. Right now I've got it set up so that every method is an extension method on IEnumerable so it works well with existing projects that are already using HtmlAgilityPack. I thought I could get away without…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
5
votes
2 answers

C++ DAL - Return Reference or Populate Passed In Reference

[EDIT 1 - added third pointer syntax (Thanks Alex)] Which method would you prefer for a DAL and why out of: Car& DAL::loadCar(int id) {} bool DAL::loadCar(int id, Car& car) {} Car* DAL::loadCar(int id) {} If unable to find the car first method…
ng5000
  • 12,330
  • 10
  • 51
  • 64
4
votes
1 answer

What would be the benefit of an interface which implies a certain implementation?

I'm looking at this: public interface IAjaxCallbackEventHandler : ICallbackEventHandler { string CallbackResponse { get; set; } } } So pages implement this interface and end up looking like this: public partial class XPage : Page,…
Cade Roux
  • 88,164
  • 40
  • 182
  • 265
4
votes
2 answers

Best practices when using an interface

Many times when designing interfaces I keep running into the same situation. The situation is where certain implementations using an interface require particular parameters in the interface while others do not. What is the best practice when…
crv
  • 3,024
  • 4
  • 27
  • 31
2
votes
2 answers

How to call Events in Interfaces C#?

So i have a design problem. I have a mouse class that has delegates and events. ie MouseButtonPressed, MouseMoved. and such that are getting called by a state engine. What i want to have happen is to create an interface like IClickable or…
Eibach
2
votes
1 answer

Dedicating a field in arbitrary class types for "external use"

My container needs to store a little information about its elements. Normally, I store this separately from elements. However, I'd like to give users possibility to conserve memory by dedicating a field in element structure type for external use. …
user319799
2
votes
4 answers

What is the best way to pass data between a MainFrame (or Main Dialog) and a Modal Dialog?

I need a modal dialog to gather some user input. I then need the same data to be consumed by the application MainFrame. Usually my Modal Dialog would have a pointer to some DataType able to store what I need, and I'd be passing this object by…
JohnIdol
  • 48,899
  • 61
  • 158
  • 242
2
votes
5 answers

How can I express that an argument needs to implement multiple interfaces in C#

Similiar to this question: How can I require a method argument to implement multiple interfaces? I want a method argument to implement several interfaces. The interfaces shall be combinable in arbitrary fashion and I don't want to create an…
Onur
  • 5,017
  • 5
  • 38
  • 54
1
2 3