Wrox Pro 2012
Wrox Pro 2012
Feature
Feature Type
Other Instructions
Page Number
Sidebar
type = general
1011
Warning
type = warning
No title
1000
Note
type = note
No title
1008
WroxPro.030912.indd 1
3/14/12 12:25 PM
Feature
Test classes will be named as follows [class name]Tests, for example if we are testing the PayController class then the test fi xture will be named PayControllerTests.
FeatureCoDeSniPPet (68 CHaraCterS)
12345678901234567890123456789012345678901234567890123456789012345678
FeatureCodeSnippet
123456789012345678901234567890123456789012345678901234567890123456
FeatureCode80
1234567890123456789012345678901234567890123456789012345678901234567890
FeatureCodeSnippetSub
123456789012345678901234567890123456789012345678901234567890
FeatureCode80Sub
1234567890123456789012345678901234567890123456789012345678901234
WroxPro.030912.indd 2
3/14/12 12:25 PM
Professional
ASP.NET MVC Test Driven Development
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Chapter 1
Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2
High-Level Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Chapter 3
Membership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17
Chapter 18
Chapter 19
Continues
WroxPro.030912.indd 3
3/14/12 12:25 PM
WroxPro.030912.indd 4
3/14/12 12:25 PM
Professional
ASP.NET MVC Test Driven Development
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2
High-Level Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Chapter 3
Membership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Chapter 4
Chapter 5
Chapter 7
Chapter 8
Chapter 9
Chapter 13
Chapter 14
Chapter 15
Chapter 16
WroxPro.030912.indd 5
3/14/12 12:25 PM
WroxPro.030912.indd 6
3/14/12 12:25 PM
MatterTitle
Praise for
Para
Richard McAniff
Corporate Vice President,
Microsoft Office
This book will guide you through everything you need to know about the great new functionality in Excel Services. Microsoft Office SharePoint Server 2007 is Microsofts platform for business
applications. Excel Services provides great new business intelligence functionality and helps users
control and manage their spreadsheets. Were already seeing these tools and services unleashing tremendous creativity in the developer community.
Kurt DelBene
Corporate Vice President,
Office Business Platform Group
Microsoft Excels sophisticated calculation and analysis capabilities, combined with ease of use
and programmability, have led to wide deployment in Capital Markets for critical applications such
as pricing and risk management. To date, management and auditing, of what can be highly complex
linked workbooks, have posed challenges.
Excel Services, part of Microsoft Office SharePoint Server 2007, now provides a powerful
solution for management of mission-critical spreadsheet applications by centralizing workbook content and calculations and providing controlled web browser access to Excel applications and data on
a client/server basis.
We at HCL technologies see huge take-up of Excel Services in Capital Markets and are making significant investments in developing deployment capabilities. If you want to learn more about
Excel Services, you must get this book.
Para
Peter Bennett
Principal, Capital Markets,
HCL Former CIO of London Stock Exchange
Excel Services is a critical enhancement to the analysis tool that the world knows and loves. This is
the definitive book on Excel Services, from the team that dreamed it up and built it.
Bill Baker
Distinguished Engineer,
General Manager Business Intelligence,
Microsoft Corporation
WroxPro.030912.indd 7
3/14/12 12:25 PM
WroxPro.030912.indd 8
3/14/12 12:25 PM
BookHalfTitle
Professional
WroxPro.030912.indd 9
3/14/12 12:25 PM
WroxPro.030912.indd 10
3/14/12 12:25 PM
BookTitle
Professional
BookSubtitle
Fifth Edition
If there is an Edition number, no
subtitle, then edition number is
styled as BookSubtitle
BookAuthor
WroxPro.030912.indd 11
Emad Ibrahim
3/14/12 12:25 PM
www.wiley.com
InlineURL
Copyright
WroxPro.030912.indd 12
3/14/12 12:25 PM
Dedication
This book is dedicated to my beautiful soon-to-bewife, Laura, for her unconditional love and support. I
love you. Te amo mucho.
Ana Bahebyk
WroxPro.030912.indd 13
3/14/12 12:25 PM
WroxPro.030912.indd 14
3/14/12 12:25 PM
MatterTitle
Para
Para
WroxPro.030912.indd 15
3/14/12 12:25 PM
WroxPro.030912.indd 16
3/14/12 12:25 PM
MatterTitle
Para
that and none of that. He is clearly conflicted.He graduated from Virginia Tech in 2009 without
honors and since worked in small and large companies, in small and large teams. He has worked in
coffee shops, libraries, skyscrapers, and basements. He has managed teams across the room, across
the country, and across the world.
Emad Ibrahim is a programmer, an entrepreneur, a thinker, a dreamer, and a human-
ist. He is all that and none of that. He is clearly conflicted.He graduated from Virginia
Tech in 2009 without honors and since worked in small and large companies, in small
and large teams. He has worked in coffee shops, libraries, skyscrapers, and basements.
He has managed teams across the room, across the country, and across the world. He
has managed teams across the room, across the country, destination and across the world.
He was born in Egypt, graduated kindergarten and met Santa Claus for the first time in Jordan, graduated high school in Zambia, and graduated college in the Virginia, USA. He has lived in Virginia for
more than 14 years and now claims it as his home and final destination.
Emad Ibrahim is a programmer, an entrepreneur, a thinker, a dreamer, and a human-
ist. He is all that and none of that. He is clearly conflicted. He graduated from Virginia
Tech in 2009 without honors and since worked in small and large companies, in small
and large teams. He has worked in coffee shops, libraries, skyscrapers, and basements.
He has managed teams across the room, across the country, and across the world. He
was born in Egypt, graduated kindergarten and met Santa Claus for the first time in Jordan, graduated high school in Zambia, and graduated college in the Virginia, USA. He has lived in Virginia for
more than 14 years and now claims it as his home and final destination.
Emad Ibrahim is a programmer, an entrepreneur, a thinker, a dreamer, and a humanist.
WroxPro.030912.indd 17
3/14/12 12:25 PM
WroxPro.030912.indd 18
3/14/12 12:25 PM
Credits
MatterTitle
Acquisitions Editor
Paul Reese
Richard Swadley
Project Editor
Barry Pruett
Technical Editor
Cody Reichenau
Associate Publisher
Jim Minatel
Production Editor
Debra Banninger
Lynsey Stanford
Copy Editor
Catherine Caffrey
Compositor
Robyn B. Siesky
Proofreader
Style as Credits,
Comp will apply
additional styles
Indexer
J & J Indexing
Tim Tate
WroxPro.030912.indd 19
3/14/12 12:25 PM
WroxPro.030912.indd 20
3/14/12 12:25 PM
Acknowledgments
MatterTitle
Para
Many people contributed directly and indirectly to this effort. I am grateful for their thoughtful
insights. I thank Adaobi Obi Tulton and Jim Minatel for their incredible patience, understanding,
and support throughout the writing process. They have made the writing process so much easier.
By the time this book is published, I will be married to Lauramy fiance of two years and the love of
my life. I am looking forward to spending the rest of my life with you. Thank you for your love, support, encouragement, and your belief in me.
I want to acknowledge my dad for teaching me to dream big, encouraging and supporting me in
everything I do. When I was a kid, I used to tell people I wanted to win the Nobel Peace Prize when
I grew up. Needless to say, everyone thought it was funny except my parents, and specifically except
for my dad. No dream was ever too big for him. Of course, I have not won the Nobel Peace Prize,
but the fact that I am writing this acknowledgement means that one of my dreams did come true to
write a book.
Last but not least, I want to acknowledge my little sister, Caroline. Thank you for being there when
I need you. You are a great sister and friend. I cant believe you will be a doctor in a few months. Dont
expect me to address you as Doctor, though.
ChapterCredit
Ana Bahebyk
I want to acknowledge the best mom in the world. She is the best listener, the most compassionate
and loving mother. Thanks for unconditionally listening to all that I have to say even when none of
it made sense. She is also a fantastic cook. One day we will create a cookbook together.I also want
to acknowledge the best mom in the world. She is the best listener, the most compassionate and loving mother. Thanks for unconditionally listening to all that I have to say even when none of it made
sense. She is also a fantastic cook. One day we will create a cookbook together.
John Smith
WroxPro.030912.indd 21
3/14/12 12:25 PM
WroxPro.030912.indd 22
3/14/12 12:25 PM
Contents
TOCTitle
Introduction
ContentsChapterTitle
xix
ContentsPartTitle
ContentsChapterTitle
Problem 1
Design 1
Message Management
Contact Management
Reports and Stats
Miscellaneous Requirements
2
3
5
5
ContentsH1
Solution 6
Model-View-Controller 6
ASP.NET MVC
6
Methodology, Concepts, and Approach
10
ContentsH2
Tools and Frameworks
18
Why EvenContact?
22
Summary 23
Chapter 2: High-Level Design
25
Problem 25
Design 25
Membership 25
Account Management
29
Message Management
31
ContentsH3
Contact Management
32
Solution 34
Summary 34
Part II: Part Opener Title Two
Chapter 3: Membership
35
Problem 35
Design 35
Solution 36
Minor Interruption
WroxPro.030912.indd 23
46
3/14/12 12:25 PM
CONTENTS
Problem 206
Back on Track
Message Templating
207
209
Design 209
Solution 211
My Templates
217
Summary 222
Chapter 4: Billing and Subscriptions
223
Problem 223
Design 223
Solution 224
PayPal Implementation
226
Summary 234
Part III: Part Opener Title Three
Chapter 5: Usage Tracking
235
Problem 235
Design 235
Solution 236
Summary 246
Chapter 6: Fill In the Blanks
247
Problem 247
Design 247
User Interface
247
Refactor and Optimize
248
Scaling 248
Solution 248
User Interface
248
Refactor and Optimize
254
Scaling 257
Summary 259
Appendix A: An Overview of XML
267
Glossary 271
Index
289
xxiv
WroxPro.030912.indd 24
3/14/12 12:25 PM
Foreword
MatterTitle
Para
After three years, the time is here. Microsoft Office SharePoint Server 2007 has shipped with great
fanfare and lots of accolades from customers, partners, and the press.
Its humbling to be part of the team that helped bring this monstrous release to market. When I
worked on SharePoint Portal Server 2001 (codenamed Tahoe back then), Microsoft was making its
first official foray into the portal market with document management added in for good measure. For
those of you who worked with SharePoint in those days, the 2001 version was a good first attempt to
enter into a new market for Microsoft even with some of the limitations we knew the product had.
With the 2007 release, I can definitely say that we have worked hard to make sure SharePoint meets
the needs of diverse sets of customers from the smallest business to the largest enterprise.
So, why should you care about SharePoint and this book?
Well, if you look at the 2007 release, weve extended the surface area of SharePoint twofold. The
previous version of SharePoint was a great collaboration, portal, and enterprise search tool. Weve
enhanced each of those capabilities, while at the same time adding enterprise content management,
business process management and e-forms, and finally business intelligence capabilities to the product. Thats a lot of new technology, information, APIs, and best practices that you need to learn.
Youll need a great teacher and this book is that teacher.
The authors cover the breadth of SharePoint without sacrificing the depth you need to understand
how to build complete and robust SharePoint solutions. In fact, you will find yourself consistently
reaching for this book on your bookshelf, earmarking pages that have the tips and tricks you need
to get your job done, and this book will quickly become an indispensable part of your SharePoint
reference set.
After reading this book, you will become a sought-after SharePoint expert ready to tackle the problems that your users throw at you. I know I learned a number of new things about SharePoint after
reading this book. I think you will, too.
ChapterCredit
WroxPro.030912.indd 25
Tom Rizzo
Redmond, WA
March 2007
3/14/12 12:25 PM
WroxPro.030912.indd 26
3/14/12 12:25 PM
Introduction
IntroductionTitle
Para
Dear reader, thank you for picking up this book, and welcome to the exciting world of Test
Driven Development (TDD) and ASP.NET MVC. Sometime in 2008, I quit my job and decided to
start my own company. Naturally, my startup was web-based. At the time, I was already very familiar with the Microsoft web development platform, a natural choice for my website. I hesitated to use
it because I wanted to learn something new and I wanted to use TDD. Several of the web startups at
the time were written in Ruby on Rails (RoR), and I seriously considered going that route. I played
around with RoR and became familiar with it. I liked its approach to development, the ease of testing, and the control I had over HTML and JavaScript. There are several things that I didnt like,
however, especially the Integrated Development Environment (IDE). Nothing came close to Visual
Studio. Luckily, around that time Microsoft introduced ASP.NET MVC, which made the decision
very easy for me.
Even though ASP.NET MVC was still in early alpha, I went ahead and built my startup on top of
it (talk about taking risks). It was a great experience for me and turned out to be a good decision. I
instantly fell in love with the MVC way of doing things. I enjoyed the control I had over the generated HTML and scripts. I loved the clean and friendly URLs. I cant imagine living without the unit
tests that I could easily run when I make a change to verify that I havent broken anything. I can go
on and on about why I love ASP.NET MVC and TDD and how much more enjoyable they make
programming.
Dont get me wrong, though; its not all sunshine. There is a learning curve. You cant just drag-anddrop a control and instantly have a grid. You cant drag-and-drop a few controls, set a couple properties, and instantly have form validation. ASP.NET MVC requires some manual work. The upside
is that there is no more magic, so you will actually know what is happening on your page, what
gets rendered, and how it gets there. Best of all, you will not see anything that you didnt put on
the page. No more hidden fields, strange scripts, or magical eventsjust straight up HTTP requests.
H1
Do you love programming? I dont mean like or enjoy, I mean love. If you are like me, then you
probably do, and if you do, then you owe it to yourself to learn ASP.NET MVC and to get into Test
Driven Development. They will make something that you already love so much more enjoyable.
With that said, let me state up front that this isnt a book for completely novice programmers, or for
experienced developers who have never touched ASP.NET and the .NET Framework in general. This
book teaches how to write a real-world website from scratch to deployment, and as such, it cant explain
every single detail of the technology, but must concentrate on designing and writing actual solutions. To
read this book comfortably, you should already have had some experience with ASP.NET 2.0, even if
not advanced solutions. Youre not required to know ASP.NET MVC, as each chapter will introduce the
new concepts and features that youll use in that chapter, providing enough background information to
WroxPro.030912.indd 27
3/14/12 12:25 PM
introduction
implement the solution. If you then want to go deeper and learn everything you can about a feature, you
can refer to the MSDN official documentation or to another reference book such as Professional ASP.NET
MVC 1.0 by Rob Conery, Scott Hanselman, Phil Haack, and Scott Guthrie (Wrox, 2009).
This book is not a crash course in ASP.NET MVC, and its also not an advanced ASP.NET MVC
or TDD book. I dont do a lot of handholding, and I dont delve into all the intricacies of the framework or theories of TDD. I wanted this book to be practical and as close to real-world development
as possible. I wanted to create an application, show and explain my decisions, make mistakes, and
fix them.
Think of this book as a documentary. I try to develop a web application from scratch and document
the process. I make mistakes. I correct them. I (and hopefully you) learn from them. I intentionally
kept the mistakes I made in earlier chapters and addressed them in later chapters because I wanted
to show the flexibility, power, and usefulness of Test Driven Development. Do you know the feeling
when you make a change to the code and cross your fingers hoping that you didnt break something
somewhere else in the application? This problem, and the risks associated with it, is greatly diminished when you use TDD. Imagine making a change, running your tests, and instantly finding out
that you just broke six different tests. This immediate knowledge is very comforting. It also allows
you to make changes more frequently, fix bugs easily, and feel confident that your changes didnt
break anything.
Code coverage
Mocking
I will also use the following .NET 3.5 features that were added in C# 3.0:
LINQ
LINQ-to-SQL
Extension methods
Anonymous methods
xxviii
WroxPro.030912.indd 28
3/14/12 12:25 PM
introduction
In addition, you will learn how these new features and concepts integrate standard ASP.NET 2.0
features, such as:
Master pages
Not only does this book cover the new features of ASP.NET MVC 1.0; it also demonstrates how to
integrate all of them together in order to develop a single full-featured site. After reading this book,
you will know many of the best practices for web development using TDD.
ProblemThis defines the problem or problems to be addressed in the chapter: What do you
want to do in this chapter? What features do you want to add to the site and why are they
important? What restrictions or other factors need to be taken into account?
DesignAfter the problem is defined adequately, this section describes what features are
needed to solve the problem. This will give you a broad idea of how the solution will work.
SolutionAfter establishing what I am going to accomplish and why (and how that solves
the problem defined earlier), I will produce and discuss the code and any other material that
will realize the design and solve the problem laid out at the beginning of the chapter. Just as
the book as a whole focuses primarily on the solution, so does each chapter. This is where
you will get hands-on practice and create the code.
xxix
WroxPro.030912.indd 29
3/14/12 12:25 PM
introduction
Conventions
To help you get the most from the text and keep track of whats happening, weve used several conventions throughout the book.
FeatureType = warning
WARNING Boxes like this one hold important, not-to-be forgotten information
that is directly relevant to the surrounding text.
FeaturePara
FeatureType = note
Note Notes, tips, hints, tricks, and asides to the current discussion are offset
and placed in italics like this.
We show filenames, URLs, and code within the text like so: persistence.properties.
ListBulleted
Source Code
CodeHighlight
CodeSnippet
As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All of the source code used in this book
is available for download at www.wrox.com. Once at the site, simply locate the books title (either by
using the Search box or by using one of the title lists) and click on the Download Code link on the
books detail page to obtain all the source code for the book.
FeatureType = note
Note Because many books have similar titles, you may find it easiest to search
by ISBN; this books ISBN is 978-0-470-44762-8.
FeaturePara
Once you download the code, just decompress it with your favorite compression tool. Alternatively, you
can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to
see the code available for this book and all other Wrox books.
InlineURL
xxx
WroxPro.030912.indd 30
3/14/12 12:25 PM
introduction
Errata
We make every effort to ensure that there are no errors in the text or in the code. However, no one
is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or
faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save
another reader hours of frustration, and at the same time you will be helping us provide even higher
InlineURL
quality information.
To find the errata page for this book, go to www.wrox.com and locate the title using the Search box
or one of the title lists. Then, on the Book Search Results page, click on the Errata link. On this page,
you can view all errata that has been submitted for this book and posted by Wrox editors.
FeaturePara
FeatureType = note
Note A complete book list including links and info to errata is also available at
www.wrox.com/misc-pages/booklist.shtml.
Notes, tips, hints, tricks, and asides to the current discussion are offset and
placed in italics like this.
FeaturePara
If you dont spot your error on the Errata page, click on the Errata Form link and complete the form
to send us the error you have found. Well check the information and, if appropriate, post a message to
the books errata page and fix the problem in subsequent editions of the book.
Para
H1
p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a web-based
system for you to post messages relating to Wrox books and related technologies and interact with
other readers and technology users. The forums offer a subscription feature to email you topics of
interest of your choosing when new posts are made to the forums. Wrox authors, editors, other
industry experts, and your fellow readers are present on these forums.
At http://p2p.wrox.com you will find a number of different forums that will help you not only as
you read this book, but also as you develop your own applications. To join the forums, just follow
these steps:
ListNumbered
1.
2.
3.
4.
You will receive an email with information describing how to verify your account and complete the joining process.
Para
xxxi
WroxPro.030912.indd 31
3/14/12 12:25 PM
introduction
Note You can read messages in the forums without joining P2P, but in order to
post your own messages, you must join.
Once you join, you can post new messages and respond to messages other users post. You can read
messages at any time on the Web. If you would like to have new messages from a particular forum
emailed to you, click on the Subscribe to this Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to
questions about how the forum software works as well as many common questions specific to P2P
and Wrox books. To read the FAQs, click on the FAQ link on any P2P page.
xxxii
WroxPro.030912.indd 32
3/14/12 12:25 PM
PART I
PartTitle
chapter 3: Architecture
chapter 4: XML
WroxPro.030912.indd 997
3/14/12 12:25 PM
WroxPro.030912.indd 998
3/14/12 12:25 PM
ChapterTitle
ChapterTitle
ChapterObjectiveTitle
ChapterObjective
ChapterIntroductionHead
Wrox.com
downloads
The wrox.com code downloads for this chapter are found at www.wrox.com/remtitle.cgi
?isbn=0123456789 on the Download Code tab. The code for this chapter is divided into the
Option 1
MyBasePageCS.zip
MyBasePageVB.zip
maximum
5 ListBulleted
items
Wrox.com
downloads
Para
ChapterIntroductionHead
The wrox.com code downloads for this chapter are found at www.wrox.com/remtitle.cgi
?isbn=0123456789 on the Download Code tab. The code is in the chapter xx download and
Option 2
H1
The role of an Object Relational Mapper (ORM) is to bridge the gap between the relational
model (the database) and the object-oriented model. This problem is often referred to as the
impedance mismatch. Using mapping fi les or attributes on a business object.
WroxPro.030912.indd 999
3/14/12 12:25 PM
1000
Why NHibernate?
NHibernate is a port of the popular Open Source Hibernate Framework for Java. Hibernate has
been around for years, and its a proven and robust piece of software. ORM has had a slow takeup in the .NET world, but with the release of LINQToSQL and the beta of the Entity Framework,
many developers are starting to see the benefit of automating their Data Access Layer.
One of the best features of NHibernate, in my opinion, is the support for transparent persistence
this means that your business objects dont have to inherit from any base classes or implement any
framework interfaces. This enables you as a developer to build a rich model of a problem domain
and put off worrying about persistence requirements to the end. This is why I have chosen to use
NHibernate as my ORM of choice, and after you read this article, I hope you start to use it as well.
Warning You will often see the terms exception and error used interchangeably, although technically they are not the same thing. An error is simply any
situation in which unwanted or unexpected results occur, while an exception is
a specific object instantiated in response to a runtime error. However, as long as
its understood that youre talking about runtime errors, swapping these terms is
usually not a problem. For more information, go to www.wrox.com.
InlineURL
1.
2.
ListNumbered
3.
ListNumberedSub
i.
ii.
or smaller, text
should wrap
around it.
ListNumberedSub2
WroxPro.030912.indd 1000
3/14/12 12:25 PM
1001
Add a new SQL Express 2005 database to the web project, and name it QuickDemo.mdf. Visual
Studio will prompt you to ask if you want to place it in the App_Data folder. Do so and add a new
table to the database called People with the column definitions shown in Table1-1.
Add a class file to the Class Library project called person as defined in Listing1-1. This will be the
plain old business object that you will map to the database table.
Listing1-1: Selectors Example SelectorsAPIExample01.htm
CodeTitle
CodeListing
writer.WriteLine(DateTime.Now.ToString(CultureInfo.InstalledUICulture));
writer.WriteLine(Entry: {0}, txtLogEntry.Text);
writer.WriteLine(-------------------);
writer.Dispose();
}
catch (PathTooLongException)
{
Response.Write(
The path contains too many characters.);
catch (DirectoryNotFoundException)
{
Response.Write(The specified path is invalid.);
}
catch (IOException)
Response.Write(There was a problem accessing the file.);
}
Now add a reference to the NHibernate.dll from the location where you extracted the NHibernate
files and folders. If you were following along, the NHibernate.dll will be found in the folder
C:\NHibernate\bin\net-2.0.
InlineCode
TableCaption
Table1-1: XPath Overview
Description
Node Name
Selects nodes from the root, for example, /menu/section retrieves the section
nodes that are children of the menu node
&5
Selects an attribute, so in the example, this is how we retrieve the section title,
and the links url and name
TableEntry
WroxPro.030912.indd 1001
TableHead
Expression
continues
3/14/12 12:25 PM
1002
Table1-5 (continued)
Expression
Description
Selects nodes from the root, for example, /menu/section retrieves the section
nodes that are children of the menu node
//
Selects all children nodes regardless of where they are; for example, we could use
//link to retrieve every link element without having to navigate down through
the section
Selects an attribute, so in the example, this is how we retrieve the section title,
and the links url and name
Fill in the textboxes with a first and last name, select a date, and then click on the Add Person
button. Do this a couple of times with different data, and you will see your people appear on the
grid. If you take a look in the People database table, you will see your newly added Person.
EquationNumbered
Equation
(x+1)2 = 2x 2 + x + 1
(x+1)2 = 2x2 + x + 1
(1)
Dont worry if you didnt understand exactly how it workedthats whats covered in the rest of
this article. When you have learned all about the concepts and features of NHibernate, you will
build a real-world ASP.NET application with more of an enterprise feel so you can see how to use
NHibernate in your line-of-business applications.
ISessionFactory
An ISessionFactory is typically created as a singleton object; this is because of the relatively
expensive operation of creating it. One of the jobs of the SessionFactory is to provide ISession
instances. The ISession is the main interface used to persist and retrieve business entities. In the
demo project, you used it to retrieve all the people from the database, as can be seen in Listing9,
and persist new people. Think of ISession as your gateway to the database or, as the NHibernate
site defines it, as the persistence manager, and then send email to [email protected].
InlineEmail
WroxPro.030912.indd 1002
3/14/12 12:25 PM
ISession
1003
Option A for code snippets where an entire section used the same code
(no need to repeat the code name with every snippet):
All of the code in this section uses SelectorsAPIExample01.htm code file. An ISession instance will
enable you to retrieve and persist your business objects. There are a variety of ways to do this with
NHibernate, and I will go into them in more detail later in this article.
SETS WIDTH AND HEIGHT
The ISession interface implements the Unit of Work patterna number of actions can be performed
on business entities, and the session will keep track of the updates, additions, and deletions; then,
using a transaction, all changes can be committed as part of one atomic action. You will see this
later when you look at the ITransaction interface. A second pattern that NHibernate makes use of
is the Identity Map pattern. NHibernate uses an Identity Map to maintain a single instance of each
persistent entity in the ISession no matter how many times you retrieve the same entity.
ITransaction
NHibernate supports its own Transaction API via the ITransaction interface. Now you may be
asking, why is another Transaction API needed when we have ADO.NET transactions as well as
many others? The advantage is that by using NHibernates implementation, we can abstract away
the concrete underlying Transaction API, which enables you to code against a consistent Transaction
API no matter what your underlying database or environment is.
WroxPro.030912.indd 1003
3/14/12 12:25 PM
1004
to query against the Person entity. I then just call a list to return all of the people. If I wanted to add
a clausesuch as people whose name began with a PI would need to add a criterion to the
criteria, but more on this later in the article (see Listing1-2).
Listing1-2: Exception handling in a CreateUserWizard control
CodeHead
case MembershipCreateStatus.InvalidAnswer:
litResult.Text =
The password retrieval answer provided is invalid. +
Please check the answer and try again.;
break;
litResult.Text =
The password retrieval answer provided is invalid. +
Please check the answer and try again.;
WroxPro.030912.indd 1004
3/14/12 12:25 PM
Using NHibernate
1005
break;
case MembershipCreateStatus.ProviderError:
litResult.Text =
An error occurred. The user was not created. +
Please verify your input and try again.;
litResult.Text =
break;
}
}
The CreateUserError event handler in Listing15 uses the CreateUserError property of the passedin CreateUserErrorEventArgs object to determine what error has occurred and notifies the user
accordingly. The CreateUserError property is an enumeration of type MembershipCreateStatus,
which contains all the possible outcomes from an attempt to create a user.
Using NHibernate
Now that you have a good grounding in the main components of NHibernate, its time to find out
how you can leverage it into your line-of-end-business applications. I find the best way to learn is by
example, so I am going to follow the Wrox ProblemDesignSolution approach to a small application. Lets begin by looking at the requirements (see Figure1-3).
RMS
Roles
End User
HIPAA
Compliance
Officer
SOX
Compliance
Officer
Administrator
Responsibilities
Ensure the validity
of document
metadata
Ensure
confidentiality of
patient records
Ensure
accuracy of
financial records
Optimize storage
bandwidth and
performance
FigureLabel
Activities
Send
documents
to the
repository
Procedures
Assign
permissions
Monitor
access to
patient
records
Policies
Requests
Perform
consistency
checks
on records
Logs
Logs
Gather
and monitor
system
metrics
Validation Rules
Metrics
Documents
287620
Ch01 figure
05 f0105.eps
Figure1-3: This is just a regular
full-size
figure.
9/03/09 rs
Slug
WroxPro.030912.indd 1005
3/14/12 12:25 PM
1006
Before we can start to build an application, we need a set of requirements. This section will introduce a sample set of requirements for a fictitious mail order company. Once we have these requirements, we can define an architecture that will best suit the solution and one that will shape the rest
of our project.
The company has these requirements for the software:
The ability to add, remove, and update customers. However, no customer should be able to
be deleted if they have placed an order with us.
The ability to add, remove, and update products; again, we do not want products that have
been ordered to be deleted.
ListPara
The ability to process orders that we have stock for. When an order is processed, we need
the product stock to decrease by the amount shipped. Because the company also has plans
for other systems like mobile devices for dispatchers and rich clients for sales staff to interact
with orders, so some kind of concurrency check must be put in place.
The Design
Based on the requirements, the system will have a small amount of business logic to start with but
will increase as the software evolves over time. You need to ensure that you can isolate the business
logic and process from the code that is used to present it. To keep focused on the business problem,
you will be following a domain-driven approach and using a Domain Model pattern to model the
business problem. The Domain Model will implement all of the business rules, processes, and logic
and will represent the problem domain in code.
The architecture will consist of the following layers:
ListHead
ListUnmarked
ListHead
User Interface (UI)T his layer is responsible for displaying the data and handling
user commands. In this application, you are using ASP.NET pages, but you could easily
add a Win Forms or WPF front-end with only a few minor changes to the applications
configuration.
Presentation LayerT his layer is the interface between the UI (in this case, the ASP.NET
pages) and the rest of the application. This layer will contain some validation logic and can
be easily unit tested and used with a variety of different UIs.
Service LayerT he Service Layer acts as the entry point into the application and
coordinates all activity between the presentation layer and the repositories. The
services will expose business use cases and will be autonomous.
ListUnmarkedSub
ListUnmarkedSub2
Repository (Data Access Layer)T he Repository acts like an in-memory domain collection. It is used to persist and retrieve our domain business objects. The Repository Layer
needs to support Lazy Loading, concurrency checks, querying of business entities, and a
transaction interface that can be controlled via the service layer.
WroxPro.030912.indd 1006
3/14/12 12:25 PM
Using NHibernate
1007
The Solution
The solution will be written in Visual Studio 2008 with a SQL Express 2005 database.
Not surprisingly, I am going to be using NHibernate as my Data Access Layer because it has built-in
support for concurrency, transactions, and Lazy Loading. NHibernate also gives you transparent
persistence, which will allow me to build my Domain Model without hindrance, and if you want to
change my Data Access Strategy at a later date, you will be able to with no change to your Domain
Model as in Tables 1-2 and 1-3.
Table1-2: The Mapping Relationships that NHibernate Supports
set narrow tables to 23p0 wide
Relationship
Ex ample
One-to-one
One-to-many
Many-to-many
Many-to-one
table footnote
TableFootnote
TabularHead
Mapping Collection type
Bags
Sets
List
TabularEntry
Map
Figure1-19 shows how you would map a simple one-to-many relationshipan Order and its
OrderItems.
The table definitions for this example are shown in Table1-5 and Table1-6.
The object-oriented model of the relationship (shown in Listing1-54) uses an IList(Of OrderItem)
to store the Items collection. I could have also used an ISet(Of OrderItem) as well, as the order
should not contain any duplicate OrderItems.*
*Footnote on a page
WroxPro.030912.indd 1007
FootnoteEntry
3/14/12 12:25 PM
1008
Listing1 has a call to File.AppendText (which takes as an argument a string indicating the physical path to the file you want to append to), as well as several has a call to File.AppendText (which
takes as an argument a string indicating the calls to the StreamWriter.WriteLine
ListBulleted
ListBulletedSub
It would be great if there was a way to defer the loading of the full list of orders
until you really needed it.
ListParaSub
ListBulletedSub2
There could be a disk error while opening the file or writing to the disk.
InlineCode
Note that the foreign key in the object is a full order, not just an order ID property.
FeatureType = note
Note When handling an exception, avoid throwing a new exception that fails
to include the original exception in its InnerException property, as all the information about the original exception is then lost. The new exception starts a new
stack trace starting from the exact spot.
FeaturePara
FeatureCodeSnippet
FeaturePara
The new exception starts a new stack trace starting from the exact spot where
you threw it, making it appear as though this is where the error actually
originated.
There was a requirement to ensure that customers with orders were not deleted. Now you can easily
check if a customer has an order by inspecting his or her orders collectionif the count is 0, then
you can safely remove them; and if it is 1 or greater, then you cannot.
Relationship
Ex ample
One-to-one
One-to-many
Many-to-many
WroxPro.030912.indd 1008
3/14/12 12:25 PM
Using NHibernate
1009
1TB
1TB
1TB
1TB
1TB
data
data
data
data
data
data
1TB
data
1TB
1TB
1TB
1TB
1TB
data
data
data
data
data
data
+ Mirrored Copy:
1TB
1TB
1TB
1TB
1TB
1TB
data
data
data
data
data
data
1TB
1TB
1TB
1TB
1TB
data
data
data
data
data
data
1TB
data
FigureSource
Following Along?
If you are following along and building the projects as I progress through the application, simply
follow the steps below; or alternatively, you can download the entire application from the Wrox site:
1.
2.
3.
Add the NHibernate configuration section as defined in Listing66 to the web.config file
located in the web site project. Dont worry that Visual Studio will complain about the
namespacethis will be fixed later when you add the reference to the Presentation project.
4.
Add the context property definition as described in Listing64 to the web.config file within
the web site project. This will let NHibernate know that you want to store the current session
in a Web context.
5.
6.
WroxPro.030912.indd 1009
3/14/12 12:25 PM
1010
The remainder of the pages in the web site project follow the same logic using user controls to implement the views from the presentation project and creating a presenter in the code-behind to interact
with the model.
WroxPro.030912.indd 1010
3/14/12 12:25 PM
using nHibernate
1011
Again, I will only be showing you the code required to satisfy the customer management requirements. You will be able to inspect all of the other classes involved in the ASP.NET layer from the
complete application download from the Wrox web site. Lets ensure that the user can actually view
the Register page. We start by creating a simple test that would simply need to show whether a user
can navigate to the Register view i.e. http://evencontact.com/account/register.
One thing I havent talked about is ensuring that we always identify an entity by its ID. Its important to override the equals and getHashCode methods of each of the entities because NHibernate
will use proxy classes for the Lazy Load features, and comparing objects may bring undesired
results. Also if you are using more than one NHibernate session, overriding the equality methods
will ensure that NHibernate will identify an entity in the correct way. You can add a new method
defi nition to the IEntity interface to support equality checking as seen in Listing1-87. The updated
BusinessBase class with equality overrides is displayed in Listing1-88.
Not surprisingly, I am going to be using NHibernate as my Data Access Layer because it has built-in
support for concurrency, transactions, and Lazy Loading. NHibernate also gives you transparent
persistence, which will allow me to build my Domain Model without hindrance, and if you want to
change my Data Access Strategy at a later date, you will be able to with no change to your Domain
Model as in Tables 1-2 and 1-3.
FeatureType = general
FeatureTitle
FeaturePara
cOnVentIOn
Test classes will be named as follows [class name]Tests, for example if we are testing
the PayController class then the test fi xture will be named PayControllerTests.
Test methods will be named using clear and descriptive names that clearly identify
the test and its outcome. You can either separate the name using capitals or using
underscores. For example:
CallbackShouldReturnNull or callback_should_return_null
FeatureCodeSnippet
public void Register_Can_Successfully_Register_New_User()
{
var ac = new AccountController();
var results = ac.Register(username, email,
question, answer, password);
FeatureCodeSnippet +
Assert.IsNotNull(results);
CodeHighlight
results);
var typedResults = results as RedirectToRouteResult;
Assert.AreEqual(Index,
One thing I havent talked about is ensuring that we always identify an entity by its
ID. Its important to override the equals and getHashCode methods of each of the
entities because NHibernate will use proxy classes for the Lazy Load features, and
comparing objects may bring undesired results. Also if you are using more than one
NHibernate session, overriding the equality methods will ensure that NHibernate
will identify an entity in the correct way. You can add a new method defi nition to
the IEntity interface to support equality checking as seen in Listing1-87.
continues
FeaturePara
WroxPro.030912.indd 1011
3/14/12 12:25 PM
1012
continued
Run the test. The test passes (green light). Woohoo!!! Our fi rst test works.
nOte This is a very simple action and test, so there isnt really much to refactor. At least, for now.
Moving on. We need to write tests for the second Register Action, the one that actually registers the
user. We want to:
Again, I will only be showing you the code required to satisfy the customer management requirements. You will be able to inspect all of the other classes involved in the ASP.NET layer from the
complete application download from the Wrox web site. Lets ensure that the user can actually view
the Register page. We start by creating a simple test that would simply need to show whether a user
can navigate to the Register view i.e. http://evencontact.com/account/register.
One thing I havent talked about is ensuring that we always identify an entity by its ID. Its important
to override the equals and getHashCode methods of each of the entities because NHibernate will
use proxy classes for the Lazy Load features, and comparing objects may bring undesired results.
Also if you are using more than one NHibernate session, overriding the equality methods will ensure
that NHibernate will identify an entity in the correct way. You can add a new method defi nition to
the IEntity interface to support equality checking as seen in Listing1-87. The updated BusinessBase
class with equality overrides is displayed in Listing1-88.
WroxPro.030912.indd 1012
3/14/12 12:25 PM
Using NHibernate
1013
In this test, we check that the returned value is not null and that it is of type RedirectToRoute
Result. Then we make sure that it is redirecting to the correct destination i.e. /home/index. Then
we check that page title is correct. There are two Register actions that we need to accommodate.
One action just displays the view that would happen with a GET request and the other will submit
the form to the server to perform the registration that would happen with a POST request.
Bill Gates earns $250 every SECOND; thats about $20 million a DAY and
$7.8 billion a YEAR!
QuotePara
If he drops a thousand-dollar bill, he neednt even bother to pick it up because
in the four seconds it would take him to pick it up, he wouldve already earned
it back.
QuoteSource
As Microsoft has morphed and spread into new markets over the years, Gates has remained the constant star by which everything and everyone connected with the company has navigated. In short,
up until this point, Microsoft has been all about Bill.
WroxPro.030912.indd 1013
3/14/12 12:25 PM
1014
Recommended Reading
Wardriving & Wireless Penetration Testing by Chris Hurley, Russ Rogers, Frank Thornton, and
Daniel Connelly (Syngress Publishing. ISBN: 159749111X)
Infosec Career Hacking: Sell Your Skillz, Not Your Soul by Aaron W. Bayles, Chris Hurley, Johnny
Long, and Ed Brindley (Syngress Publishing. ISBN: 1597490113)
Reference
OnlineReference Option A
OnlineReference Option B
Visit p2p.wrox.com
YOU CAN DOWNLOAD THE CODE FOUND IN THIS BOOK. VISIT WROX.COM
AND SEARCH FOR ISBN 9780470123456
Neither should be used in the middle of a chapter. End of chapter
only and not on every chapter. Very occasionally.
WroxPro.030912.indd 1014
3/14/12 12:25 PM
AppendixTitle
regular expressions
Thomas Hardy
AppendixTitle
ChapterAuthor
This appendix examines some basic aspects of constructing regular expressions. One reason
for working through the simple regular expressions presented in this chapter is to illuminate
the regular expressions used in Chapter 3 and extend your knowledge of regular expressions.
nOte This appendix has been borrowed from Beginning Regular
Expressions (Wiley Publishing, Inc., 2005) by Andrew Watt. We recommend this book for further (and more comprehensive) reference into the
world of regular expressions.
How to match characters that can occur a specified number of times Matching Single
Characters
continues
WroxPro.030912.indd 1015
3/14/12 12:25 PM
1016
Listing1-1 (continued)
The simplest regular expression involves matching a single character. If you want to match a single,
specified alphabetic character or numeric digit, you simply use a pattern that consists of that characRunInHead ter or digit. So, for example, to match the uppercase letter L, you would use the following pattern:
RunInParaAny occurrence of the uppercase L. You have not qualified the pattern in any way to
limit matching, so expect it to match any occurrence of uppercase L. Of course, if matching is being
carried out in a case-insensitive manner (which is discussed in Chapter 4), both uppercase L and
lowercase l will be matched.
RunInPara
RunInParaSubThe matching of the pattern L in OpenOffice.org Writer against the sample
document UpperL.txt. Notice that there are five matches contained in the sequences of characters XLM, CMLIII, Leoni, Legal, and Lewinski.
RunInHead
RunInParaSub
The default behavior of OpenOffice.org Writer is to carry out a case-insensitive match. As you can
see in Figure A-1, I have checked the Match Case check box so that only the same case as specified
in the regular expression is matched.
Question
Interview Q&A
Q:
If my wireless network doesnt have a lot of traffic, is it okay to use WEP because the IVs
required to crack the WEP key wont be generated?
A:
No. Automated tools are available that allow attackers to capture an ARP packet and reinject it to the access point very rapidly. This generates a significant amount of traffic and
allows the attacker to capture enough unique initialization vectors to quickly crack the key.
Q:
A:
Active WLAN detection requires that the SSID be broadcast in the beacon frame. Passive
WLAN detection listens to all traffic in range of the device and determines what WLANs
are in range.
Answer
WroxPro.030912.indd 1016
3/14/12 12:25 PM
appendIx
regular expressions
Mail your packages early so the post office can
lose them in time for Christmas.
Johnny Carson
Epigraph
EpigraphSource
This appendix examines some basic aspects of constructing regular expressions. One reason
for working through the simple regular expressions presented in this chapter is to illuminate
the regular expressions used in Chapter 3 and further extend your knowledge of regular
expressions.
The following exercises use OpenOffice.org Writer a free document editor that makes it
easy to apply regular expressions to text, and verify that they do what you expected. You can
download this tool from http://www.openoffice.org.
nOte This appendix has been borrowed from Beginning Regular
Expressions (Wiley Publishing, Inc., 2005) by Andrew Watt. We recommend this book for further (and more comprehensive) reference into the
world of regular expressions.
One of the issues this chapter explores in some detail is the situation where you want to match
occurrences of characters other than those characters simply occurring once.
This Appendix looks at the following:
WroxPro.030912.indd 1017
3/14/12 12:25 PM
1018
RunInParaSub
RunInPara
RunInHeadSub
runInparasub The matching of the pattern L in OpenOffice.org Writer against the sample
document UpperL.txt. Notice that there are five matches contained in the sequences of characters XLM, CMLIII, Leoni, Legal, and Lewinski.
The default behavior of OpenOffice.org Writer is to carry out a case-insensitive match. As you can
see in Figure A-1, I have checked the Match Case check box so that only the same case as specified
in the regular expression is matched.
FeatureType = general
_FeatureParaAfterTitle
FeatureTitle
cOnVentIOn
Test classes will be named as follows [class name]Tests, for example if we are testing
the PayController class then the test fi xture will be named PayControllerTests.
1.
Test methods will be named using clear and descriptive names that clearly identify the test and its outcome. You can either separate the name using capitals or
FeatureListNumbered
using underscores. For example:
CallbackShouldReturnNull or callback_should_return_null
public void Register_Can_Successfully_Register_New_User()
{
var ac = new AccountController();
var results = ac.Register(username, email,
FeatureCodeSnippet +
question, answer, password);
CodeHighlight
Assert.AreEqual(Index,
FeatureCodeSnippet
I personally prefer the underscore method but there will be a mix of both in the
code. I settle on using lower cases and underscores towards the end of the book.
I personally prefer the underscore method but there will be a mix of both in the
code. I settle on using lower cases and underscores towards the end of
the book.
FeatureListBulleted
Widespread industry support exists for XML. There are also some subtle
differences in the way Apache handles rules for mod_rewrite in .htac vs.
httpd.conf.Numerous tools and utilities are being with Web browsers,
databases, and operating systems.
InlineCodeUserInput
InlineCode
InlineCodeVariable
InlineCodeUserInputVariable
WroxPro.030912.indd 1018
3/14/12 12:25 PM
Glossary
GlossaryTitle
GlossaryTerm
GlossaryDefinition
Apache Cocoon An open source XML publishing system developed under the banner of the
Apache Software Foundation.
Attribute Metadata on an XML tag that provides additional information.
BizTalk An XML-based framework from the Microsoft Corporation that enables communications
and integration of business applications.
BPMN Business Process Modeling Notation.
BPMS Business process management systems.
BPR Business process reengineering.
CDATA Character DATA, which is not interpreted or parsed.
CMS Content management system.
COM Component Object Model.
Comment Characters included between the comment delimiters <!-- and --> that are not considered
part of the documents character content.
CORBA Common Object Request Broker Architecture.
DCOM Distributed Component Object Model.
Declaration If present, this is the first line within an XML file, which essentially lets parsers, tools,
and readers know that the file contains XML.
DOM Document Object Model.
DTD Document type definition; a file that contains element and attribute definitions.
ebXML Electronic Business using Extensible Markup Language.
Elements The structural units represented by the starting and ending tags that make up XML files.
Encoding The manner in which the abstract characters of a coded character set, such as
Unicode, are converted into an integer code representation suitable for storage, transmission, and
manipulation.
Entity An item that can be included in an XML metadata document by referring to it by a representative name.
WroxPro.030912.indd 1019
3/14/12 12:25 PM
1020
GLossary
FOFormating Objects.
DOM Document Object Model.
DTD Document type definition; a file that contains element and attribute definitions.
ebXML Electronic Business using Extensible Markup Language.
Elements The structural units represented by the starting and ending tags that make up XML files.
Encoding The manner in which the abstract characters of a coded character set, such as
Unicode, are converted into an integer code representation suitable for storage, transmission, and
manipulation.
Entity An item that can be included in an XML representation document by referring to it by a representative name.
ETL Extract, Transform, and Load.
FOFormating Objects.
Markup Logical delimiters of a document, consisting of start tags, end tags, empty element tags,
entity references, character references, comments, CDATA section delimiters, document type declarations, processing instructions, XML declarations, text declarations, and white space outside of the
document.
Parameter Entity A distinct type of entity that is used to modify the structures of a DTD.
PCDATA Parsed Character Data, which is parsed and uses XML syntax.
Pipeline A chain of application components that allows processing data in stages.
Processing Instruction Markup used to convey information directly to an application, without
being part of the documents character data.
Prologue The optional XML declaration, document type declaration, and any comments, processing instructions, or spaces that occur at the very beginning of an XML document.
RMI Remote Method Invocation.
RosettaNet An organization that defines standards for business processes such as supply chain and
distribution management.
SAX Simple API for XML.
SGML Standard Generalized Markup Language, somewhat related to XML and HTML.
SOAService-Oriented Architecture.
SOAP Simple Object Access Protocol.
Tag The markup delimiters, element name, and (for a start tag) the attributes, demarcating the start
and end of an element instance within a document. In XML an element is expressed either as a paired
start tag and end tag, or as a single empty element tag. Contrast with element, which encompasses
the entire logical structure.
WroxPro.030912.indd 1020
3/14/12 12:25 PM
Index
IndexTitle
IndexLetter
Index1
Symbols
Index3
1021
WroxPro.030912.indd 1021
3/14/12 12:25 PM
B
// (backslash, double) expression, 160
/ (backslash) expression, 160
benefits of configuration system used by
ASP.NET, 58
binary serialization, 51
brackets ([ ]) expression, 160
BufferResponse property, 416
building XML Web service, 412416
1022
WroxPro.030912.indd 1022
3/14/12 12:25 PM
C
Call for Help program, 279
Call Me ad, 143
calls to action, 319, 321
camcorders
defined, 449
guidelines, 281283, 282
reviews, 277278, 278
camera techniques, 262263, 263
campaign comparisons in Google Analytics, 371
Cansei De Ser Sexy band, 100
captdeaf channel, 272
captions, 272273, 272, 449
CaptionTube, 281
Caraeff, Rio, 291, 407
Carl Zeiss optics, 283
Carlson, Nicholas, 152
Carnegie Mellon University, 80
Carousel application, 299
Carr, Nicholas, 119120,
119120, 239
Carroll, Jill, 113114, 114, 431
Carrozza, J. L., 132
categories
Channels tab, 56
defined, 449
Live Search Video, 110
in titles, 98
videos, 417421, 418421
Videos tab, 52
viewer statistics, 3334, 34
D
Dailymotion, 5, 7071, 70
Dancing 2006 video, 154
Darling, Jennifer, 60
Insight, 346347, 347
demonstrations, 135
Denters, Esmee, 140142, 141,
224, 423
depth of field, 450
descriptions
defined, 450
optimizing, 9798
Dickson, Tom, 398, 402
Did You Know; Shift Happens - Globalization;
Information Age (Fisch), 447448, 447
Diet Coke + Mentos video,
12, 158
diffusion networks, 8
brand channels, 197198
defined, 450
1023
WroxPro.030912.indd 1023
3/14/12 12:25 PM