I have the most basic Edit Post screen finished. No custom control implemented so far–want to stay with the native ones. I’m still not sure about the
category selection–need to look around what other people do.
A chapter in UI Design and Interaction Guide for Windows Phone 7 concerning text capitalization says that list items are to be displayed in lowercase. But the Design Templates released as Photoshop files and a Windows Phone app show list items in sentence caps.
What to do?
When you click your mouse on one of the input fields in a form, you will get the onscreen keyboard on Windows Phone 7 emulator. It’s worse than using your thumbs on your real phone because you actually has to click one character at a time with your mouse.
Now, while you still can see the onscreen keyboard, press the [Pause/Break] key (to the right of [Scroll Lock] key, at least on my keyboard–my computer keyboard). If you do it right, the onscreen will disappear and you can do your form entry with your physical, full-size keyboard.
Microsoft released the UI Guide and Design Templates for Windows Phone 7 some time ago. The design templates contained several Photoshop files showcasing common user interface elements of Windows Phone.
The past few months, I seemed to have absorbed information like a sponge. My amazon.com’s orders history said I had bought 9 books this year. And there were books I purchased from my neighborhood bookstore that I didn’t keep track. I didn’t see the pattern would stop and my bookshelf had no more vacancy. I had to put away some books in boxes. I had books scattered on tables and the floor. I needed a solution; I bought a Kindle.
My Kindle is the DX kind with 9.7″ display. I’ve had it for two weeks and I’ve finished a few books. I read books a programmer would read–programming or technical books. To name a few, these are the books I’ve read or are currently reading on my Kindle.
- Expert .NET Delivery Using NAnt and CruiseControl.NET
- Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries
- Patterns of Enterprise Application Architecture
- Effective C# (Covers C# 4.0): 50 Specific Ways to Improve Your C#
- The Art of Unit Testing: with Examples in .NET
I’ve been content with traditional books other than the fact that they take up so much space. The Kindle’s solved that. But are there any trade-offs?
No More Dual Pages
Imagine you walked in one morning to your cubicle only to find that one of the two monitors you had had been taken away. Now we all know the benefits of dual monitor setup. What are the drawbacks of seeing only a single page at a time?
The technical books that we, programmers, read contain code listing, diagrams, and/or screenshots. A traditional book will have one of those illustrative elements (code listing, diagrams, or screenshots) and the corresponding, explanatory paragraphs immediately on the same page or on the opposing page. When we read on a Kindle with its single-page “feature,” we don’t have the convenience of having all correlated content in front of us at the same time. We can’t as seamlessly switch back and forth between reading the paragraphs and examining the illustration as we can a traditional book. But we can always turn the page back and forth, can’t we? <sarcasm>Have fun with that. (Read on.)</sarcasm>
Slow Refresh Rate
It takes two seconds to turn a page on Kindle. It’s not a big deal when we only have to do it once every few minutes. But when we have a big chunk of code which takes up one full-page, the explanatory paragraphs must go to the next page. The routine is to read a portion of code listing, read two or more sentences, and repeat. But the routine becomes irritating when it’s interrupted with 2-second delays of page turning.
When we finish reading a chapter or a section of a book and arrive at another, sometimes we want to know how big the section is before we commit to continuing reading. To accomplish that, we have to turn few pages ahead until we find the beginning of the next section. With the slow refresh rate of Kindle screen, turning 2 pages or more is a chore.
Inconsistent, Less Readable Code Listing
There are three formats of e-book that we can read on a Kindle: PDF, mobi, and kindle. The display of code listing seems to vary by the format, publication date, and the publisher. (The preceding sentence is mostly speculation because I don’t have enough samples.)
Unlike the content where the same font family is used across all e-books (excluding PDFs), code listings in different e-books use different font family, with varying sizes (some are too large which cause unnecessary wrapping), and resizability (whether we could resize the font). Some books still sticks to using images to display code listings. I will post more detailed observation and samples on the code listing from various books in part 2 of the post.
Some code listings use lighter shades which reduces contrast, and, consequently, readability. Some other do not use proper indentation which makes the code block to not have clear structure.
So far I’ve managed to get the books that I wanted in kindle (from amazon.com) or mobi format (from the respective publisher). mobi format in overall reads as well as the kindle format. Some features in Kindle are not available for mobi format: synchronizing to furthest page read, viewing book description, and viewing popular highlights; I rarely or do not use those features.
If a book is available electronically in PDF format only, I advise against purchasing it. The text may come out too small to comfortably read. Resizing the page to optimize viewing is somewhat exasperating. I could zoom in and set the view port to the center (where the content is), but when you turn the page, the view port will go to the left of the page and I have to re-position the view port back to center.
When a book is available electronically in PDF format only, there may be a chance that the PDF has certain feature that Kindle is not able to open it. The PDF of “Applying Domain-Driven Design and Patterns: With Examples in C# and .NET,” for example, can’t be read in Kindle because it’s, I’m guessing, watermarked.
I went to the bookstore the other day and I was tempted to bring home a book that I liked. Yes, traditional books are still that much better than e-books. Unlike music collection, you only need one book at a time. For sure I didn’t buy Kindle for its portability. But I seriously don’t have space for things that will be used for a short period of time and drown my room most of the time. In the end, Kindle has solved my storage problem.
If you come from the world of always-use-stored-procedures or at least you always write your own SQL query, you’d be curious how LINQ to SQL translates your C# code to SQL query. Say you have table Persons with fields PersonId, FirstName, LastName, and Age. PersonId is the primary key of the table Persons.
In this example, we want to update a particular row (PersonId = 1) with a new Age value. So, we write the following block of code in our application.
Entities.DataContext context = new Entities.DataContext(); int personId = 1; Entities.Person person = context.Persons.SingleOrDefault(p => p.PersonId == personId); person.Age = 24; context.SubmitChanges();
To see the generated SQL query, we want to redirect the log of DataContext object to console.
Entities.DataContext context = new Entities.DataContext(); context.Log = Console.Out; int personId = 1; Entities.Person person = context.Persons.SingleOrDefault(p => p.PersonId == personId); person.Age = 24; context.SubmitChanges();
Now, when we run the application, you will see the SQL queries generated by your code in console window. The SQL query will look something similar to the following.
UPDATE [dbo].[Persons] SET [Age] = @p4 WHERE ([PersonId] = @p0) AND ([FirstName] = @p1) AND ([LastName] = @p2) AND ([Age] = @p3) -- @p0: Input Int (Size = 0; Prec = 0; Scale = 0)  -- @p1: Input NVarChar (Size = 4; Prec = 0; Scale = 0) [John] -- @p2: Input NVarChar (Size = 5; Prec = 0; Scale = 0) [Smith] -- @p3: Input Int (Size = 0; Prec = 0; Scale = 0)  -- @p4: Input Int (Size = 0; Prec = 0; Scale = 0)  -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.4926
If you’re used to writing your own query, you probably wonder why the WHERE clause is verbose (or wordy, an English major will say). You see the query tries to find the row to update by matching every single field in the table with their old values. “Well, that’s dumb, ain’t it?” you say. “We can find the row to update by matching only the value of the primary key, PersonId.” Here’s how.
- Go to your Solution Explorer in Visual Studio and double click the .dbml file.
- Click the property PersonId on the class diagram.
- Go to Properties window (it’s on bottom right on default window setup) and find the property
Update Check. The current value should be
- Change it to
Repeat step 2-4 for all properties (FirstName, LastName, and Age).
Update the application to update the Age to 25 (previously 24). Rebuild and re-run the application. You will see the update statement that you probably always write.
UPDATE [dbo].[Persons] SET [Age] = @p1 WHERE [PersonId] = @p0 -- @p0: Input Int (Size = 0; Prec = 0; Scale = 0)  -- @p1: Input Int (Size = 0; Prec = 0; Scale = 0)  -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.4926
So, what’s the purpose of the property Update Check? The property description says it all. It’s to control the frequency of optimistic concurrency checking.