What is the difference between a Class Abstraction and an Object Interfaces in PHP? I ask because, I don't really see the point to both of them, they both do the same thing! So, what are the advantages of disadvantages using both against one or the other?
Class Abstraction:
abstract class aClass
{
// Force extending class to define...
I have created an OrderFormViewModel which looks something like
public class OrderFormViewModel
{
public IOrderDetails { get; set; }
public IDeliveryDetails { get; set; }
public IPaymentDetails { get; set; }
// ... etc
public SelectList DropDownOptions { get; set; }
// ... etc
}
This goes to my Create view, ...
Hello, I have been working with a iPhone app that I would like to have switch views like the Palm Pre does for multitasking. I know the usual way of switching views by using the black bar at the bottom of the app but the app I am working on does not lend itself to having a big black bar in the way (see attached picture #1).
I guess my q...
(This is a hypothetical question for discussion, I have no actual problem).
Say that I'm making an implementation of SortedSet by extending LinkedHashMap:
class LinkedHashSortedMapThing extends LinkedHashMap implements SortedSet {
...
}
Now programmers who use this class may do
LinkedHashMap x = new LinkedHashSortedMapThing();
Bu...
Why wouldn't DoesntWork() work below? The error is:
Cannot implicitly convert type 'List' to 'IEnumerable'. An explicit conversion exists (are you missing a cast?). I know this is something about generic/templates I'm not getting, but List is IEnumerable and Implementer is an IInterface. I don't see why this needs to be casted (or if ...
Take this code:
interface ISomeInterface
{
public int SomeProperty { get; }
}
struct SomeStruct : ISomeInterface
{
int someValue;
public int SomeProperty { get { return someValue; } }
public SomeStruct(int value)
{
someValue = value;
}
}
and then I do this somewhere:
ISomeInterface someVariable = ne...
In the following code:
public class MovieRepository : IMovieRepository
{
private readonly IHtmlDownloader _downloader;
public MovieRepository(IHtmlDownloader downloader)
{
_downloader = downloader;
}
public Movie FindMovieById(string id)
{
var idUri = ...build URI...;
var html = _downlo...
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 abstra...
I dont know anything about Ienumerable object.what is the role of Ienumarble interface in .net ? Please tell me whether it is in built? Is every class in .net automatically implements the Ienumarable interface ? why there is need to implement the ienumerable interface? what are the methods it contains & what roles they plays. Please expl...
I have seen code where every class has an interface that it implements.
Sometimes there is no common interface for them all.
They are just there and they are used instead of concreate objects.
They do not offer a generic interface for two classes and are specific to the domain of the problem that the class solves.
Is there any reason to ...
I have the following code inside a method:
var list = new[]
{
new { Name = "Red", IsSelected = true },
new { Name = "Green", IsSelected = false },
new { Name = "Blue", IsSelected = false },
};
I would like to call a function that requires a list of elements with each element implementing an interface (ISelectable). I kno...
Hello,
I have a function which implement an interface. something like this:
string IMyInterface.MyFunction()
{
do something;
}
This function is available outside of my class. All working perfect.
Now I also need to call this function from another LOCAL non public function. like this:
void Func2()
{
string s;
s = MyFunction();
...
I'm working on using the Repository methodology in my App and I have a very fundamental question.
When I build my Model, I have a Data.dbml file and then I'm putting my Repositories in the same folder with it.... IE:
Data.dbml
IUserRepository.cs
UserRepository.cs
My question is simple. Is it better to build the folder struc...
I found some sample code from here.
static UIImage *backgroundImageDepressed;
/**
*
*/
@implementation DecimalPointButton
+ (void) initialize {
backgroundImageDepressed = [[UIImage imageNamed:@"decimalKeyDownBackground.png"] retain];
}
is it something like this - +(void) initialize method initialize static variables of a class...
I'm using a DSP to control a sensorless brushless DC motor, The DSP is on a board which has a parallel port and a jtag connection (it's an eZdspTMS320F2812). What would be the best way to communicate between a PC application and the DSP as it was running? Ideally I'd like to have a GUI program with buttons like start, stop, accelerate, d...
I am trying to refactor a working code. The code basically derives an interface class into a working implementation, and I want to use this implementation outside the original project as a standalone class.
However, I do not want to create a fork, and I want the original project to be able to take out their implementation, and use mine....
Sorry about the strange title. I really have no idea how to express it any better...
I get an error on the following snippet. I use the class Dummy everywhere. Doesn't the compiler understand the constraint I've added on DummyImplBase? Is this a compiler bug as it works if I use Dummy directly instead of setting it as a constraint?
Err...
I have a situation where i have a class
class Foo
{
Foo Bar()
{
return new Foo();
}
}
Now i wan tot create an interface for it
class IFoo
{
??? Bar();
}
What should be in place of the question marks? Each class should return it's own type, not Foo.
The solutions below work but do not looks clean. I don't ...
In my line of business we have Products. These products can be modified by a user by adding Modifications to them. Modifications can do things such as alter the price and alter properties of the Product. This, to me, seems to fit the Decorator pattern perfectly.
Now, envision a database in which Products exist in one table and Modificat...
I am quite the beginner - but I have a lot of experience with respect to Electrical Engineering and formulas - over 30 years worth! Trying to construct an app for the iPhone. Loaded the SDK, bought myself a Mac, got a couple of "Chapter" pages written by John at Alpha Aviation - who recomended I try this site.
How do I - well for example...