Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Seven Mobile Apps in Seven Weeks
Nội dung xem thử
Mô tả chi tiết
Seven Mobile Apps in Seven
Weeks
Native Apps, Multiple Platforms
by Tony Hillerson
Version: P1.0 (July 2016)
Copyright © 2016 The Pragmatic Programmers, LLC. This book is licensed to the individual who
purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes.
Please don't break this trust—you can use this across all of your devices but please do not share this copy
with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was
aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The
Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the
linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no
responsibility for errors or omissions, or for damages that may result from the use of information (including
program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. We’re here because we want to improve the lives
of developers. We do this by creating timely, practical titles, written by programmers for programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better software
and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at
http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We
pioneered the beta book concept, where you can purchase and read a book while it’s still being written, and
provide feedback to the author to help make a better book for everyone. Free resources for all purchasers
include source code downloads (if applicable), errata and discussion forums, all available on the book's
home page at pragprog.com. We’re here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an
account on pragprog.com (an email address and a password is all it takes) and select the checkbox to
receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch
your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get
free updates for the life of the edition. And, of course, you can always come back and re-download your
books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices.
Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more
information, please see our FAQ at pragprog.com/frequently-asked-questions/ebooks. To learn more about
this book and access the free resources, go to https://pragprog.com/book/7apps, the book's homepage.
Thanks for your continued support,
Dave Thomas and Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Jacquelyn Carter (editor),
Potomac Indexing, LLC (indexer), Candace Cunningham, Molly McBeath (copyeditor),
Gilson Graphics (layout), Janet Furlow (producer)
For customer support, please contact [email protected].
For international rights, please contact [email protected].
Table of Contents
Acknowledgments
The Story So Far...
The Only Constant
Who Should Read This Book?
Seven Mobile Apps
The Platforms
System Requirements and Useful Tools
Don’t Get Comfortable
Online Resources
1. Day 0: Setting Up the API
Setting Up and Running the API
Reviewing and Testing the Endpoints
Now We’re Ready
Part I. Official Native Platforms
2. Mobile Web
A World-Clock App
Day 1: A Time for Beginnings
Day 2: Making Time
Day 3: Time to Move
Wrapping Up the Web App
3. iOS
A Weather-Forecast App
Day 1: What’s It Like Out?
Day 2: What’s It Like There?
Day 3: Expanding Our Horizons
Wrapping Up iOS
4. Android
A Currency-Conversion App
Day 1: How Far Does a Dollar Go?
Day 2: What Can I Get for a Buck?
Day 3: Time Is Money
Wrapping Up Android
5. Universal Windows Platform
A Stock-Quote App
Day 1: The Initial Investment
Day 2: Trending Up
Day 3: A Wider Market
Wrapping Up Windows Phone
Part II. Cross-Platform Tools
6. RubyMotion
A To-Do App
Day 1: ✓ Android
Day 2: ✓ iOS
Day 3: ✓ Cross-Platform
Wrapping Up RubyMotion
7. Xamarin
A Calculator App
Day 1: Adding Up the Platforms
Day 2: Dividing Up the Solution
Day 3: Subtracting Platform-Specific Code
Wrapping Up Xamarin
8. React Native
A Note-Taking App
Day 1: Comparing Notes
Day 2: Exchanging Notes
Day 3: Taking Note of Where We Are
Wrapping Up React Native
9. Wrapping Up
Official Native Platforms
Cross-Platform Tools
What’s Next?
Copyright © 2016, The Pragmatic Bookshelf.
Early praise for Seven Mobile Apps in
Seven Weeks
Tony does an excellent job at explaining the Xamarin concepts to first-time
users! His fun tutorials keep the reader engaged while teaching them step-bystep to create their first mobile app in C#.
→ Brandon Minnick
Customer-success engineer, Xamarin
The mobile software development landscape has never been wider than it is
today. Tony Hillerson’s Seven Mobile Apps in Seven Weeks is a wonderful
approach to showcasing the many options available for mobile application
development. You’ll find this book is a valuable learning asset regardless of
whether you’re starting fresh in the industry or looking to pick up experience on
another mobile platform. This book is the "Three Wolf Moon" of the mobile
software development world.
→ Joshua Jamison
Software engineer, Ride
This book will teach you so much about mobile native and hybrid development
by taking you on an in-depth journey exploring many approaches to create
incredible apps across all the major platforms. An incredible and versatile source
of knowledge that I recommend to any developer of any level.
→ Daniel Wanja
VP of engineering, Blinker
I found this book much more engaging than I had anticipated. I am impressed by
the author’s ability to cover the material with a delicate balance between
glossing over important details and providing too much detail— overwhelming
the reader. I highly recommend this title to anyone interested in a practical headto-head comparison of modern mobile application-development approaches.
→ Daniel Lamb
Senior software engineer; Technical architect and author, CoStar Group
Acknowledgments
When people ask where I got the concept for this book, I joke that it sprang fully
formed into my head because I needed to answer questions about or build apps
for multiple mobile platforms so many times. It certainly feels that way, but
what most likely happened was that I had hundreds of conversations with
coworkers, friends, clients, and industry experts about building apps for multiple
platforms. Add to those conversations the great esteem I have for the Seven in
Seven series, and you can see how I came to the conclusion to write this book.
So, then, thank you to all of my coworkers and friends with whom I’ve had these
conversations and built those apps over the years. We commiserated, we argued,
we experimented, we built stuff, and I learned a great deal from all of you.
Thank you also to Dave and Andy, the publishers; Bruce, the Seven in Seven
series editor; and Jackie, the editor of this book, for helping me to make this an
addition to the series that I enjoy so much. I really appreciate the opportunity.
Writing a book like this, with seven technologies, requires more eyes than just
mine on the code; it requires the help of reviewers both reviewing the book as a
whole and diving deeply into technologies as experts. Here are the reviewers
who made this book possible by finding bugs and corrections and offering style
tips and encouragement. Thanks to all of you:
Michael Hunter, Kevin Garriott, Daniel Wanja, Loren Sands-Ramshaw, Maricris
Nonato, Javier Collado, Alessandro Bahgat, Daniel Lamb, Nishant Srivastava,
Gábor László Hajba, Ramaninder Singh Jhajj, Stephen Wolff, Stefan Turalski,
Kaan Karaca, Fabrizio Cucci, Jacob Henry, Colin Gray, Seth Howard, Eric
Langland, Rob Malko, Brandon Minnick, Jack Moffitt, and Joshua Jamison.
Finally, thanks to my wife, Lori, and our kids, Diāna, Lincoln, and Titus, for
allowing me the time to write another book.
Copyright © 2016, The Pragmatic Bookshelf.
The Story So Far...
In the beginning there was a mobile platform, and it was good. It ran on the best
mobile hardware available, both phones and tablets. It had an app store, where
consumers could buy new software for their mobile devices. Developers liked to
develop for this platform because the devices had fancy UIs, powerful SDKs
were available, and people could make money from the app store to support their
development.
There was a competing platform, though, and a lot of those devices looked pretty
good, too. But it wasn’t that easy to develop on. Its marketplace wasn’t as good
and the toolset was really hard to work with. If you were a developer on the first
platform, it didn’t seem very appealing to try to learn a whole different platform.
If you had a good thing going, there was not a lot of value in learning all new
tools instead of spending time building apps you already knew how to build. The
best bet was to stick with what was comfortable and just ride that gravy train to
an early retirement.
And then everything changed.
The Only Constant
In case you didn’t already guess, the mobile platform I was just talking about
was Windows Mobile. Back in the days before the iPhone changed the mobile
space, Windows Mobile had a pretty good thing going. It already had everything
the iPhone introduced: an app store (by a different name) and good tools (for the
time), and it ran on pretty sweet devices (by those days’ standards). It had a big
competitor, or maybe more than one—who can remember back that far? The
point is that if you were making your living by developing Windows Mobile
apps then, there’s a really good chance you no longer are. Not that it would have
helped to have been proficient at more than one platform when iOS came out
and made them all pretty much obsolete. The point is not how many platforms
you’re proficient on, but rather how proficient you are at learning new platforms.
As software developers, we’ve learned that the platforms we build software on
change pretty often. If you pick a durable language to learn really well, chances
are you can get some mileage out of it, but you’re always having to learn new
SDKs, new APIs, new libraries. And of course, even languages can become
obsolete. With apologies to anyone still using it, I no longer include Cold Fusion
on my resumé.
The Seven in Seven series has always been about expanding your horizons, about
becoming a polyglot and a connoisseur of new ideas in software. You don’t learn
new languages or frameworks just because that’s a fun pastime, although it can
be, but because learning a new language, framework, or platform exposes you to
new paradigms and idioms, different ways to solve problems. At some point you
realize that recognizing the similarities and differences between languages or
platforms makes you think about building software at a higher level, no matter
what tool you’re using at the time. At some point in your career you are no
longer an “X developer”—where X is whatever platform you prefer—and instead
you have become a “software developer."
Who Should Read This Book?
To get the most out of this book, you need to buy in to the premise of the Seven
in Seven series. The best way I can express that is that you fully believe that
continually exploring and learning about software development is your
responsibility as a developer. What you get in return is the inspiration, guidance,
and interesting problems that can help you maximize your time spent learning.
That means that this book isn’t a replacement for the official documentation; it
doesn’t spend a lot of time telling you how to get set up, and the platform
coverage isn’t comprehensive. Instead, this book provides you with a very useful
tool: problems to solve in order to help you learn. Each week you’ll build a
nontrivial app over three days, and you’ll also get some ideas of how you can
take the app further yourself.
This book is focused on modern mobile platforms. Those are the “official”
platforms: mobile web, iOS, Android, and Windows. Closely related are three
cross-platform tools: RubyMotion, Xamarin, and React Native. The selling point
of these tools is that, to some greater or lesser extent, building apps for one or
more of the official platforms is easier, and you can share code between the
platforms.
If you’ve never done any mobile development before, it’s best if you have
software-development experience of some kind. This book is most helpful for
answering the following questions about each platform:
How does it feel to develop on this platform?
How does this platform compare to the others?
And, for the cross-platform tools, what are their pros and cons over
developing for one or more of the official platforms?
If you’re a software developer who wants to dive into mobile development, this
book will help you make a solid comparison between the platforms. If you’re
already a mobile developer for one platform, this book will give you a great
framework for evaluating another platform. And if you’ve ever wondered or
framework for evaluating another platform. And if you’ve ever wondered or
been asked by a client or manager if a cross-platform development tool is the
right one for the job, this book will help you answer that question about three
popular choices.
Seven Mobile Apps
Over the course of this book, we’ll build seven mobile apps. The point of
building the apps is to explore the platforms. To that end each of the apps have a
number of design goals.
App-Design Goals
Not every app hits every goal, but each reaches a large enough subset to give
you a really good taste of building for the target platform. Here is a list of design
goals.
The apps should have enough view code that you get a feel for how
interface-building works.
All apps have some level of navigation, multiple screens, or at least
multiple views.
All apps deal with displaying collections of data. This is something that
happens all the time, so we cover it.
The apps all make HTTP requests to a JSON API, so you should have a
great idea of how to request data from the web. In some cases we’ll also
post data.
Most apps include some information on designing and building interfaces
for multiple screen sizes and orientations.
Most apps give you an idea of how to store data locally.
These design goals won’t make you an expert on the platform, but they will give
you an idea of what it’s like to work with common use cases.
How a Week Works
Each platform is designed to be explored over a week. There are chapters for
three days of guided development, and each day ends with some suggested next