Comparison of C # mobile for Desktop

0

I'm a young man in the world of programming, the language I decided to learn was C #, and I got on well in learning. 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 execute it (now at dawn) I came to doubt: Is there any difference between the Desktop language and the mobile language, but specifically android?

The question I have is, for example, a one-button code (speaking of GUI'S) that is executed by a PC, regardless of whether it is by VS, is the same as the code of a button executed by an android platform.

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

    
asked by anonymous 11.04.2017 / 06:56

1 answer

2

Yes, there is a lot of difference in how to develop, but not in language.

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

But the mode of development changes completely from platform to platform. 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 endless loop, Cloud in scalability and decoupling, Xbox in a level of performance 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:

  

Can a function executed by a button on a desktop App run by a button on an App mobile?

  • Simple answer: SIM

  • Correct answer: Depends

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

A legal example. You make 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 but very poorly written function, because it has a very high level of coupling and dependencies. To make a sum, it depends on having object , arguments EventArgs , two TextBox 'es, and Label to display the result. Migrating this to another platform is impossible. You really have to code everything over again.

But if we isolate the function of adding it 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, it seems that we complicate more, but not. For now, on the click the button you only have a few conversions to capture screen data and then display result. But most importantly, your business rule, the main Soma() function is completely isolated, with no dependency, and can be ported to a mobile app, to an IoT, to the Web, which will work without problems and without having to mess with walk in your code.

    
11.04.2017 / 09:11