Working with Code in e-Books

Most of my technical readers now use e-books instead of paper books. Of course, there is a convenience factor to storing your entire library on a Kindle, even if it’s a software version of the Kindle. Of course, there are all sorts of e-book formats for your desktop system as well. The point is that electronic format makes a lot of sense when dealing with technical books.

However, e-books can cause some interesting problems and I’ve encountered a few with a number of readers now. The most important consideration is that you can’t cut and paste code from an e-book directly into your IDE and expect it to work. There are all sorts of reasons for this exclusion. For example, cutting and pasting may insert special characters into the output stream or the resulting paste may not have white space in the right places. A common problem is that publishers often convert regular single and double quotes into curly quote equivalents. The two kinds of quotes (both single and double) are completely different and the second type definitely won’t compile.

The best option when working with an e-book is to view the code in the e-book, but still get the downloadable source code for the book from the publishers website. I always provide a blog post detailing where to obtain the downloadable source for a book, when you need source code to use the book. If you can’t find the downloadable source, always feel free to contact me at John@JohnMuellerBooks.com. I want to be sure you have a great reading experience, which means having source code that actually runs in your development environment.

Another potential problem with e-books is that you may see unfortunate code breaks (despite the efforts of the publisher and myself). When you need to understand how white space works with a programming language, always review the downloadable source. The fact that the downloadable source compiles and runs tells you that all the of white space is in the right place and of the correct type. Typing the source code directly out of your e-book could result in added carriage returns or other white space errors that will cause the code to fail, even though the commands, variables, and other parts of the code are all correct.

As always, I’m open to your questions about my books. If you don’t understand how things work, please contact me—that’s why I’m here.

 

Using the Correct Product with MATLAB for Dummies

A reader recently wrote in with a problem with the example on pages 311 and 312 of MATLAB for Dummies. In this case, the reader was using the R2015b academic license edition. What the reader saw was this error:

>> A = magic(4)

A =

    16     2     3    13
    5    11    10     8
    9     7     6    12
    4    14    15     1

>> factor(sym(A))
Error using sym/factor (line 50)
The first argument must be a scalar.

It turns out that the newer version of MATLAB doesn’t provide the same support as the R2013b release used for the book. As a result, the example code doesn’t work as expected because the newer version requires different code that looks like this:

A=magic(4)
for i=1:4
    for j=1:4
        B{i,j}=factor(A(i,j));
    end
end

To get all factors double click on B in the workspace window. This workaround is needed because the newer version no longer supports the old method of performing the task.

The point is that the book is written to use a specific version of MATLAB, R2013b, so you must have that version in order to get good results. Fortunately, you can still get the R2013b release. All you need to do is go to the Mathworks site at: http://www.mathworks.com/downloads/select_release. Simply choose the R2013b release from the Download Earlier Release list after you have logged in. Please let me know if you have any questions or concerns at John@JohnMuellerBooks.com.

 

Browser Support in My Books

A number of my books rely on browser output to show the result of various coding techniques, including Security for Web Developers, HTML5 Programming with JavaScript for Dummies, and CSS3 for Dummies. I try to keep up with changes in technology with my books and I’m currently testing the code in all three books with Internet Explorer 11. According to a recent ComputerWorld article, users of older version of IE only have six weeks to make an update to the new version. They can also use the Edge browser or move to a competitor’s browser. My books list the browsers I used for initial testing of the source code, but I do try to at least check the code with newer browsers to ensure you have a good reading experience. In this case, the check is critical because I can’t expect you to rely on unsupported software to use my books.

When I originally wrote each of these books, I had at least one technical editor and a number of beta readers checking my code under various conditions to ensure the code would run as advertised on the maximum number of systems. I no longer have the support, so I’m testing these updates on just my systems. If you encounter a problem with the source code of any of these books, please be sure to contact me at John@JohnMuellerBooks.com. Now, here’s the important part. Make absolutely certain to let me know that you’re using a newer browser—one not originally tested in the book so I can handle your query correctly and also provide an update on my blog. Your input will help other readers.

Whenever possible, I encourage readers to use the environment described in the book to write their own code. Doing so reduces the potential for problems because I know that the environment is tested by a number of people in a number of environments. However, sometimes using the original environment isn’t possible any longer, such as this instance where Microsoft is putting its collective foot down and forcing an update. Please be sure to write me if you have any questions about the source code for these book. Thanks, as always, for your continued support!

 

Source Code Placement

I always recommend that you download the source code for my books. The Verifying Your Hand Typed Code post discusses some of the issues that readers encounter when typing code by hand. However, I also understand that many people learn best when they type the code by hand and that’s the point of getting my books—to learn something really interesting (see my principles for creating book source code in the Handling Source Code in Books post). Even if you do need to type the source code in order to learn, having the downloadable source code handy will help you locate errors in your code with greater ease. I won’t usually have time to debug your hand typed code for you.

Depending on your platform, you might encounter a situation the IDE chooses an unfortunate place to put the source code you want to save. For example, on a Windows system it might choose the C:\Program Files folder (or a subdirectory) to the store the file. Microsoft wants to make your computing experience safer, so you don’t actually have rights to this folder for storing your data file. As a result, the IDE will stubbornly refuse the save the files in that folder. Likewise, some IDEs have a problem with folder names that have spaces in them. For example, your C:\Users\<Your Name>\My Documents folder might seem like the perfect place to store your source code files, but the spaces in the path will cause problems for the IDE and it will claim that it can’t find the file, even if it manages to successfully save the file.

My recommendation for fixing these, and other source code placement problems, is to create a folder that you can access and have full rights to work with to store your source code. My books usually make a recommendation for the source code file path, but you can use any path you want. The point is to create a path that’s:

  • Easy to access
  • Allows full rights
  • Lacks spaces in any of the path name elements

As long as you follow these rules, you likely won’t experience problems with your choice of source code location. If you do experience source code placement problems when working with my books, please be sure to let me know at John@JohnMuellerBooks.com.

 

C++ All-in-One for Dummies, 3rd Edition, Error

It seems to be my week for reporting errors! Just yesterday I reported one in Beginning Programming with Python For Dummies. Today I’m reporting an error in C++ All-In-One for Dummies, 3rd Edition. If you look in Book I Chapter 3 on page 67, you see Listing 3-6. The listing title tells you that this example uses brackets to access an individual character in a string, which is precisely what it does. However, what the example is supposed to do is show you how to create the string in the first place. Look at Listing 3-7 on page 68 and you see an example that performs this task. The two listings are switched. As you go through the book, please use Listing 3-7 first and Listing 3-6 second. I’m sorry about any confusion caused by the error. Please contact me at John@JohnMuellerBooks.com if you have any questions about this or any other error in the book. I’ll be only too happy to help.

 

Beginning Python for Dummies Chapter 13 Error

Even with the most carefully crafted book, errors do creep in (see Errors in Writing). There is an error in Chapter 13 of Beginning Programming with Python For Dummies on page 247. In Step 8 you are supposed to, “Type MyTuple[4] and press Enter.” The output information for that step is wrong. Instead of seeing Orange, as specified in the book, you see Yellow. The value Yellow was added to the tuple in Step 7 as the fifth value, which you access using MyTuple[4]. I’m sincerely sorry about any problems that the error may have caused in using the book. Please let me know if you have any questions about this issue at John@JohnMuellerBooks.com.

 

Using My Coding Books Effectively

A lot of people ask me how to use my books to learn a coding technique quickly.  I recently wrote two articles for New Relic that help explain the techniques for choosing a technical book and the best way to get precisely the book you want. These articles are important to you, the reader, because I want to be sure that you’ll always like the books you purchase, no matter who wrote them. More importantly, these articles help you get a good start with my coding books because you start with a book that contains something you really do need.

Of course, there is more to the process than simply getting the right book. When you already have some experience with the language and techniques for using it, you can simply look up the appropriate example in the book and use it as a learning aid. However, the vast majority of the people asking this question have absolutely no experience with the language or the techniques for using it. Some people have never written an application or worked with code at all. In this case, there really aren’t any shortcuts. Learning something really does mean spending the time to take the small steps required to obtain the skills required. Someday, there may be a technology that will simply pour the knowledge into your head, but that technology doesn’t exist today.

Even reading a book cover-to-cover won’t help you succeed. My own personal experiences tell me that I need to use multiple strategies to ensure I actually understand a new programming technique and I’ve been doing this for a long time (well over 30 years). Just reading my books won’t make you a coder, you must work harder than that. Here is a quick overview of some techniques that I use when I need to discover a new way of working with code or to learn an entirely new technology (the articles will provide you with more detail):

  • Read the text carefully.
  • Work through the examples in the book.
  • Download the code examples and run them in the IDE.
  • Write the code examples by hand and execute them.
  • Work through the examples line-by-line using the debugger (see Debugging as An Educational Tool).
  • Talk to the author of the book about specific examples.
  • Modify the examples to obtain different effects or to expand them in specific ways.
  • Use the coding technique in an existing application.
  • Talk to other developers about the coding technique.
  • Research different versions of the coding technique online.
  • View a video of someone using the technique to perform specific tasks.

There are other methods you can use to work with my books, but this list represents the most common techniques I use. Yes, it’s a relatively long list and they all require some amount of effort on my part to perform. It isn’t possible to learn a new technique without putting in the time required to learn it. In a day of instant gratification, knowledge still requires time to obtain. The wisdom to use the knowledge appropriately, takes even longer. I truly wish there were an easier way to help you get the knowledge needed, but there simply isn’t.

Of course, I’m always here to help you with my books. When you have a book-specific question, I want to hear about it because I want you to have the best possible experience using my books. In addition, unless you tell me that something isn’t working for you, I’ll never know and I won’t be able to discuss solutions for the issue as part of blog post or e-mail resolution.

What methods do you use to make the knowledge you obtain from books work better? The question of how people learn takes up a considerable part of my time, so this is an important question for my future books and making them better. Let me know your thoughts about the question at John@JohnMuellerBooks.com. The same e-mail address also works for your book-specific questions.

 

Where is Python 3?

A number of readers have been sending me e-mail about Beginning Programming with Python For Dummies and why I chose to use Python 3.3 instead of one of the Python 2.x versions. In general, I believe in using the most up-to-date version of a language product available because that’s the future of programming for that language. So, it wasn’t too surprising to me that I noted in a recent InfoWorld article that Fedora 22 will have Python 3 installed by default. I’ve started noticing that Python 3 will be the default with other products and in other environments too. Choosing Python 3.3 for this particular book looks like a really good choice because anyone reading it will be equipped to work with the latest version as it becomes adopted in a wider range of environments.

I do talk about standard Python in Professional IronPython. Of course, this book is targeted toward IronPython users, not Python users, but talking about standard Python and how you can use both libraries and utilities from it seemed like a good idea when I wrote the book. You need to remember that a solid version of Python 3 wasn’t available at the time I wrote this book and that Python 2 was really popular at the time. If there are readers of this book who would like me to create a series of posts that discuss using Python 3 libraries and tools with IronPython (assuming it’s possible), you need to let me know at John@JohnMuellerBooks.com. I try to accommodate reader needs whenever I can, as long as there is an interest in my doing so. At this point, I haven’t had a single reader request for such support, which is why I’m making a direct request for your input.

This leaves my current book project, Python for Data Science for Dummies. It turns out that the Data Science community is heavily involved with Python 2. My coauthor, Luca, and I have discussed the issue in depth and have decided to use Python 2 for this particular book. The limitation is that the libraries used for Data Science haven’t been moved to Python 3 completely and the entire Data Science community still uses Python 2 exclusively. If it later turns out that things change, I can certainly post some updates for the book here so that it remains as current as possible.

Python is an exception to the rule when it comes to languages. There are currently two viable versions of the language, so I can understand that some readers are completely confused. I encourage you to contact me with your thoughts, ideas, and concerns regarding the use of specific Python versions in my books. I want you to feel comfortable with the decisions that I made in putting the books together. More importantly, your input helps me decide on content for future books, articles, and blog posts. Unless I know what you need, it’s really hard to write good content, so please keep those e-mails coming!

 

Python 2.7.9 Update

Beginning Programming with Python For Dummies is based on Python 3.3. However, I know that some of you are using Python 2.x installations instead. My book does discuss some of the differences between the two releases and makes you aware of examples that won’t work. However, if you do decide to use Python 2.x despite the limitations when it comes to the book, I highly recommend you get the Python 2.7.9 update. The update contains a slew of important bug fixes, many of which affect security, which is always an important issue when it comes to applications.

A reader recently sent me an InfoWorld Tech Watch article that highlights the updates in the 2.7.9 release for you. The most important thing to know from a book perspective is that the update doesn’t offer any new features. This means that if an example didn’t work with 2.x in the past, it won’t work with 2.7.9 either.

A number of readers feel that the Python 2.x releases are better and the bug updates simply mean that it remains popular. Because the 3.x release is the preferred release, I chose to focus on it when I wrote the book. Yes, you can use my book with the 2.x release, but I guarantee some examples simply won’t work with it.

Please let me know if you have any other questions about my book, the level of Python support it provides, or whether the Python 2.7.9 release will provide any book-related advantage other than ensuring your system will remain safe at John@JohnMuellerBooks.com. I want to ensure you have the best reading experience possible. However, there isn’t any chance at all that I’ll rewrite book examples to work with 2.x unless there is a significant number of readers who want this feature. Even then, some examples simply won’t work because there is no workaround to make them work (essentially the reason we needed the 3.x update).

 

Missing Source Code Files for Beginning Programming with Python for Dummies

A number of readers have written to ask about the downloadable source code for Beginning Programming with Python For Dummies. At one point, the downloadable source was featured on the Extras page and I provided a link to it as part of the Getting Your Beginning Programming with Python for Dummies Extras post. The other extras are still in place, but the source code has moved location. You can now find it on the book’s main page immediately below the initial book description on the Downloads tab. I’m sorry for any confusion that the site setup change caused, but it actually took me by surprise as well and I had to research the actual location of the code. Those of you who asked me about the download through e-mail have already received a response.

I always want you to have the best possible learning experience with my books. That means having access to all the resources that the book has to offer. I’ll also keep providing required updates and tell you when others find errors so that you don’t have to work through it yourself. Please feel free to contact me with any book-specific questions you might have at John@JohnMuellerBooks.com.