Hacking Android
> Click or hit Control-Enter to run the code above
MP6 Review
We’re going to do a few exercises in class today using MP6.
So if you haven’t already, please accept our GitHub Classroom link and have the code up either in Android Studio (best) or on GitHub.
Warm-Up Exercise
Implement a sorting algorithm of your choice…
> Click or hit Control-Enter to run the code above
Your Algorithm
What did you implement?
-
What are its best and worst case runtime?
-
What are its best and worst case inputs?
… But Most Programming Is Not Like This
(It would be kind of fun if it was, but also a bit sad.)
Course v. Real Programming
Course | Real | |
---|---|---|
You start with… |
A small amount of great code |
A large amount of complex and confusing code |
Most of your time is spent… |
Programming |
Understanding the system |
You solve problems… |
Yourself! |
By finding existing solutions |
You end up building… |
Something small |
Something really cool |
We call this… |
Doing the MP |
Hacking |
Android Hacking
Starting today you’ll be hacking on Android. MP6 also introduces you to the Microsoft Cognitive Services API.
Why Android?
How About 2 Billion Reasons…
Android Overview
iOS may be flashier, but Android is the dominant smartphone platform on Earth today—particularly outside the US.
-
2 billion active monthly users (v. 700 million for iOS)
-
24,000 different devices, both phones and tablets, as of 2015 (!)
-
2.8 million available apps (v. 2.2 million for iOS)
-
Programmed in Java, as well as other newer options like Kotlin
Don’t Worry: You’re Ready!
We chose Android because it’s the most fun and highest impact thing you can hack on as a Java programmer.
How To Hack
MP6 forces you to confront new and unfamiliar code and concepts. To do that well:
-
Look around
-
Experiment
-
Iterate
-
Imitate
Look Around
Develop loose theories about what various parts of the the code that you are working with do.
-
But don’t try to understand everything in detail until you need to
-
Some parts you will need to understand…
-
others parts you never will!
-
When you write code for others, keep this in mind when naming functions and providing documentation
Experiment
Try things!
-
Hacking requires a highly experimental mindset
-
Consider yourself a scientist performing experiments on an alien piece of code: poke it in various ways, and see what happens
-
But do good experiments: formulate hypotheses and only test one thing at a time
-
Nothing you do will launch any missiles!
Iterate
Making progress experimentally requires being able to iterate—try things again and again quickly
-
Change one small thing, run your app, collect some data, try again
-
The faster you can keep this loop, the better
-
Sometimes spending even medium amounts of time on just improving your development cycle can really pay off in the long run
Imitate (But Don’t Copy)
Find snippets of code either in your project or elsewhere that seem useful and understand and use them
-
If you can find ones that already exist in your project, that’s sometimes best since it matches the existing style and idioms
-
If you find ones online, don’t blindly copy them… you don’t learn that way
-
Instead, reproduce them in a way that’s appropriate to your goals and project
Questions About Android or MP6?
CBTF Programming
As a reminder, we’ve posted a PrairieLearn "homework" assignment
-
We’ll be moving quiz questions there each week
-
It’s not worth any credit…
-
But you should use it to practice for the kinds of programming questions you should expect to see on the exam
Announcements
-
(Obviously) MP6 is out, due a week from today on Friday. 40 point early deadline next Wednesday.
-
Get your Android environment set up! Come to office hours if you need help.
-
We’ve added an anonymous feedback form to the course website. Use it to give us feedback!
-
My office hours continue today at 11AM in the lounge outside of Siebel 0226.