Lesson 01.02 Programming Basics androi

download Lesson 01.02 Programming Basics androi

of 10

Transcript of Lesson 01.02 Programming Basics androi

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    1/10

    INTRODUCTION TO JAV

    FOR ANDROID DEVELOPMLesson 1.02 Programming Basics

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    2/10

    For New ProgrammersIf you're completely new to programming, the following presentation will help you gterminology, and basics of programming.

    We'll talk about:

    Misconceptions There are a number of misconceptions when it comes to prograclear these up.

    What is an application? While most of us know what an application is from a uselet's define it from a programming perspective as well.

    Code executionLet's outline what the code does in general, and how it runs.

    Logic

    Our apps are able to make decisions. How do they achieve this?

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    3/10

    Can Anyone Learn to Program?Programming is something that anyone can learn. It isn't difficult to do so, but like eworth learning, requires patience, dedication, and practice.

    Imagine that you've just got the news that you'll be moving to a foreign country. Oyou'll do is start to learn the language of that country so you can effectively commuget there. It may take you weeks to get the basics down, and if you stick with it, in stime you'll be able to hold your own, although you'll still make mistakes and may nounderstand everything. Once you get to this new country, it may take you six montmore fluent and comfortable with the new language.

    The same thing applies to learning a programming language. You must find the timand continue to practice in order to get better at it. However, while a foreign langto learn how to read, write, speak and pronounce correctly, learning to program rebe able to write it, and read it back with understanding. Overall, it is much easier tothan to learn a foreign language, if you ask me.

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    4/10

    Programming Requires CollegeMany people are under the impression that in order to learn to program, one must acomputer science curriculum for a number of years. While there are numerous beneducation, everything you need to learn to write top notch applications is also avathat medium.

    Some benefits of learning to program on your own include:

    Learn at your own pace. Repeat what you didn't get, until you understand it.

    Real-life experience. Text book examples are rarely useful examples of how you wapplication to solve a problem. By working on your own, you're able to apply yo

    knowledge to your needs and your real-life observations. Out of the box thinkers. Colleges tend to force students towards using specific gu

    when it comes to programming. While this isn't a bad thing per se, it does limit yosolutions for a given problem.

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    5/10

    Programming Requires MathYou do not need to be a mathematician in order to write great applications. Mathprogramming, but not to the extent you might think. Math becomes more importato work on games and 3D/2D graphics, but for the majority of the work that you'll bebeyond basic mathematic skills is required.

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    6/10

    ExperienceExperience is important to being able to write applications. I've said this before, anwalk before you can run. Don't start out working on an application that is beyond yabilities. Instead, work towards it. Solve smaller problems, and gain the experienceEventually, that killer application inside your head will become a reality.

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    7/10

    ApplicationsWe certainly know what an application is from a user's perspective. We use them eour email, to write documents, to create spreadsheets, to design graphics, and matasks.

    We can define an application as something that runs on a computer's operating syone or more related tasks. I use the term "computer" loosely here, as that can repreanything with a processor and an operating system. I also want to point out that mdo not directly interact with the user, yet still meet this definition.

    From a programming perspective, we can define an application as a set of instructcomputer that help solve a problem. The problem may be as general as "I need toas precise as "calculate PI to the 120th decimal".

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    8/10

    Writing ApplicationsWriting an application is a lot like putting together a jig-saw puzzle. There are manywhich must fit together properly, and it's not done until all of those pieces are in plac

    Unlike a jig-saw puzzle, however, the programming pieces are "re-usable", and fit mthe same jig-saw puzzle. We call those re-usable pieces "classes", or "objects", and basis of "Object Oriented Programming".

    You work on creating the individual pieces first, then combine them together to maapplication.

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    9/10

    Code ExecutionYour code executes linearly, from top to bottom, left to right. For the most part, eacrepresents a single statement, which performs a single action. You can combine minto blocks of code, and identify those blocks by a name. This is known as a "functio

    Code is not dynamic and will perform the same set of steps each time it is executedbranch out to other code sections of your application, but always returns back to woff from. The code you write must handle all possible branching scenarios.

    MainCode

    Method

    A

    MethodC

    Method

    B

  • 8/10/2019 Lesson 01.02 Programming Basics androi

    10/10

    LogicYour application can make decisions through evaluation of conditions. Those condresolve to being either true or false.

    Any logic that you are going to implement in your application, must be broken dowstatements, and if the application has to make a decision as to which piece of codso based on a true / false condition.

    Example Programming a stop light (pseudo code)

    1 wait 15 seconds

    2

    if light = red then light = green3 if light = yellow then light = red

    4 if light = green then light = yellow

    5 go back to step 1

    All computer code must be broken down into these types of simple statements, regprogramming language you're planning to use to write your application in.