Categories
Uncategorized

Tampa iOS Meetup: The dreaded tip calculator, part 2

Here’s the second in a series of articles based on the most recent Tampa iOS Meetup, where I walked the group through building a tip calculator. If you’re new to iOS development, you’ll may find this series a useful introduction.

(And if you’re in the Tampa Bay area, perhaps you’d like to join us at the next Tampa iOS Meetup, currently scheduled for Tuesday, February 28th.)

Other articles in this series:

The story so far: What we did in the previous article

In the previous article, we put together a simple application featuring one button and one label:

If you tap the button, the text of the label changes to Hi there!

Right now, the app doesn’t act anything like a tip calculator should, but over this series of article, we’ll turn it into one. Along that way, you’ll become familiar with a number of aspects of iOS programming, including Xcode, the Swift programming language, and a couple of iOS user interface objects.

This article will start from where the previous article left off. You can either follow its steps, or if you prefer, you can start with the completed projects from the previous article.

What we’ll do in this article

A tip calculator has to have some way for the user to enter a dollar amount so that a tip for that amount can be calculated. In this article, we’re going to add a text field to our app as the first step in converting our simple app into a tip calculator.

By the end of this article, our app will look like this:

The user will be able to type text into the text field, and when s/he taps the Tap me button, the label will display the text in the text field:

I’ll admit that it won’t calculate tips, but by providing a text field and being able to read its contents, we’ll be a step closer to having a functioning tip calculator.

Let’s add a text field to our app

A tip calculator has to have some way for the user to enter a dollar amount so that a tip for that amount can be calculated. We’ll use a text field as that way.

We want to put the text field near the top of the view, so we’ll need to:

  • Move both the button and label farther down on the view so that there’s enough space near the top to place a text field.

Like the button and the label, the text field is a user interface object that you can get from the Object Library, which is part of the Libraries section of the Xcode interface, and located near the lower right-hand corner. Look at the lower right-hand corner and make sure that the Object Library icon is highlighted…

…and then look for the Text Field object in that list. There are a lot of objects in the Object Library, so you can either scroll around for Text Field, or you can pare down what’s shown in the list by using the Filter box at the bottom:

Do the following:

  • Type text into the box.
  • The Objects Library will respond by displaying only those objects with text in their names. One of them is the Text Field, and that’s what we want to add to our app’s view.

  • Drag a Text Field from the Object Library and onto the view. Place it near the upper left-hand corner of the view. As you bring the button close to that corner, Xcode will cause a couple of guides to appear. Line the text field up with those guides.

  • We want to provide the user with enough room to enter a few words into our text field, so widen it so that it goes about two-thirds of the way across the view.

Connect the text field to the view controller

Now that we’ve added a text field to the view, we need to make a connection between it and the view controller. In the previous article, we said that there were two kinds of connections you could make:

  1. Outlet:
    • In the view controller, an outlet is a variable that contains a reference to a specific object (such as a label, button, or text field) in the view. It’s marked with the @IBOutlet keyword, which tells Xcode that it isn’t just a variable, but an outlet.
    • Allows the code in the view controller to “talk” to an object in the view.
    • By connecting an object in the view to the view controller with an outlet, the view controller can:
      • call that object’s methods,
      • set one of its properties (such as the text it displays, its color, and so on), and
      • get the value of any of its properties.
    • The bottom line: If you want to call the methods for an object in the view, or get or set its properties, use an outlet.
  2. Action:
    • In the view controller, an action is a method that gets called in response to a specific event occurring for an object in the view (such as when a button is tapped, or the text in a text field is changed). It’s marked with the @IBAction keyword, which tells Xcode that it isn’t just a method, but an action.
    • Allows an object in the view to “talk” to the code in the view controller.
    • By connecting an object in the view to the view controller with an action, the view controller can:
      • Respond to specific events that occur for the object.
    • The bottom line: If you want to respond to the events for an object in the view, use an action.

We want a connection that will allow us to get the contents of the text field. An outlet will allow us to do that.

Once again, we’d like to have both the view (which lives the in Main.storyboard file) and the underlying view controller code (which lives in the ViewController.swift file) visible at the same time. We’ll use the Assistant Editor, which allows us to view two files side by side.

The Assistant Editor button is located near the upper right-hand corner of the Xcode interface. Do this:

  • With the main storyboard visible in the editor area in the center of Xcode, click the Assistant Editor button. Xcode tries to be “smart” about which file you want to edit, and in this case, it should “assume” that you want to look at the app’s only view’s view controller code.

You should see something like the screenshot above. You may want to expand the Xcode window so that it takes up the entire screen.

Let’s connect the text field to the view controller:

  • Select the text field on the view in the main storyboard, then control-drag (that is, drag while holding down the control key on the keyboard, or if you have a mouse, right-drag) from the view to the ViewController.swift code.
  • Let go of the mouse in the empty spot between
    @IBOutlet weak var replyLabel: UILabel!
    and
    @IBAction func buttonPressed(_ sender: Any) {

A pop-up will appear:

Do the following with the pop-up:

  • Select Outlet from the Connection menu.
  • Give the outlet a name: enter initialAmountField into the Name field.
  • Click the Connect button.

The text field is now connected to the view controller.

Changing what the button does

At this point, the code in ViewController.swift should look similar to this:

import UIKit

class ViewController: UIViewController {
  
  @IBOutlet weak var replyLabel: UILabel!
  @IBOutlet weak var initialAmountField: UITextField!
  
  @IBAction func buttonPressed(_ sender: Any) {
    replyLabel.text = "Hi there!"
  }

  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }

}

We want to change the code so that when the user taps the Tap me button, the text of the label is set to whatever text is in the text field.

The buttonPressed method — which is also an action — is executed whenever the user taps on the button, so that’s where we’ll want to make the change. Change the contents of buttonPressed so that it contains just this line:

replyLabel.text = initialAmountField.text

The code in ViewController.swift should now look like this:

import UIKit

class ViewController: UIViewController {
  
  @IBOutlet weak var replyLabel: UILabel!
  @IBOutlet weak var initialAmountField: UITextField!
  
  @IBAction func buttonPressed(_ sender: Any) {
    replyLabel.text = initialAmountField.text
  }

  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }

}

Run the app. You should see this:

Now enter some text into the text field:

Now tap the Tap me button. You’ll know the app is working as expected when the contents of the label are the same as the contents of the text field:

Now that the app can accept user input and do something simple with it, we’re a step closer to having a working tip calculator. In the next installment, we’ll make our first actual tip calculation!

Download the project files

Although this is an extremely simple project, I’ve made its files available for download — click here to get them!

Categories
Uncategorized

Beginner-friendly git tutorials and guides

At the most recent Tampa iOS Meetup, someone asked me where they could find some beginner-friendly tutorials and guides for people new to git and version control in general. I promised to post a list of them, and here they are:

Categories
Uncategorized

A lot of programming is JUST. LIKE. THIS.

Found via imgur.

Categories
Uncategorized

Florida Man writes great book for people who want to learn iOS programming

Here’s the capsule review: iOS 10 Programming for Beginners, written by fellow Tampa developer Craig Clayton, is a great book. If you’re new to programming, it’s for you, because it doesn’t assume any prior programming experience. If you have programming experience but are new to iOS programming or the Swift programming language, you’ll also find it useful. Hey, I’ve been programming for years, I have an app in the App Store, and I run Tampa iOS Meetup, and I learned a couple of things from it!

Craig knows what he’s talking — and writing — about. He organized and ran the Suncoast iOS Meetup here in Tampa as well as intensive iOS coding academies, and he makes a living writing mobile apps. If you’re a Patriots fan with an iPhone, chances are you’ve used his app (pictured on the right).

iOS 10 Programming for Beginners starts with the basics — getting familiar with Xcode, the tool used for writing iOS apps — and then spends a couple of chapters getting you up to speed with Swift through the use of programming exercises in Xcode’s playgrounds.

Once the book has provided you with enough Swift knowledge to be dangerous, it spends a couple of chapters introducing iOS’ UI elements and basic application architecture. The final two-thirds of the book is devoted to building a single application: Let’s Eat, a restaurant review app that becomes more sophisticated and gains more features with each chapter. Each chapter begins with an explanation of the topics that will be covered, and features both clear explanations of those topics, along with step-by-step instructions for turning those topics into working code. Craig does an excellent job of explaining what he did with his code and why he did it.

As you work on Let’s Eat, you’ll have built a professional-looking app that uses a number of iOS features, including GPS and maps, the camera, iPad multitasking, iMessage, and even 3D touch. When you’re done, you should be able to take the knowledge from working on the app and apply it to your own projects.

If learning iOS programming was one of your new year’s resolutions, do yourself a big favor and get your hands on iOS 10 Programming for Beginners. There’s a lot of knowledge packed into this book!

You can get the book from:

Categories
Uncategorized

Tampa iOS Meetup: The dreaded tip calculator, part 1

A new year, a new approach to the meetup, and tweaking the format

Photo by Deanna Gray.

Tampa is lucky to have three iOS meetups. In addition to my group, Tampa iOS Meetup, we’ve got:

Suncoast iOS and Tampa Bay Cocoaheads cover topics better suited for intermediate- to expert-level iOS developers, and they do so quite well. This year, I decided shift the focus of Tampa iOS Meetup towards a different audience: people who were either new to iOS development or who were new to development in general.

With that in mind, the January 2017 session of Tampa iOS Meetup (which took place on Tuesday) was about developing a simple app: a tip calculator. While a tip calculator is a simple application, even the simplest of mobile apps have a lot going on underneath the hood, what with the programming language, the application development framework(s) involved, and the IDE. I covered a fair bit of ground in my presentation, and after a little review, have decided to tweak the format.

Future Tampa iOS Meetups will have two parts:

  • A presentation part, where new concepts are introduced, followed by
  • a workshop part, where those new concepts are applied.

I think that this approach will be more useful, especially to developers who are new to iOS programming or just programming in general. It would give attendees a chance to try out the concepts while they’re still fresh in their minds, as well as a chance for me to help people with their programming.

I’d like to thank Wolters Kluwer for providing the space in which to hold the meetup, as well as the food (excellent salads) and drinks! Special thanks to John Wang, my go-to guy at Wolters Kluwer, and source of valuable feedback for my presentations.

Building the dreaded tip calculator

Let’s start by building a simple app that will grow into the tip calculator. This one will be simple — it will be an app that says “Hi there” when the user taps on a button. Over a couple of articles, we’ll make changes to it, and in the end, it will be a tip calculator.

First step: Create a new project

Start by creating a new iOS project. Launch Xcode, then use File → New → Project…. This will take you to a dialog window where you’ll choose a template, which is a pre-made set of files that you can use as a starting point for your project.

Think of Xcode’s templates as being the coding answer to templates that Office-style apps provide when you create a new document. Just as PowerPoint lets you choose from pre-made templates so you don’t have to design your deck from scratch and have more time to focus on its content…

…Xcode lets you choose from pre-made templates of code, each one designed to be the basis for a different link of app.

Here’s what the “Choose a template for your new project” windows looks like:

In this window, you should:

  • Make sure that iOS is selected in the menu near the top of the window. Xcode can be used to write applications for a number of different platforms, and you want to be certain that the project you create will run on iOS.
  • From the Application section, select Single View Application. This is a template for an app that features a single view, which corresponds to a “screen” in the app. The Single View Application template isn’t just for writing apps with single views; it’s just a template with a single view and its underlying code — a view controller — pre-defined.
  • Click the Next button to go to the next window.

The “Choose options for your next project” window lets you specify a number of options for your project. For this project, we’ll use it to specify a name for your project, leaving the other settings at their default values.

In this window, you should:

  • Enter the name of the app into the Product Name text field. I used Tip Calculator as the name for my app. This will not only be the name of the app, but the name of the folder in which its files will be stored.
  • We’re leaving the other settings at their default values, so click the Next button.

You’ll now be at the screen where you specify where the project should be saved. In this window, you should:

  • Choose a place on your hard drive where your project’s folder will be stored.
  • Make sure that the Create Git repository checkbox is checked, and that My Mac is selected from the drop-down list beside it.
  • Click the Create button, which will start the process of generating the files and folders of your project.

Xcode will spend a moment or two generating your project’s files and folders, after which you’ll be taken to a place where you’ll be spending a lot of time: the Xcode main interface.

Xcode’s main interface is divided into 5 general areas:

  1. The toolbar, which contains a number of frequently-used controls, including those for running or stopping apps, and for changing the layout of the Xcode interface.
  2. The navigators, which take up the left column of the Xcode interface and provide a number of ways of navigating about your project.
  3. The editor area, which occupies the central area of the Xcode interface. It’s where you’ll do a lot of work, including writing code, designing your apps’ user interfaces, and editing your apps’ settings and configurations.
  4. The utilities area, where you can edit the properties and settings of things that you’re working on in the editor area.
  5. The libraries area, which is a repository for user interface controls that you’ll put on your apps’ screens, as well as files, code snippets, and media that you’ll include in your projects.

Right now, we’re going to focus on the toolbar because we’re going to run the app.

Even though you haven’t yet written a single line of code or created a single user interface, you already have a working app. The Single View Application template that your app is using as its basis already contains enough code for an application that will run.

We’ll run the app in the Simulator, which comes with Xcode and can simulate any supported Apple device. It’s useful for quickly testing an app without having to load it onto a device, and handy when you want to test your app on a type of device you don’t have.

To run the app:

  • Select iPhone SE from the menu to the right of the Run (the “play” triangle) and Stop (the “stop” square) buttons in the toolbar. This tells the Simulator to simulate an iPhone SE. It’s one of the smaller-screened iPhones, and as such, it’s good for testing interface designs. If your app is usable on an iPhone SE screen, there’s a very good chance it’ll also be usable on larger-screened devices like the iPhone 6 and 7, and especially the Plus versions.
  • Click the Run button to start the app.

The simulator will take a couple of moments to start up, after which you should see this:

It’s not much to look at, but that’s because we haven’t built a user interface or added any code yet. Now that we’ve confirmed that our template runs, stop the app by clicking the Stop button:

Draw a simple user interface

It’s time to work on our app’s user interface. In order to do this, let’s take a closer look at the left column of the Xcode interface, which is where the navigators live. We’re interested in the Project Navigator, which lets us navigate through all the files that make up a project:

To show the Project Navigator, do the following:

  • Make sure that the Project Navigator is currently displayed. You can do this by clicking on the folder icon from the set of icons located at the top of the left column. The Project Navigator will display a set of files and folders that make up your project. For now, we’re interested only in the files in the Tip Calculator folder.
  • You should be able to see the contents of the Tip Calculator folder — these are files such as AppDelegate.swift, ViewController.swift, Main.storyboard, and so on. If you can’t see them, make them visible by clicking on the disclosure triangle to the left of the Tip Calculator folder.
  • Inside the Tip Calculator folder, you’ll see a file called Main.storyboard. Click on it once; this will cause the main storyboard to appear in the editing area in the center of the screen.

The storyboard is where you draw the user interfaces for the screens (or more accurately, views) of your apps. The term “storyboard” is borrowed from filmmaking; in that field, it’s a way of graphically organizing the scenes of a movie. Here’s an example — an early storyboard for a film that eventually became Star Wars: A New Hope

In Xcode, a storyboard is a way of graphically organizing the views of your app. It’s where we’ll define the user interface of our app, once we’ve done a little housekeeping.

Near the upper right-hand corner of the Xcode interface, you’ll find a set of buttons that determine what the Xcode interface shows. We’ll want to make sure that the both the left and right sidebars are visible:

Do the following:

  • Make sure that the left and right sidebars are visible by ensuring that their buttons (see the screenshot above) are selected. You’ll know that the buttons are selected when they’re highlighted blue. Feel free to click on them to see what happens, just as long as you’ve got the left and right sidebar buttons selected at the end:

Now that we’ve set up Xcode’s sidebars, let’s set up the storyboard so that its views are iPhone SE-sized. Xcode has a feature that makes it easy to design for various screen sizes, and it’s located near the center of the bottom of the Xcode interface:

Do the following:

  • Click on View as: near the center bottom of the Xcode interface. This will cause a menu of various devices to appear. If you hold the cursor over each device’s icon, its name will appear. Select the icon named iPhone SE.
  • In the menu of orientations — located to the right of the menu of devices — choose the portrait orientation.

These steps will cause the storyboard to display iPhone SE-sized views in the portrait orientation.

Now that we’ve set up the view, let’s look at the objects we’ll put into it. Look at the libraries, located near the lower right-hand corner of the Xcode interface:

Of the libraries that are available, we want to make use of the Object Library, which contains user interface objects that we can put on our app’s views. Do the following:

  • Make sure that the Object Library is selected. Click on its icon (the round one), to make sure it’s selected. Feel free to click on the other Library icons to see what happens, just as long as you’ve got Object Library selected at the end.
  • Scroll through the Object Library, where you’ll see all the objects it contains, and their descriptions. When you’re done exploring it, scroll through the list so that you can see the Button object.

It’s time to put user interface items onto the view. The first user interface item is a button:

  • Drag a Button from the Object Library and onto the view. Place it near the upper left-hand corner of the view. As you bring the button close to that corner, Xcode will cause a couple of guides to appear. Line the button up with those guides.

  • Double-click on the button to edit its title. The text in the button will be highlighted, which indicates that you are editing it.

  • Change the text in the button to Tap me.
  • Click anywhere outside the button to stop editing it.

Let’s now add a label, which is a container for read-only text that can neither be selected nor edited by the user:

  • Drag a Label from the Object Library and onto the view. Place it a short distance below the button. As you bring the label close to that view’s left edge, Xcode will cause a guide to appear. Line the label up with that guide, so that its left edge lines up with the left edge of the button.

Since this is a simple app, we’re done drawing its user interface. Time for the next step…

Connecting the interface to the underlying code

Run the app right now, and you’ll see this:

However, if you tap on the Tap me button, nothing happens. In our simple app, we want the text in the label to change to Hi there! when the user taps the Tap me button.

As its name implies, the Single View Application template that we’re building our app on comes with a single view. We just placed a button and label on that view. However, that view doesn’t do very much because we haven’t yet written any code to control that view. This view-controlling code that we’ll write will go into the view controller file, which is very conveniently named ViewController.swift in our project.

We’re going to connect the button and label in our view to the underlying view controller in this step. In order to do this, we’d like to have both the view (which lives the in Main.storyboard file) and the underlying view controller code (which lives in the ViewController.swift file) visible at the same time. This is possible with the Assistant Editor feature, which makes it possible to view two files side by side.

The Assistant Editor button is located near the upper right-hand corner of the Xcode interface. Do this:

  • With the main storyboard visible in the editor area in the center of Xcode, click the Assistant Editor button. Xcode tries to be “smart” about which file you want to edit, and in this case, it should “assume” that you want to look at the app’s only view’s view controller code.

You should see something like the screenshot above. You may want to expand the Xcode window so that it takes up the entire screen.

Let’s connect the button to the view controller code first:

  • Select the Tap me button on the view in the main storyboard, then control-drag (that is, drag while holding down the control key on the keyboard, or if you have a mouse, right-drag) from the view to the ViewController.swift code.
  • Let go of the mouse in the empty spot between
    ViewController: UIViewController {
    and
    override func viewDidLoad() {

A pop-up will appear. This pop-up lets you define the type and details of the connection between a user interface object and the underlying view controller code. There are two types of connection, and we’ll use both in this simple app:

  • Actions: An action is some code that’s run in response to an event. In the case of this app, we’re going to define an action that runs some code when the Tap me is pressed.
  • Outlets: An outlet is a reference to a user interface object, which allows the underlying code to affect that object. In this app, we’ll define an outlet that will allow us to refer to the label, which in turn will allow us to change its text.

Since we’re dealing with the button right now, we’re defining an action connection:

Do the following with the pop-up:

  • Select Action from the Connection menu.
  • Give the action a name: enter buttonPressed into the Name field.
  • Note the default selection in the Event menu, but don’t change it: Touch Up Inside. This is one of the user interaction events that a button can respond to. Touch Up Inside is an event that gets raised when the user pushes down and then releases on a button with their finger still inside the button’s bounds (which is a very precise way of saying “when the user presses the button”).
  • Click the Connect button.

The following code will appear in the view controller:

@IBAction func buttonPressed(_ sender: Any) {
}

This is a new method (that’s another term for a function) named buttonPressed, and it will be called whenever the user pressed the Tap me button.

Do the following:

  • To make the code easier to read, add blank lines before and after the newly-created method.

Let’s now define an outlet connection for the label:

  • Select the label on the view in the main storyboard, then control-drag (that is, drag while holding down the control key on the keyboard, or if you have a mouse, right-drag) from the view to the ViewController.swift code.
  • Let go of the mouse in the empty spot between
    ViewController: UIViewController {
    and
    @IBAction func buttonPressed(_ sender: Any) {

Another pop-up will appear:

Do the following with the pop-up:

  • Select Outlet from the Connection menu.
  • Give the outlet a name: enter replyLabel into the Name field.
  • Click the Connect button.

The following code will appear in the view controller:

@IBOutlet weak var replyLabel: UILabel!

This is a new variable named replyLabel, and it will be used to access the label in order to change its contents.

Do the following:

  • To make the code easier to read, add blank lines before and after the newly-created variable.

Let’s make it work!

There’s just one thing left to do: write the code that changes the text of the Label to “Hi there!” when the user presses the Tap me button. We already have a method — buttonPressed — that gets called when the button is pressed; all we have to do write the body of that method.

All it takes is one line of code to get what we want. Add the following line to buttonPressed…

replyLabel.text = "Hi there!"

…so that the method in its entirety looks like this:

@IBAction func buttonPressed(_ sender: Any) {
  replyLabel.text = "Hi there!"
}

Run the app. It should look like this:

Now press the Tap me button. You should see this:

As you can see, Hi there! got shortened to Hi t…. That’s what happens when a label doesn’t have enough space to accommodate the text it contains. There’s a simple fix…

Do the following:

  • Stop the app.
  • In the main storyboard, select the label. Grab one of the “handles” (the squares that appear around the label) on the right side of the label and use it to widen the label.
  • Run the app.

You should now see the full Hi there! when you press the Tap me button:

Wait, wasn’t this going to be a tip calculator? (or: What’s next?)

After all, the app’s name is Tip Calculator. Don’t worry — in the coming installments in this series, that’s exactly what this app will become. I thought it would be a good idea to start with a simple exercise first, in order to get you comfortable with Xcode and creating simple apps.

In the next article in the series, we’ll look at getting input from the user with text fields.

Download the project files

Although this is an extremely simple project, I’ve made its files available for download — click here to get them!

Categories
Uncategorized

Swift Algorithm Club’s call for a co-maintainer, and my answer

The call for a co-maintainer

swift algorithm clubSwift Algorithm Club — an open source project of the great iOS (and Android) tutorial site RayWenderlich.com to build implementations of useful algorithms and data structures in the Swift programming language — is looking for someone to help maintain it.

While they have two maintainers on the project (Kelvin Lau and Vincent Ngo), they could use some help, since it’s a popular GitHub project with almost 11,000 stars, over 800 watchers, and over 100 contributors. Hence their call.

The successful candidate will have the following responsibilities:

  • Deal with issues, pull requests, edit and code review submissions.
  • Help keep build server functional, especially as new submissions come in.
  • Occasionally submit new algorithms or find people to make ones we need.
  • Write a tutorial on raywenderlich.com based on something from the Swift Algorithm Club every 3 months.

If you’d like to apply, you should email Kelvin Lau with your answers to these questions:

  • Why do you want to be a co-maintainer on the Swift Algorithm Club?
  • Please tell me a little about your experience with Swift.
  • Please tell me a little about your experience with algorithms.
  • Please link to any articles/tutorials you have written online.
  • Please link to your GitHub account page.

My answer to the call

joey devilla and moshi phone

It takes great confidence to pose for a pic like this…
…the kind of confidence a co-maintainer needs!

I’m interested in the role, and emailed an application to Kelvin Lau. In the spirit of openness and collaboration, I’ve decided to share what I sent. Give it a look!


Hello, Kelvin!

I’m Joey deVilla, and I’d like to become a co-maintainer for Swift Algorithm Club!I’m a technology evangelist by day, and rock-and-roll accordion-playing mobile developer and bon vivant by night, as well as a long-time reader of RayWenderlich.com. I think I’d be well-suited for the role, and as proof, I have submitted my answers to the questions you posed in the article calling for co-maintainers.

Why do you want to be a co-maintainer on the Swift Algorithm Club?

I’ll admit it: a big part of my reason for wanting to be a co-maintainer on the Swift Algorithm Club is to be able to say “The first rule of Swift Algorithm Club is…to get ’em as close to O(1) as possible.”

But seriously, I’d like to be a co-maintainer of the Swift Algorithm Club for the following reasons:

  • I’ve been a big fan (see all the references on my tech/programming blog) and beneficiary of RayWenderlich.com over the past few years and have always wanted to join the gang.
  • I’ve been doing tech evangelism since 2000 (you can see my LinkedIn profile here), and in my current position as Technology Evangelist for Smartrac (an RFID company pivoting to an RFID-plus-software-platform kind of company), establishing good relations with the developer community is part of the job. I’d even be able to contribute to Swift Algorithm Club on company time!
  • I like helping out developers, which is why I’m in my line of work. Some evidence:My Stack Overflow profile, where my reputation score puts me in the top 6%.
  • As a tech evangelist, I don’t work directly on code with my company, and they currently don’t do iOS development anyway. Working on Swift Algorithm Club would give me a chance to keep learning, exercise my coding skills, and work with a language I love.

Please tell me a little about your experience with Swift.

Please tell me a little about your experience with algorithms.

The boring stuff: I have a degree in Computer Science from Queen’s University, which is one of Canada’s nicer schools. I learned algorithms and data structures from Dr. Robin Dawes (4.2 rating on RateMyProfessors), and we’ve stayed in touch. I know my depth-first searches from my breadth-firsts, I can pronounce Euler properly (it’s “oiler”), and I know where the word “trie” comes from (retrieval).

I once had to explain to some art students why they couldn’t represent all the possible states of their game using individual QuickTime cells. It was a “Virtual Bubble Wrap” game with 95 bubbles, which meant that it would take 2^95 cells to represent every possible state (for comparison’s sake, the estimated number of photons in the universe is a smaller number: 10^89).

The more interesting experience: I am “internet famous” for using P=NP to figure out that I was dating a con artist. The story is on my personal blog under the title What happened to me and the new girl (or: “The girl who cried Webmaster”), and ended up in print in an anthology titled Never Threaten to Eat Your Co-Workers: Best of Blogs. 

Please link to any articles/tutorials you have written online.

I’ve been blogging since November 2001, with my personal blog, The Adventures of Accordion Guy in the 21st Century. I started my personal tech blog, Global Nerdy, in August 2006, and since then have written over 3,000 posts which have acquired over 8.6 million pageviews.

Here’s a small sampling of what I’ve written:

I should also mention that while working at Microsoft as the Windows Phone evangelist (the second-hard evangelism job in mobile), I had a short-lived children’s show, complete with puppet co-host. Here’s the first episode: How to create your own games with Kodu

Please link to your GitHub account page.

I’ll admit that it’s not as fat as I would like, but here it is: https://github.com/AccordionGuy

If you have any questions or need additional information about me and my qualifications, please feel free to contact me!

— Joey

Categories
Uncategorized

My plans for 2017, part 2: Journey back to Java (or: What helped me land my new job)

java

target

Another of my goals for this year is to considerably raise my proficiency with a programming language I thought I’d never use again, despite its ubiquity: Java.

Until last year — and by “last year”, I mean 2016 — I hadn’t done anything with Java since I looked like this…

joey-devilla-2000

…and since the preferred Java IDE looked like this…

jbuilder-3-screenshot

…and was distributed via something like this:

jbuilder-3-cd

That all changed thanks to the Tampa iOS Meetup, a regular gathering for people interested in learning how to develop iOS apps:

Angela Don and I started Tampa iOS Meetup in October 2015, fresh off a successful “Intro to iOS Programming with Swift” presentation at BarCamp Tampa Bay. The BarCamp presentation in turn was the result of our meeting at Ybor Tech OpenHack, a monthly gathering of programmers for conversation over beer at New World Brewery, one of Tampa’s better beer pubs.

target

The moral of the paragraph above is one I’ve been touting for years: if you want opportunities, you’ve got to network. One of my goals this year is to turn up my outreach, not just in the Tampa Bay area where I live, and not just nation-wide, but globally.

Java homework, after 16 years

At one of the meetups, one of the attendees asked me for help with an assignment for a Java course he was taking. I told him that I’d be happy to help, but warned him that it had been over a decade since I’d written anything in it. While C# (with which I have more recent experience) is similar to Java, it’s not the same thing. He was undeterred, and we arranged to meet at a coffee shop, where I could help him as he did the assignment.

Our meeting never happened. Between putting in a lot of overtime at work and tending to his family in the remaining time, he didn’t have any time to do the assignment and didn’t even have any idea of where to begin.

“I need it by tomorrow. Could you do it for me? Just tell me your hourly rate, and I’ll pay you,” he said.

“Look, let me see if I can even do it first,” I replied. “We can talk money later.”

“I’ll send you my assignment,” he said, “and it has to be done using JavaFX.”

“JavaFX it is,” I said, making a mental note to Google the term.

The first assignment

netbeans-borg

After spinning my wheels for what felt like an eternity trying to get a project using JavaFX (which turned out to be a GUI library) running using Eclipse (a.k.a. the worst IDE ever), I switched to NetBeans and had a simple “Hello World!” program operational in a few minutes.

With what remained of the evening, I now had to do the actual assignment: given a full filename that the user enters, read the contents of that file, and then display all the words in that file in an alphabetically-sorted list.

A couple of hours later — and some Googling for reference material on Java Lists, file operations, and JavaFX UI elements — I surprised myself with a working program:

sorted-file-words

After cleaning up the code and adding some Javadoc comments in order to make it academically complete, I emailed him the code (for the curious, it’s on GitHub). A couple of days later, he told me that he got full marks for the assignment. I was pleased with myself, and thought that this would be my last encounter with Java.

One good assignment deserves another

help

A couple of days later, he made a second call for help. I gave him a couple of pointers to put him in the right direction, but after a number of impassioned pleas, I ended up coding the whole thing. This time, it was a “states and capitals” quiz, complete with pop-up windows for right and wrong answers:

states-and-capitals

I used an Iterator to “step through” the set of states and capitals, which were stored in a Hashmap. I worried that using it might have been beyond the scope of the assignment, but it greatly simplified the code. My friend got full marks for the project, which you can find on GitHub.

The third time’s the charm

help-me-obi-wan

Good things come in threes, and with two assignments that earned full marks, my friend asked for help with the final assignment: the clichéd-yet-mandatory “access a database and display some of its contents” assignment. Here’s the text of the assignment, which for some reason was set in Comic Sans, which I’m sure is not the official font of Serious Database Work:

Create a JavaFX GUI that allows the user to retrieve records from the customers table in the “pcparts” database. The GUI should allow the user to specify desired fields, desired order, and a where condition. Display only the desired fields in the desired order for the desired where condition. You may display the records in the GUI in any way you wish.

This time, there wasn’t even any pretense that I’d provide tips and he’d write the program. I just told him to check his inbox later that night.

Here’s what my implementation looked like:

database-app

Once again, you can see it on GitHub.

As with the other two assignments, it was an evening’s worth of work, most of the time spent Googling for information about JDBC and Java ObservableLists. With the completion and submission of this assignment — and the full marks he got for it — my friend successfully completed his Java course.

“And that,” I thought, “will likely be the last I’ll see of Java for a while.” I decided that the projects shouldn’t go to waste sitting on my hard drive and posted them to my GitHub account, which needed some fattening anyway.

A headhunter comes a-callin’ (with a test)

recruiter

A couple of months later, I got an email from a recruiter. Thanks to my online presence, I get these on a regular basis, but this one was intriguing:

Hi Joey,

I’m an IT Recruiter with [recruiting company], I came across your profile and was impressed with your skills and background so I wanted to reach out to you regarding an exciting opportunity!

Our client is looking to hire a Developer Evangelist to join their growing team based out of Baltimore, MD. They are looking for someone that is passionate about technology and can provide code samples, white papers, blog postings, and other educational content in order to demonstrate the power of our client’s platform. The role is 50% travel but in between trips to trade shows and conferences all of the work would be remote.

Unlike most of the recruiting emails I get, this one seemed worth replying to, and a day later, I had a phone interview. It went well enough for them to ask me for a resume, references, and — horror of horrorstake a timed online Java proficiency test.

“And this is where I’ll get taken out of the running,” I thought. There’s been at least one time when I’ve failed a test on a language that I was comfortable with and used regularly; how the hell was I going to pass test for Java, which I’d made a career of avoiding and with which I hadn’t worked with in 16 years, with the exception of those homework assignments?

I still went along with the process and took the test. I managed to answer a number of its questions, and a lot of that was thanks to the Java practice I got from doing my friend’s assignments. Despite that, I figured I’d get the “Sorry, you didn’t make the cut” email in a couple of days.

Instead, I got a call: “Congratulations! The platform architect and product manager would like to schedule an interview with you.”

The interview

octocat

All my interviews were conducted via Skype. The first and most crucial one was with Product Manager Jason Rusk (to whom I report) and Platform Architect Robert van Voorhees. During the interview, Robert asked if I had anything posted on GitHub, especially in Java. I pointed him to the assignments, and he gave them a quick once-over.

“Good clean code, easy to follow, nice notes,” he said, nodding approvingly.

Approved!

approved-by-spider-man

On the 15th of September, I got an email that started like this:

Hi Joey,

Congratulations again on your offer from SMARTRAC. I have attached a copy of your contract for you to look over. They would like to offer you an hourly rate of $[ask me in person over a beer]/hr and a conversion salary of $[again, ask me in person over a beer].

Moving forward

smart-cosmos-logo

Smartrac’s Smart Cosmos platform is largely written in Java. While I’m not likely to contribute code to it, I’ll most certainly help partners and customers integrate with it. Furthermore, many of these other people may be coding in Java, and I’ll need to provide code samples in their language. Hence this year’s push to go back to Java after studiously avoiding it for nearly two decades.

Luckily for me, Smartrac hooked me up with IntelliJ IDEA Ultimate, a Java IDE that’s light-years better than NetBeans (and thousands of light-years better than Eclipse)…

…and I’ve been making the most of my spare moments getting Java practice in the form of Android development. Even at the airport, when my flights are delayed by hours:

android-development

target

None of this would’ve come about had I not helped my friend with his homework, so I suppose another one of my 2017 plans should be to help people learn to code when I can. You never know how it’ll pay off!