biscuithead

I'm in the very early planning stages of an application that will use varying types of the same hardware (let say for example sake, a sound card). I want the code to be as contained, modular and maintainable as possible. In the GUI, I want to be able to create one generic object and have that object talk to specific classes for the card specific code. In other word I don't want the GUI code to change. I think I've found a way, but I am wondering if it is the best way. So the question is, is there a better way Also can anyone recommend books and or web sites that provide tutorials on a architecture that I want

Thanks

'//not actual code...just for illustrative purposes only//
'/////////////////////////////
class form1
dim soundCard as new soundCard
end class
'/////////////////////////////
class soundCard
public SoundCard as object

if Creative then
SoundCard = new CreativeSoundCard
end if
if SoundBlaster then
SoundCard = new SoundBlasterCard
end if

public sub foo
SoundCard.foo()
end sub

end class
'/////////////////////////////
class CreativeSoundCard
public sub foo
' add creative sound card code here
end sub
end class
'/////////////////////////////
class SoundBlasterSoundCard
public sub foo
' add SoundBlaster sound card code here
end sub
end class


Re: Visual Basic General For varying hardware, what is the best way to create and implement a common interface.

SJWhiteley

Create an interface: the GUI communicates through that interface. Each 'card' implements that interface in a different way.