You are on page 1of 116

1992-2014 by Pearson Education, Inc.

All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Computers process data under the control of sequences of


instructions called computer programs.
These programs guide computers through actions specified
by people called computer programmers.
The programs that run on a computer are referred to as
software.
Youll learn object-oriented programmingtodays key
programming methodology thats enhancing programmer
productivity, and reducing software development costs.
Youll create many software objects that model both abstract
and real-world things.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

A computer consists of various devices referred to as


hardware, such as the keyboard, screen, mouse, hard disks,
memory, DVD drives, printer and processing units).
Every year or two, the capacities of computer hardware
have approximately doubled inexpensively.
This remarkable trend often is called Moores Law, named
for the person who identified it, Gordon Moore, co-founder
of Intelthe leading manufacturer of the processors in
todays computers and embedded systems, such as
smartphones, appliances, game controllers, cable set-top
boxes and automobiles.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Moores Law and related observations apply especially to

the amount of memory that computers have for running programs


and processing data
the amount of secondary storage (such as hard disk storage) they
have to hold programs and data over longer periods of time
their processor speedsthe speeds at which computers execute their
programs (i.e., do their work).

Similar growth has occurred in the communications field, in


which costs have plummeted as enormous demand for
communications bandwidth (i.e., information-carrying
capacity) has attracted intense competition.
Such phenomenal improvement is truly fostering the
Information Revolution and creating significant career
opportunities.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Data items processed by computers form a data hierarchy


that becomes larger and more complex in structure as we
progress from the simplest data items (called bits) to
richer data items, such as characters, fields, and so on.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Bits
The smallest data item in a computer can assume the value 0
or the value 1.
Such a data item is called a bit (short for binary digita
digit that can assume either of two values).
Its remarkable that the impressive functions performed by
computers involve only the simplest manipulations of 0s and
1sexamining a bits value, setting a bits value and reversing
a bits value (from 1 to 0 or from 0 to 1).

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Characters
We prefer to work with decimal digits (09), uppercase
letters (AZ), lowercase letters (az), and special symbols
(e.g., $, @, %, &, *, (, ), , +, ", :, ? and / ).
Digits, letters and special symbols are known as characters.
The computers character set is the set of all the characters
used to write programs and represent data items on that
device.
Computers process only 1s and 0s, so every character is
represented as a pattern of 1s and 0s.
The Unicode character set contains characters for many of
the worlds languages.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

C# supports several character sets, including 16-bit


Unicode characters that are composed of two byteseach
byte is composed of eight bits.
See Appendix B for more information on the ASCII
(American Standard Code for Information Interchange)
character setthe popular subset of Unicode that represents
uppercase and lowercase letters in the English alphabet,
digits and some common special characters.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Fields
Just as characters are composed of bits, fields are composed
of characters or bytes.
A field is a group of characters or bytes that conveys
meaning.
For example, a field consisting of uppercase and lowercase
letters could be used to represent a persons name, and a field
consisting of decimal digits could represent a persons age.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Records
Several related fields can be used to compose a record.
In a payroll system, for example, the record for an employee
might consist of the following fields (possible types for these
fields are shown in parentheses):

Employee identification number (a whole number)


Name (a string of characters)
Address (a string of characters)
Hourly pay rate (a number with a decimal point)
Year-to-date earnings (a number with a decimal point)
Amount of taxes withheld (a number with a decimal point)

Thus,

a record is a group of related fields.


In the preceding example, all the fields belong to the same
employee.
1992-2014 by Pearson Education, Inc.
All Rights Reserved.

Files
A file is a group of related records.
More generally, a file contains arbitrary data in arbitrary
formats.
In some operating systems, a file is viewed simply as a
sequence of bytesany organization of the bytes in a file,
such as organizing the data into records, is a view created by
the programmer.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Database
A database is a collection of data thats organized for easy
access and manipulation.
The most popular database model is the relational database
in which data is stored in simple tables.
A table includes records composed of fields.

For example, a table of students might include first name, last name,
major, year, student ID number and grade point average fields.
The data for each student is a record, and the individual pieces of
information in each record are the fields.

You

can search, sort and otherwise manipulate the data


based on its relationship to multiple tables or databases.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Big Data
The amount of data being produced worldwide is enormous
and growing explosively.
According to IBM, approximately 2.5 quintillion bytes (2.5
exabytes) of data are created daily and 90% of the worlds
data was created in just the past two years!
(www-01.ibm.com/software/data/bigdata/)

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Computers can be envisioned as divided into various logical


units or sections:

Input Unit
This receiving section obtains information (data and computer programs)
from input devices and places it at the disposal of the other units for
processing.
Most information is entered into computers through keyboards, touch
screens and mouse devices.
Other forms of input include receiving voice commands, scanning images
and barcodes, reading from secondary storage devices (such as hard drives,
CD drives, DVD drives, Blu-Ray Disc drives and USB flash drives),
receiving video from a webcam or smartphone and having your computer
receive information from the Internet (such as when you download videos
from YouTube or e-books from Amazon).

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Output Unit
This shipping section takes information that the computer
has processed and places it on various output devices to make
it available for use outside the computer.
Most information thats output from computers today is
displayed on screens; printed on paper; played as audio or
video on PCs and media players and giant screens in sports
stadiums; transmitted over the Internet or used to control other
devices.
Computers also can output their information to networks, such
as the Internet.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Memory Unit

This rapid-access, relatively low-capacity warehouse


section retains information thats entered through the
input unit, making it immediately available for processing
when needed.
The memory unit also retains processed information until
it can be placed on output devices by the output unit.
Information in the memory unit is volatileits typically
lost when the computers power is turned off.
The memory unit is often called either memory or
primary memory.
1992-2014 by Pearson Education, Inc.
All Rights Reserved.

Arithmetic and Logic Unit (ALU)

This manufacturing section performs calculations,


such as addition, subtraction, multiplication and
division.
It also contains the decision mechanisms that allow the
computer, for example, to compare two items from the
memory unit to determine whether theyre equal.
In todays systems, the ALU is usually implemented as
part of the next logical unit, the CPU.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Central Processing Unit (CPU)

This administrative section coordinates and


supervises the operation of the other sections.
The CPU tells the input unit when information should
be read into the memory unit, tells the ALU when
information from the memory unit should be used in
calculations and tells the output unit when to send
information from the memory unit to certain output
devices.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Many of todays computers have multiple CPUs and,


hence, can perform many operations simultaneously.
A multi-core processor implements multiple processors
on a single microchipa dual-core processor has
two CPUs and a quad-core processor has four CPUs.
Many of todays desktop computers have quad-core
processors that can execute billions of instructions per
second.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Secondary Storage Unit

This is the long-term, high-capacity warehousing section.


Programs or data not actively being used by the other units
normally are placed on secondary storage devices (such as your
hard drive) until theyre again needed, possibly hours, days,
months or even years later.
Information on secondary storage devices is persistentits
preserved even when the computers power is turned off.
Secondary storage data takes much longer to access than
information in primary memory, but the cost per unit of
secondary storage is much less than that of primary memory.
Examples of secondary storage devices include CD drives, DVD
drives and flash drives, some of which can up to 2 TB (TB stands
for terabytes; a terabyte is approximately one trillion bytes).

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Programmers write instructions in various


programming languages (such as C#), some directly
understandable by computers and others requiring
intermediate translation steps.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Machine Languages
Any computer can directly understand only its own machine
language, defined by its hardware architecture.
Machine languages generally consist of numbers, ultimately
reduced to 1s and 0s.
The term code has become more broadly used and now
refers to the program instructions in all levels of programming
languages.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Assembly Languages and Assemblers


Machine language was simply too slow and tedious for
programmers to work with.
Instead, programmers began using English-like
abbreviations to represent elementary operations.
These abbreviations formed the basis of assembly
languages.
Translator programs called assemblers convert
assembly-language programs to machine language
quickly.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

High-Level Languages, Compilers and


Interpreters
To speed up the programming process, high-level
languages were developed in which single statements
could be written to accomplish substantial tasks.
High-level languages, such as C#, Visual Basic, C++,
C, Objective-C and Java, allow you to write
instructions that look almost like everyday English and
contain commonly used mathematical expressions.
Translator programs called compilers convert highlevel-language code into machine language code.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Objects, or more precisely the classes objects come from,


are essentially reusable software components.

There are date objects, time objects, audio objects, video objects,
automobile objects, people objects, etc.
Almost any noun can be reasonably represented as a software object
in terms of attributes (e.g., name, color and size) and behaviors (e.g.,
calculating, moving and communicating).

Using a modular, object-oriented design-andimplementation approach can make software-development


groups much more productive than was possible with earlier
techniquesobject-oriented programs are often easier to
understand, correct and modify.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The Automobile as an Object


Lets

begin with a simple analogy.


Suppose you want to drive a car and make it go faster by
pressing its accelerator pedal.
Before you can drive a car, someone has to design it.
A car typically begins as engineering drawings, similar to the
blueprints that describe the design of a house.
Drawings include the design for an accelerator pedal.
Pedal hides from the driver the complex mechanisms that
actually make the car go faster, just as the brake pedal hides the
mechanisms that slow the car, and the steering wheel hides the
mechanisms that turn the car.
1992-2014 by Pearson Education, Inc.
All Rights Reserved.

Enables people with little or no knowledge of how


engines, braking and steering mechanisms work to
drive a car easily.
Before you can drive a car, it must be built from the
engineering drawings that describe it.
A completed car has an actual accelerator pedal to
make the car go faster, but even thats not enoughthe
car wont accelerate on its own (we hope), so the driver
must press the pedal to accelerate the car.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Methods and Classes


Performing a task in a program requires a method.
Houses the program statements that actually perform its
task.
Hides these statements from its user, just as the
accelerator pedal of a car hides from the driver the
mechanisms of making the car go faster.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

In object-oriented programming languages, we create a


program unit called a class to house the set of methods
that perform the classs tasks.
A class is similar in concept to a cars engineering
drawings, which house the design of an accelerator
pedal, steering wheel, and so on.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Making Objects from Classes


Just as someone has to build a car from its engineering
drawings before you can actually drive a car, you must
build an object from a class before a program can
perform the tasks that the classs methods define.
The process of doing this is called instantiation.
An object is then referred to as an instance of its class.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Reuse
Just as a cars engineering drawings can be reused many
times to build many cars, you can reuse a class many
times to build many objects.
Reuse of existing classes when building new classes and
programs saves time and effort.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Reuse also helps you build more reliable and effective


systems, because existing classes and components
often have gone through extensive testing, debugging
and performance tuning.
Just as the notion of interchangeable parts was crucial
to the Industrial Revolution, reusable classes are crucial
to the software revolution that has been spurred by
object technology.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Messages and Method Calls


When you drive a car, pressing its gas pedal sends a
message to the car to perform a taskthat is, to go faster.
Similarly, you send messages to an object.
Each message is implemented as a method call that tells
a method of the object to perform its task.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Attributes and Instance Variables


A car has attributes
Its color, its number of doors, the amount of gas in its tank, its
current speed and its record of total miles driven (i.e., its
odometer reading).
The

cars attributes are represented as part of its design


in its engineering diagrams.
Every car maintains its own attributes.
Each car knows how much gas is in its own gas tank,
but not how much is in the tanks of other cars.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

An object has attributes that it carries along as its used


in a program.
Specified as part of the objects class.
A bank account object has a balance attribute that
represents the amount of money in the account.
Each bank account object knows the balance in the
account it represents, but not the balances of the other
accounts in the bank.
Attributes are specified by the classs instance
variables.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Encapsulation
Classes encapsulate (i.e., wrap) attributes and methods
into objectsan objects attributes and operations are
intimately related.
Objects may communicate with one another, but theyre
normally not allowed to know how other objects are
implementedimplementation details are hidden within
the objects themselves.
Information hiding is crucial to good software
engineering.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Inheritance
A new class of objects can be created quickly and
conveniently by inheritancethe new class absorbs the
characteristics of an existing class, possibly customizing
them and adding unique characteristics of its own.
In our car analogy, an object of class convertible
certainly is an object of the more general class
automobile, but more specifically, the roof can be
raised or lowered.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Object-Oriented Analysis and Design (OOAD)


To

create the best solutions, you should follow a detailed


analysis process for determining your projects requirements
(i.e., defining what the system is supposed to do)
Develop a design that satisfies them (i.e., deciding how the
system should do it).
Carefully review the design (and have your design reviewed by
other software professionals) before writing any code.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

If this process involves analyzing and designing your


system from an object-oriented point of view, its called
an object-oriented analysis and design (OOAD)
process.
Languages like C# are object oriented.
Object-oriented programming (OOP) allows you to
implement an object-oriented design as a working
system.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The UML (Unified Modeling Language)


The Unified Modeling Language (UML) is now the
most widely used graphical scheme for modeling objectoriented systems.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

In the late 1960s, ARPAthe Advanced Research


Projects Agency of the Department of Defenserolled
out plans to network the main computer systems of
approximately a dozen ARPA-funded universities and
research institutions.
ARPA implemented what quickly became known as the
ARPAnet, the precursor of todays Internet.
Its main benefit proved to be the capability for quick
and easy communication via e-mail.
This is true even on todays Internet, with e-mail,
instant messaging, file transfer and social media such
as Facebook and Twitter, enabling billions of people
worldwide to communicate quickly and easily.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The protocol (set of rules) for communicating over the


ARPAnet became known as the Transmission Control
Protocol (TCP).
TCP ensured that messages, consisting of sequentially
numbered pieces called packets, were properly routed
from sender to receiver, arrived intact and were
assembled in the correct order.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The Internet: A Network of Networks


In parallel with the early evolution of the Internet,
organizations worldwide were implementing their own
networks for both intraorganization (that is, within an
organization) and interorganization (that is, between
organizations) communication.
One challenge was to enable these different networks to
communicate with each other.
The Internet Protocol (IP) created a true network of
networks, the current architecture of the Internet.
The combined set of protocols is now called TCP/IP.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Businesses rapidly realized that by using the Internet,


they could improve their operations and offer new and
better services to their clients.
This generated fierce competition among
communications carriers and hardware and software
suppliers to meet the increased infrastructure demand.
As a result, bandwidththe information-carrying
capacity of communications lineson the Internet has
increased tremendously, while hardware costs have
plummeted.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The World Wide Web (simply called the web) is a


collection of hardware and software associated with the
Internet that allows computer users to locate and view
multimedia-based documents (documents with various
combinations of text, graphics, animations, audios and
videos) on almost any subject.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

In 1989, Tim Berners-Lee of CERN (the European


Organization for Nuclear Research) began to develop a
technology for sharing information via hyperlinked
text documents.
Berners-Lee called his invention the HyperText
Markup Language (HTML).
He also wrote communication protocols such as
HyperText Transfer Protocol (HTTP) to form the
backbone of his new hypertext information system,
which he referred to as the World Wide Web.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

In 1994, Berners-Lee founded the World Wide Web


Consortium (W3C), devoted to developing web
technologies.
One of the W3Cs goals is to make the web accessible to
everyone regardless of disabilities, language or culture.
Youll use C# and other Microsoft technologies to build
web-based apps.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

In 2000, Microsoft announced the C# programming


language.
C# has roots in C, C++ and Java.
C# has similar capabilities to Java and is appropriate for the
most demanding app-development tasks, especially for
building todays large-scale enterprise apps, and web-based,
mobile and cloud-based apps.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

C# is object oriented.
C# has access to the powerful .NET Framework Class
Librarya vast collection of prebuilt classes that enable
you to develop apps quickly.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

C# is event driven.
Youll write programs that respond to user-initiated
events such as mouse clicks, keystrokes, timer
expirations andnew in Visual C# 2012touches and
finger swipesgestures that are widely used on
smartphones and tablets.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Microsofts Visual C# is a visual programming


languagein addition to writing program statements
to build portions of your apps, youll also use Visual
Studios graphical user interface to conveniently drag
and drop predefined objects like buttons and
textboxes into place on your screen, and label and
resize them.
Visual Studio will write much of the GUI code for
you.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

C# has been standardized internationally.


This enables other implementations of the language
besides Microsofts Visual C#, such as Mono
(www.mono-project.com) that runs on Linux
systems, iOS (for Apples iPhone, iPad and iPod
touch), Googles Android and Windows.
You can find the C# standard document at:

www.ecma-international.org/publications/
standards/Ecma-334.htm

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Todays apps can be written with the aim of


communicating among the worlds computers.
As youll see, this is the focus of Microsofts .NET
strategy.
In Chapters 23, 29 and 30, youll build web-based
apps with C# and Microsofts ASP.NET technology.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

In most programming today, each task in a program must


finish executing before the next task can begin.
This is called synchronous programming and is the style
we use for most of this book.
C# also allows asynchronous programming in which
multiple tasks can be performed at the same time.
Asynchronous programming can help you make your
apps more responsive to user interactions, such as mouse
clicks and keystrokes, among many other uses.
Visual C# 2012s new async and await capabilities
simplify asynchronous programming, because the
compiler hides much of the associated complexity from
the developer.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Figure 1.4 summarizes some popular programming


languages with features comparable to those of C#.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

In 2000, Microsoft announced its .NET initiative, a broad


vision for using the Internet and the web in the
development, engineering, distribution and use of software.
.NET permits developers to create apps in any .NETcompatible language (such as C#, Visual Basic and many
others).
Part of the initiative includes Microsofts ASP.NET
technology, which is used to create web apps that users
interact with via their web browsers.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The .NET Framework contains the .NET Framework Class


Library, which provides many capabilities that youll use to
build substantial C# apps quickly and easily.
The .NET Framework Class Library has thousands of
valuable prebuilt classes that have been tested and tuned to
maximize performance.
Youll learn how to create your own classes, but you should
re-use the .NET Framework classes when possible to speed
up the software development process, while enhancing the
quality and performance of the software you develop.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The Common Language Runtime (CLR) executes .NET


programs and provides functionality to make them easier to
develop and debug.
The CLR is a virtual machine (VM)software that
manages the execution of programs and hides from them the
underlying operating system and hardware.
The source code for programs that are executed and
managed by the CLR is called managed code.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The CLR provides various services to managed code, such


as integrating software components written in different
.NET languages, error handling between such components,
enhanced security, automatic memory management and
more.
Unmanaged-code programs do not have access to the CLRs
services, which makes unmanaged code more difficult to
write. (msdn.microsoft.com/en-us/library/8bs2ecf4.aspx)

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Managed code is compiled into machine-specific


instructions in the following steps:
First, the code is compiled into Microsoft Intermediate Language
(MSIL). Code converted into MSIL from other languages and
sources can be woven together by the CLRthis allows
programmers to work in their preferred .NET programming
language. The MSIL for an apps components is placed into the apps
executable filethe file that causes the computer to perform the
apps tasks.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

When the app executes, another compiler (known as the just-in-time


compiler or JIT compiler) in the CLR translates the MSIL in the
executable file into machine-language code (for a particular
platform).
The machine-language code executes on that platform.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

If the .NET Framework exists and is installed for a platform, that


platform can run any .NET program.
The ability of a program to run without modification across multiple
platforms is known as platform independence.
Code written once can be used on another type of computer without
modification, saving time and money.
Previously, companies had to decide whether converting their programs
to different platformsa process called portingwas worth the cost.
With .NET, porting programs is no longer an issue, at least once .NET
itself has been made available on the platforms.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

The .NET Framework provides a high level of language


interoperability.
Because software components written in different .NET languages
(such as C# and Visual Basic) are all compiled into MSIL, the
components can be combined to create a single unified program.
Thus, MSIL allows the .NET Framework to be language independent.
.NET 4.5 features .NET for Windows Store Appsa subset of .NET
thats used to create Windows 8 UI (user interface) style apps.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Windows is the most widely used desktop operating system


worldwide.
Operating systems are software systems that make using
computers more convenient for users, app developers and
system administrators.
They provide services that allow each app to execute safely,
efficiently and concurrently (i.e., in parallel) with other
apps.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Windows Store
You can sell Windows 8 UI desktop and tablet apps or offer
them for free in the Windows Store.
The fee is waived for Microsoft DreamSpark program
students (see the Preface).
To learn more about the Windows Store and monetizing your
apps, visit
msdn.microsoft.com/en-us/library/windows/
apps/br229519.aspx.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Windows Phone 8 is a pared down version of Windows 8


designed for smartphones.
Windows Phone 8 has the same core operating systems
services as Windows 8, including a common file system,
security, networking, media and Internet Explorer 10 (IE10)
web browser technology.
However, Windows Phone 8 has only the features necessary
for smartphones, allowing them to run efficiently,
minimizing the burden on the devices resources.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

You can sell your own Windows Phone apps in the


Windows Phone Marketplace
(www.windowsphone.com/marketplace).
You can also earn money by making your apps free for
download and selling virtual goods (e.g., additional content,
game levels, e-gifts and add-on features) using in-app
purchase.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Paid Windows Phone 8 apps range in price from $1.49


(which is higher than the $0.99 starting price for apps in
Google Play and Apples App Store) to $999.99.
The average price for mobile apps is approximately $1.50 to
$3, depending on the platform.
For Windows Phone apps, Microsoft retains 30% of the
purchase price and distributes 70% to you.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

You can test your phone apps on the Windows Phone


Emulator that Microsoft provides with the Windows Phone
8 SDK (software development kit).
To test your apps on a Windows phone and to sell your apps
or distribute your free apps through the Windows Phone
Marketplace, you'll need to join the Windows Phone Dev
Center.
The program is free to DreamSpark students.
The website includes development tools, sample code, tips
for selling your apps, design guidelines and more.
To join the Windows Phone Dev Center and submit apps,
visit dev.windowsphone.com/en-us/downloadsdk.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Cloud computing allows you to use software and data


stored in the cloudi.e., accessed on remote computers
(or servers) via the Internet and available on demand
rather than having it stored on your desktop, notebook
computer or mobile device.
Gives you the flexibility to increase or decrease
computing resources to meet your resource needs at any
given time.
More cost effective than purchasing expensive hardware
to ensure that you have enough storage and processing
power at their occasional peak levels.
1992-2014 by Pearson Education, Inc.
All Rights Reserved.

Also saves money by shifting the burden of managing these


apps to the service provider.
With Windows Azure, your apps can store their data in the
cloud so that the data is available at all times from any of your
desktop computer and mobile devices.
Verified DreamSpark students can download Visual Studio
2012 Professional which includes built-in support for
Windows 8 and Windows Azure.
You can sign up for a free 90-day trial of Windows Azure at
www.windowsazure.com/en-us/pricing/free-trial/.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

C# programs are created using Microsofts Visual Studioa


collection of software tools called an Integrated Development
Environment (IDE).
The Visual Studio 2012 IDE enables you to write, run, test
and debug C# programs quickly and conveniently.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

[Note: This test-drive can be performed on a computer running


either Windows 7 or Windows 8. The steps shown here are for
Windows 7. Running an app on Windows 8 is discussed in
Section 1.15.]
Youll now use Visual Studio Express 2012 for Windows
Desktop to test-drive an existing app that enables you to draw
on the screen using the mouse.
The Painter app allows you to choose among several brush
sizes and colors.
The following steps walk you through test-driving the app.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 1: Checking Your Setup


Confirm that youve set up your computer and the software
properly by reading the books Before You Begin section that
follows the Preface.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 2: Locating the Painter Apps Directory


Open a Windows Explorer window and navigate to
C:\examples\ch01\win7testdrive. (We assume you placed the
examples in the C:\examples folder.)
Double click the Painter folder to view its contents (Fig. 1.6),
then double click the Painter.sln file to open the apps solution in
Visual Studio.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Depending on your system configuration, Windows Explorer


might not display file name extensions. To display them
(like .sln in Fig. 1.6):
In Windows Explorer, type Alt + t to display the Tools menu,
then select Folder options.
Select the View tab in the Folder Options dialog.
Locate the checkbox Hide extensions for known file types
and ensure that its unchecked.
Click OK to dismiss the Folder Options dialog.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 3: Running the Painter App


To see the running Painter app, click the Start button (Fig. 1.7)
or press the F5 key.
Figure 1.8 shows the executing app.
The brushs properties, selected in the RadioButtons labeled
Black and Medium, are default settingsthe initial settings you
see when you first run the app. Programmers include default
settings to provide reasonable choices that the app will use if the
user does not change the settings. Default settings also provide
visual cues for users to choose their own settings. Now youll
choose your own settings as a user of this app.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 4: Changing the Brush Color


Click the RadioButton labeled Red to change the brush
color, then click the RadioButton labeled Small to change the
brush size.
Position the mouse over the white Panel, then drag the mouse
to draw with the brush.
Draw flower petals, as shown in Fig. 1.9.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 5: Changing the Brush Color and Size


Click the Green RadioButton to change the brush color.
Then, click the Large RadioButton to change the brush size.
Draw grass and a flower stem, as shown in Fig. 1.10.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 6: Finishing the Drawing


Click the Blue and Medium RadioButtons.
Draw raindrops, as shown in Fig. 1.11, to complete the
drawing.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 7: Stopping the App


When you run an app from Visual Studio, you can terminate it
by clicking the stop button on the Visual Studio toolbar or by
clicking the close box on the running apps window.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

[Note: This test-drive can be performed only on a computer


running Windows 8.]
Step 1: Checking Your Setup
Confirm that youve set up your computer and the software
properly by reading the books Before You Begin section that
follows the Preface.
Step 2: Switching to the Windows 8 Desktop
Click the Desktop tile in the Windows 8 Start screen to
switch to the desktop.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 3: Locating the Painter Apps Directory


Click the File Explorer icon in the task bar to open a File Explorer
window, then locate the C:\examples\ch01\win8testdrive folder.
(We assume you placed the examples in the C:\examples folder.)
Double click the Painter folder to view its contents (Fig. 1.12),
then double click the Painter.sln file to open the apps solution in
Visual Studio.
[Note: Depending on your system configuration, the File Explorer window
might not display file name extensions. To display file name extensions (like
.sln in Fig. 1.12), click the View tab in the File Explorer window, then
ensure that File name extensions is selected.]

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 4: Running the Painter App


Windows 8 UI apps normally occupy the full screen, though you can also snap
apps to a 320-pixel-wide area at the left or right of the screen to see two apps
side-by-side.
To see the running Painter app, you can install it on the Windows 8 Start screen
and execute it by selecting Local Machine (Fig. 1.13) then clicking the Start
Debugging button or pressing the F5 key.
Once you install the app on the Start screen, you can also run it by clicking its
Start screen tile.
Figure 1.14 shows the executing app.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 5: Changing the Brush Color


Click the RadioButton labeled Red to change the
brush color.
Position the mouse over the white Canvas, then drag the
mouse to draw with the brush.
Draw flower petals, as shown in Fig. 1.15 .

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 6: Changing the Brush Color and Size


Click the RadioButton labeled Green to change the
brush color again. Then, click the RadioButton labeled
Large to change the brush size.
Draw grass and a flower stem, as shown in Fig. 1.16.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 7: Finishing the Drawing


Click the Blue and Medium RadioButtons.
Draw raindrops, as shown in Fig. 1.17, to complete the
drawing.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Step 8: Stopping the App


When you run an app from Visual Studio, you can
terminate it by clicking the stop button on the Visual
Studio toolbar.
Typically, when youre done using a Windows 8 UI app
like Painter, you dont terminate the app. Instead you
simply run another app.
Windows 8 suspends the execution of the previous app
you were running, but keeps it in memory in case you
decide to return to the app.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

Windows may decide to terminate a suspended app to


free up memory for executing other apps.
To explicitly shut down a Windows 8 UI app, simply
drag from the top of the screen to the bottom or press
Alt + F4.

1992-2014 by Pearson Education, Inc.


All Rights Reserved.

You might also like