2

In my previous job, they utilized alot of IEquatable<IInterface> and Dictionary<int, IInterface> declarations. We did alot of websites, as a result utilized Entity Framework (5+) and the DIF model (Castle) for object resolution.

In my new job, i am in the role of transitioning an application to the present. This current project, is a desktop (WinForms) application and have resolved myself out of using EF & DIF, due to the complexity of integration for them. So trying to utilize the EF design into an updated ADO object/parent relationship.

So i have segmented out my singleton declarations into a Domain project, Collection of singletons into the Repository project, and the interaction with the repositories into a Service Project. With the intent of the GUI (WinForms) accessing the Service Project as its sole interaction with the database.

As i am in the phase of designing the Repository design and interaction, i need to be able to store a Collection of the Repo's Domain object and was unsure if i should setup the Dictionary as Dictionary<int, Object> or Dictionary<int, IObject>.

As far as local resource management, which implementation would have an overall better load on system resources? What are the pros and cons to either implementation?

GoldBishop
  • 2,820
  • 4
  • 47
  • 82
  • _"which implementation would have an overall better load on system resources?"_ - that is not what interfaces do. _"What are the pros and cons to either implementation?"_ - the same as applying them to single objects. Can you explain why you are asking this question? What benefits do _you_ think using interfaces instead of classes yield? – CodeCaster Feb 24 '14 at 13:45
  • Tell you the truth, outside of my previous job, using Interfaces was only used in assisting in the construction of classes. But as we used a 1:1 relationship for alot of the Class:Interface designs, I wasnt sure if there was an underlying benefit to referencing Interfaces over Classes, outside of the object references. – GoldBishop Feb 24 '14 at 13:52
  • Maybe it is just my lack of knowledge of why Castle Windsor uses Interfaces to Resolve Classes, but it pretty much blew my understanding of Interfaces out of the water. I usually use Interfaces like a DBA Normalizes. – GoldBishop Feb 24 '14 at 13:54
  • 1
    A reference is a reference. An interface doesn't take up less memory than a class reference, if that is what you're aiming at. Is [Why would I want to use Interfaces?](http://stackoverflow.com/questions/240152/why-would-i-want-to-use-interfaces) any helpful? – CodeCaster Feb 24 '14 at 13:54
  • 1
    Thank you @CodeCaster, i was thinking way too much into what i needed but just wanted verification that there would be no actual load difference. – GoldBishop Feb 24 '14 at 14:09

1 Answers1

1

It will not make any difference. End of the day, values in Dictionary will be objects of certain class and will take up space as much as needed by the object.

You need to consider why exactly do you need to use interfaces here? Is it serving some purpose?

danish
  • 5,550
  • 2
  • 25
  • 28
  • Yeah polymorphism slipped my mind, i am filling a DB and App developer role, so my wires get crossed alot on industry terms. After refreshing myself on actual use, polymorphism is not being utilized and its pretty much a 1:1 Class:Interface relationship. I personally like that, cause i can keep the Classes specific Interface clean and just extend further Interfaces off that one and do the implemenation at the class level. – GoldBishop Feb 24 '14 at 14:08
  • I could be a personal preference but unless there is chance of extension/updates on application in near future, there is no real need to have 1:1 class interface relations. Also, can the consumer of this code make there own implementation? If not, this is just an overhead. Just a personal thing. – danish Feb 24 '14 at 14:13
  • 1
    Yeah its a package implementation. Right now, there will probably be no further implementation down the forseeable road. But i generally design for the unknown and so have a habit of put some overhead in the front, to allow for flexibility down the road. – GoldBishop Feb 24 '14 at 14:16
  • Then this is something required. Allows consumers to play around. – danish Feb 24 '14 at 14:17