Desktop C# Mobile Comparison

Asked

Viewed 68 times

-1

I am a young man in the world of programming, the language I decided to learn was C#, and I did well to learn. These days a friend of mine gave me a good idea for a mobile app during a conversation about studies, but when I went to try to run it (now at dawn) I doubted: There is some difference between the Desktop language for mobile, but specifically android?

The doubt I have is for example, a one button code (speaking of GUI’S) that is executed by a P.C, no matter if it is by VS, is the same as the code of a button run by an android platform.

Note_1: If there are differences please specify. Remark_2: For the topic not to be voted "too open" my doubt is more specifically for graphical interface, since one thing is mouse and keyboard and another a touch screen.

1 answer

1


Yes, there is a lot of difference in the way you develop, but not in the language.

The C# language is exactly the same on any platform. Syntax and language options you will have on any platform you develop. That’s why she’s so cool. You learn a language and can deliver products to any platform: Desktop, Store App, Mobile, Xbox, Web, Iot, Cloud, Scripts, etc...

But the mode of development changes completely from one platform to another. This is due to the very characteristics and environments of these platforms. Web is request oriented, Desktop to events, Mobile Apps there are platform specific concerns, Iot is an infinite loop, Cloud in scalability and decoupling, Xbox at a performance level that in others we do not care, Scripts then is another world. But all this with the same C#.

Trying to get closer to your question:

A function executed by a button on a desktop app can be executed by a button on a mobile app?

  • Simple answer: YES

  • Correct answer: Depends

If the function to be called has a good decoupling level - no dependencies - it can be done very smoothly.

A cool example. Vc makes a Winforms to add two numbers:

protected void btnSomar_Click(object sender, EventArgs e)
{
    var primeiro = int.Parse(txtPrimeiro.Text);
    var segundo = int.Parse(txtSegundo.Text);

    lblResultado.Text = (primeiro + segundo);
}

Simple function, but very badly written, because it has a very high level of coupling and dependencies. To make a sum, it depends on having a object, arguments EventArgs, two TextBox'es and a Label to display the result. Migrating this to another platform is impossible. You really have to encode everything again.

But if we isolate the function of adding like this:

public interface IAdicao
{
    int Somar(int primeiro, int segundo);
}
public class Adicao : IAdicao
{
    public int Somar(int primeiro, int segundo)
    {
        return primeiro + segundo; 
    }
}

We can use it in our Winforms perfectly:

private readonly IAdicao _adicao = new Adicao();
protected void btnSomar_Click(object sender, EventArgs e)
{
    var primeiro = int.Parse(txtPrimeiro.Text);
    var segundo = int.Parse(txtSegundo.Text);

    var resultado = _adicao.Soma(primeiro, segundo);

    lblResultado.Text = resultado.ToString();
}

At first glance, we seem to be more complicated, but no. Because now, at the click of the button you only have some conversions to capture data from the screen and then display result. But most importantly, your business rule, the main function Soma() is completely isolated, without any dependency, and can be ported to a mobile app, to an Iot, to the Web, which will work smoothly and without having to move around in your code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.