|
Having no experience with this but trying to break it down!
An SMS raquires a phone connection, therefore your app is going to need a modem/phone connection. It is going to have to respond to na incoming call, answer the call and receive the message(I have no idea what the protocol is with SMS). It is then going to have to parse the message and apply the results to a query of the database.
Now you have the query what to do with it, send it back to the calling number! You will either have a register of users and numbers or a way of getting the callers number when you answer the incoming call.
You may also get a completely different approach from someone with knowledge in this area
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
A phone isn't required, you can use a service, such as Twilio to do it.
|
|
|
|
|
You can use a service such a Twilio[^] to provide an SMS gateway to your application. Your app does NOT need a phone to send/receive SMS message, but it will need it's own phone number. This can be provided by Twilio.
There are services like this sprinkled around the web, but as far as I know, none of them are free.
|
|
|
|
|
Hi,
i've downloaded a sample application from here
it has two projects; First a class library project with some classes and interfaces and another a silverlight application that has shortcuts to classes and interfaces of first one.
How can a project has shortcuts to classes of another project?
And what does it mean?
It's in that project not this! I'm confused...
Best wishes
|
|
|
|
|
The class library is compiled into a dynamic link library (dll), which is then referenced by the silverlight application. This gives the silverlight app the ability to use classes and interfaces defined in the class library project. So to use the both, you need to first compile the library project, and then add a reference to the library project in the silverlight project, using the 'add reference' link in project explorer of Visual Studio.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
In Visual Studio's 'Add Existing Item' dialog box, the 'Add' button has a drop down option called 'Add As Link' that does the job. It does not copy the file to the project folder, it just creates a shortcut to the actual file. So, the file can be shared with multiple project. This is a very dirty thing to do. Ideally, you should abstract common code into a separate class library.
|
|
|
|
|
thank you Shameel
Best wishes
|
|
|
|
|
Ideally is the word, except if you want to share code between two different versions of the CLR. This is the method that you are pretty much forced to do if you want the same code to work between WP7, Silverlight and WPF.
|
|
|
|
|
As long as you share files across same kind of projects that are targeted for different platforms, you are fine. But if you share file with projects of different nature, changing the file in one project may render the other project not compile at all (and trying to fix it may make the other project not compile). And that is something really dirty.
|
|
|
|
|
Indeed, but as I say, sometimes it's necessary. Welcome to the world of the professional WPF/Silverlight developer.
|
|
|
|
|
|
Looks good. Nice find.
|
|
|
|
|
Ok so i'm messing around with a few things, specifically interfaces.
Say I have a class 'Cat' with its base as 'Animal' Animal has a method in it like so
public virtual void Walk()
{
}
So Cat would override it with:
public override void Walk()
{
}
Simple right?
Here's my question though, is there a way to force cat to override the base Walk() method? So if another developer added a Dog class they would be forced to implement their own Walk method (even if it was just base.Walk()) ?
So interfaces kind of solves this, this is what i've tried
Cat : Animal : Interface
Animal has to implement the Walk method, but Cat doesn't
Cat : Animal, Interface
Cat has to implement the Walk method, but if the developer doesn't add or forgets the ',Interface' then it will 'break' it.
can someone give me some pointer as to go about this ?
Thanks.
|
|
|
|
|
Sort of, you can make the method abstract, then it will have to implemented somehow. It could just throw a NotImplementedException though.
|
|
|
|
|
Using an abstract method in the base Animal class prevents you from doing base.Walk() because it has no implementation.
|
|
|
|
|
Yes, but you could call it baseWalk without the dot.. or something less silly.
|
|
|
|
|
|
Collin Jasnoch wrote: not virtual. That is for overloading
Virtual is not for overloading. You do not need any special keyword overload. Both virtual and abstract are for overriding. Abstract, is a forced one while virtual is not.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
Interfaces cannot have any implementation, which is what I want
|
|
|
|
|
Well, abstract will force the subclass to implement, but that prevents you from having a base implementation.
You could do this with a pair of methods...
public void Walk()
{
WalkInternal();
}
protected abstract void WalkInternal();
This way, the subclass is forced to implement WalkInternal() , but all external calls would go to the base class's Walk() (Which can't be overridden).
|
|
|
|
|
When I need this type of functionality, I normally implement an abstract On method that the sub classes have to override. Here's an example:
public abstract class Animal
{
public void Walk()
{
Console.WriteLine("Starting the legs off now...");
OnWalk();
}
protected abstract void OnWalk();
}
|
|
|
|
|
Member 8209737 wrote: can someone give me some pointer as to go about this ?
In general it isn't usually worth time trying to get someone else to do the 'right' thing.
For example even if you force it one can still throw an exception or just call the base method (whether that is right or wrong.)
One uses interfaces and abstract classes not to force others to do the correct thing but rather to implement functionality that would otherwise be difficult, hard, impossible or obscure via some other methodology. If done correctly. If not done correctly then the design if flawed anyways so implementation details become meaningless.
One uses unit tests, system tests, etc to insure that correct functionality is implemented.
|
|
|
|
|
Member 8209737 wrote: can someone give me some pointer as to go about this ?
Does it have to be on the class level, or would it be alright to have it at the object-level (say, an event[^]?)
class SomeAnimalClass
{
public event EventHandler IsWalkin;
protected virtual void OnWalk()
{
Console.WriteLine("Doing walking stuff for " + this.GetType().Name);
EventHandler isWalkin = IsWalkin;
if (isWalkin != null)
{
isWalkin(this, EventArgs.Empty);
}
else
throw new NotImplementedException("DoWalk isn't implemented in " + this.GetType().Name);
}
public void StartWalkin()
{
OnWalk();
}
}
class Cat: SomeAnimalClass { }
class Dawg: SomeAnimalClass { }
class Program
{
static void Main(string[] args)
{
SomeAnimalClass animal = new Cat();
animal.IsWalkin += (o, s) =>
Console.WriteLine("specific walking stuff for this animal of type " + animal.GetType().Name);
animal.StartWalkin();
SomeAnimalClass otherAnimal = new Dawg();
try
{
otherAnimal.StartWalkin();
}
catch (NotImplementedException nie)
{
Console.WriteLine(nie.Message);
}
Console.ReadKey();
}
}
Output;
Doing walking stuff for Cat
specific walking stuff for this animal of type Cat
Doing walking stuff for Dawg
DoWalk isn't implemented in Dawg
Reposted, seems I did something wrong as the prev. post doesn't show up
Bastard Programmer from Hell
|
|
|
|
|
I like the idea, and someone else suggested using event as well, however I think it would add to the complexity and would make a developers life harder.
Im going to have a think and have a play around with the suggestions
|
|
|
|
|
In a word, no. The closest thing is to declare the method abstract, but as others have pointed out, you can't have an implementation together with abstract.
However, if you have a base implementation, and it's valid for the subclass simply to call base.Walk, why do you want to require it to be overridden in the first place? Subclasses which do not will inherit that version of the method anyway, essentially having an implicit 'Walk() { base.Walk{} }' in terms of usage.
There's really three common scenarios that I've seen:
- You want polymorphic behaviour, but the base class doesn't know what that might be. This is what abstract methods are for.
- You want to allow subclasses to provide behaviour, but the base class has some idea what it a sensible default. For this you should use a virtual method, even if the default action is nothing.
public virtual void Walk(){} - You know what the basic template for behaviour is, but you want subclasses to be able to customise parts of it, or you are missing information. I tend to do this with the 'MethodName'/'MethodNameInner' approach, where MethodNameInner is usually protected abstract, but if there is a reasonable default (often empty), it can be protected virtual instead.
public void Walk(){
Leg legToMove = LegToWalkWith;
legToMove.MoveForward();
}
protected abstract Leg LegToWalkWith { get; }
or more realistically (pseudocode as I can't remember exactly how this works right now):
public void ReadConfig(string configFile){
XmlDocument xmlDoc = GetXmlDocument(configFile);
XmlElement elem = xmlDoc.GetElement(ConfigNodeXpath);
foreach(XmlNode node in elem.ChildNodes){
XmlElement subelem = node as XmlElement;
if(subelem == null) continue;
}
}
protected abstract string ConfigNodeXpath { get; }
Your situation sounds more like the second scenario (you want to provide a default implementation) and therefore a virtual method should do the job nicely.
|
|
|
|