Programming may seem like a complex process, but on a basic level, it's not hard to comprehend. This video shows how programming works on a basic level.
- [Instructor] Before we get into writing code, let's have an overview of how programming works in general. Programming involves three main steps. First, we develop the application. Which means we create a user interface and write code. In order to get the application to run on a device, you need to first convert the code that you wrote into something a machine could understand. This process is called compiling. Compiling also creates an app file that can be executed on a device.
So the third step in the process is called execute. This is running the actual app on the appropriate device. It doesn't have to be a mobile device, it can be a computer or any other device that can run the application. So these three steps make up the programming process. Development involves creating a user interface, which usually is a drag and drop system. With an app like Android Studio, you simply drag and drop buttons, text fields, and other user interface elements onto the screen, and you can rearrange them how you like to build your application.
Then you write human-readable code with a programming language. In this course, we're using a language called kotlin. Here's some kotlin code that does a simple set of commands. Now, you may be looking at that code and thinking, that's not quite human-readable, but if you strip away some of the syntax, like the parentheses, some of the coding key words, and the curly braces, you can see that this programming language, as well as other programming languages, are based on the English language. So we have say hi, we have something that's a greeting, we can see the word textfield, and text, and then greeting again.
The next step of the programming process, compiling, is also known as build, or building the application. This converts the code into a language the appropriate targeted device can understand, and it creates an app file, or set of files, that are runnable on a device. As a developer, you don't have to worry about all the details of compiling. When you press the Run button, it happens automatically. Just as a side note for compiling, you can designate certain lines of code to be skipped or ignored by the compiler.
These are called comments, and you can create them with forward slashes or forward slashes and asterisks, and these are used to make notes to yourself or other developers, and also used to temporarily disable lines of code in your applications. Finally, executing the application involves actually installing the compiled app on a device. And then, you actually run the app on a device or in the emulator. Code is processed from top to bottom, guided by events. To think about events, imagine you have a big code file with hundreds of lines of code.
The entire code file is not processed from top to bottom. The code file designates certain areas that are triggered when an event happens. For example, a user presses a numeric button in the calculator, when that happens, we want to do a certain set of commands. So the code in that block runs, line by line, from top to bottom. It's also important to note that we don't actually see the code running line by line when we're running an application, so in the calculator application, the user presses a button, and the screen automatically gives feedback, even though there are multiple steps happening behind the scenes to present that feedback to the user.
So keep that in mind, that all the code is usually processed before the display updates. And just like compiling, if you've watched the course up to this point, you have already built and ran an application in the Android emulator. All you have to do to do it is press the Run button in Android Studio.
- Installing Android Studio, Android SDKs, and build tools
- Working with variables
- Using methods
- Connecting interface elements to methods
- Controlling flow with conditional statements, arrays, and loops
- Designing the interface
- Using themes
- Building an Android app from start to finish