Developing a new website
Before you begin any web design project for yourself or for a client, you need to answer three important questions:
- What is the purpose of the website?
- Who is the audience?
- How do they
We’ve covered a lot up to this point in the book: variables, constants, dictionaries, arrays, looping constructs, control structures, and the like. You’ve used both the REPL command-line interface and now Xcode 6’s playgrounds feature to type in code samples and explore the language.
Up to this point, however, you have been limited to mostly experimentation: typing a line or three here and there and observing the results. Now it’s time to get more organized with your code. In this chapter, you’ll learn how to tidy up your Swift code into nice clean reusable components called functions.
Let’s start this chapter with a fresh, new playground file. If you haven’t already done so, launch Xcode 6 and create a new playground by choosing File > New > Playground, and name it Chapter 4. We’ll explore this chapter’s concepts with contrived examples in similar fashion to earlier chapters.
Think back to your school years again. This time, remember high school algebra. You were paying attention, weren’t you? In that class your teacher introduced the concept of the function. In essence, a function in arithmetic parlance is a mathematical formula that takes an input, performs a calculation, and provides a result, or output.
Macaw (see Figure 1) is a new application for building responsive websites and prototypes visually. “New” in this case means less than a year old, having been released to the public in March 2014. You might have heard of its Kickstarter campaign, or read about it somewhere online, but statistically speaking, you probably aren’t familiar with Macaw yet. If you’re a working web designer or developer, and you’re interested in making responsive websites that work on many types of devices, you should absolutely check it out.
Figure 1 The Macaw UI, showing the macawbook.com project.
The Macaw website gives a nice glance at what sets it apart from the old-school visual web design applications, but in this article we’re going to dig a little deeper and talk about some of the other things that are exciting and interesting about Macaw.
In responsive web design, we use CSS media queries to create breakpoints, which tell a browser, “Here’s a condition where we want to change things around in some way with CSS.” Breakpoints are most commonly based on the width of the window or device (for example, “when the browser window is at least 600 pixels wide, do this”). Writing media queries