Wednesday, July 4, 2012

Safe C++ - Book Review

Everybody knows how is tricky to manage all the complexity and the feature that c++ provides. From memory allocation to copy constructor ending up with address manipulation, It's very easy to make a mistake and sometimes is difficult to find the reason of it.

Safe C++ is a book for intermediate C++ users who wants avoid common mistakes that usually happens. From memory leaks to comparison operator, the book explains how a simple macro definition can help you to remove problems. The book is easy to read for who is practical with C++ and the 140  pages that composes it flows very fast. The book is composed by 17 short chapters, each of which tackles a specific issue:


The first 3 chapters are sort of introduction to the specific issues treated later in the book:
 Chapter 1: Where does c++ bugs come from?
 Chapter 2: When to catch a bug?
 Chapter 3: What to do when we encounter an error at runtime.


The middle chapters are more specific and tackles a specific issue:
 Chapter 4: Index out of bounds
 Chapter 5: Pointer Arithmetic
 Chapter 6: Invalid Pointers, References and Iterators
 Chapter 7: Uninitialized Variables
 Chapter 8: Memory Leaks
 Chapter 9: Deferencing NULL pointers
 Chapter 10: Copy Constructors and Assignment operators
 Chapter 11: Avoid writing code in the destructors
 Chapter 12: How to write consistent comparison operators
 Chapter 13: Errors when using Standard C libraries

The last three chapters talks about testing and how to help the debugging process:
 Chapter 14: General testing principles
 Chapter 15: Debug-On-Error strategy
 Chapter 16: Making your code debugger-friendly   

 This book explains how to avoid most common mistakes and bad pratices when programming in C/C++. It's a good book for intermidiate and can help also beginners to understand some tricky behaviour of C++. Together with other more general books as the pragmatic programmers series and so on, can be a good reading to master a good coding style.

Thursday, June 21, 2012

Android Cookbook - Book Review

This book talks about the new mobile OS Android. This OS (even if Framework is more appropriate) is widespreading through mobile and embedded devices. As the title suggest, this book use a Cookbook style for explain the concepts. Each problem is treated as a Recipe and is composed by 3 parts:

  • Problem: few rows to describe the problem that needs to be solved. 
  • Solution: few rows that explains briefly what must be done for solve the problem. After reading the book, this is kind of a bookmark for future research in the book and allows the reader to remember how to solve a problem simply reading few lines. 
  • Discussion: Here is described the solution in all of its aspect. The code is widely described and everything is covered to let the reader understand the solution.


Because this book covers a lot of problems with their relative solution, I prefered to copy the description of the chapters as appears in the preface of the book instead of described them myself.
What’s in This Book?
  • Chapter 1, Getting Started, takes you through the steps of setting up the Android development environment and building several simple applications of the well-known Hello, World” type pioneered by Brian Kernighan.
  • Chapter 2, Designing a Successful Application, covers some of the differences in mobile computing that will hit developers coming from desktop and enterprise software environments, and talks about how mobile design (in particular, Android design) differs from those other environments.
  • Chapter 3, Testing. Not so that you’ll skip it, but so that you’ll read and heed. We talk about unit testing individual components as well as testing out your entire application in a well-controlled way. Android provides a variety of mechanisms for communicating within an application and across applications.

  • In Chapter 4, Inter-/Intra-Process Communication we discuss intents and broadcast receivers, services, AsyncTasks, and handlers. Another communication mechanism is about allowing controlled access to data that is usually in an SQL database. 
  • In Chapter 5, Content Providers, we show you how to make an application that can be used by other applications through something as simple but ubiquitous (in Android) as the URL.
  •  Chapter 6, Graphics, covers a range of topics related to graphics, including use of the graphical drawing and compositing facilities in Android as well as using desktop tools to develop graphical images, textures, icons, and so on that will be incorporated into your finished application.
  • Chapter 7, Graphical User Interface, covers the main ins and outs of GUI development for Android. Examples are given both in XML and, in a few cases, in Java-coded GUI development.
  • Chapter 8, GUI Alerts: Menus, Dialogs, Toasts, and Notifications, covers all the pop-up mechanisms—menus, dialogs, and toasts—and one that doesn’t pop up but is also for interaction outside your application’s window, Android’s notification mechanism.
  • Chapter 9, GUI: ListView, focuses on one of the most important GUI components in Android, the ListView. Android is rich in multimedia capabilities.

  • Chapter 10, Multimedia, shows how to use the most important of these.
  • Chapter 11, Data Persistence, shows how to save data into files, databases, and so on. And how to retrieve it later, of course. Android started out as an operating system for mobile telephones.

  • Chapter 12, Telephone Applications, shows how to control and react to the telephone device that is in most mobile devices nowadays.Mobile devices are, for the most part, always-on and always-connected. This has a major impact on how people use them and think about them.
  • Chapter 13, Networked Applications, shows the coding for traditional networked applications.

  • Chapter 14, Gaming and Animation.

  • Chapter 15, Social Networking.

  • Chapter 16, Location and Map Applications, discusses how to find your location, how to get map data from Google and OpenStreetMap, and how applications can be location-aware in ways that are just now being explored.

  • Chapter 17, Accelerometer, talks about the sensors built into most Android devices and allow to use them. 
  • Chapter 18, Bluetooth, talks about the low-energy very-local area networking that Bluetooth enables, going beyond connecting your Bluetooth headset to your phone.

  • Chapter 19, System and Device Control. Since Android is Linux-based, a few of the recipes in this chapter deal with traditional Unix/Linux commands and facilities. 
  • In Chapter 20, Other Programming Languages and Frameworks, we explore the use of other programming languages to write all or part of your Android application. Examplesinclude C, Perl, Python, Lisp, and other languages.
  • Chapter 21, Strings and Internationalization, goes over the
    issues of language and culture and how they relate to Android.

  • Chapter 22, Packaging, Deploying, and Distributing/
    Selling Your App, shows how to prepare your application for distribution via
    the Android Market, and to use that as well as other markets to get your application
    out to the people who will use it.

I've never read an Android book before this one and I was a little bit suspicious about how this book would be comprehensible compared to other books more focused on the whole framework instead of single problems. I remained surprise of how this book is clear even for new comers in the Android world, each problem is discussed perfectly and the discussion part of each problem covers also the paradigms of the Android framework. Has to be noticed that a strong Java background is needed, together with a basic knowledge of the Eclipse IDE. I suggest this book for both new Android developers and expert ones, the former can find in this book an explanation about the Android framework, how to use the framework with real problems and a lot of examples that can be reused for create the application they imagine. The latter can  improve their knowledge about topics not treated in their current developments and improve with new functionality their apps.

Friday, May 11, 2012

Machine Learning for Hackers - Book Review

I was following the courses in Machine Learning through the Coursera website when i had the chance to review this book. For me it's difficult to start programming without a real motivation or pressure of a deadline and I hate myself for that. Reading or follow only theorical lectures is, of course, useful to improve your knowledge and find similar patterns in different problems but only when you start to practically use what you have learned that your mind stores the information in a more solid way.


This book tries to be less mathematical as possible, diving directly into practice with the R language functionality.
After explain the functionality of the R language, the author explains the main categories of machine learning algorithms as Supervised and Unsupervised learning.
  • Categorization: using a Bayesian Classifier wrote using R, we will be able to categorize Spam messages from good messages
  • Priority Ranking: in this chapter the author describes what features are used by google to define a priority in the received emails and provides the code for write your own ranker based on this features.
  • Linear Regression: this chapter explains one of the powerful tools of Machine Learning, Linear Regression. Using Linear Regression the case of study explains how to create a system that predicts page views of the 1000 top websites. This chapter explains also different measures of error that can be performed to test how our model works.
  • Nonlinear Regression and Regularization: the first part of the chapter explains Nonlinear regression that means when the prediction can't be mapped in the linear formula:                                       Prediction= Constant + X+Y+Z.  The second part of the chapter talks about Regularization that explains how to prevent the overfitting, that means our model fits so good the training data but is no able to fit the test data in the long run.This is due to the fitting of the training data that is so precise that starts to model also the noise (outliers) in the training data.
  • Optimization: After we define a measure of error for the model, we can tune it, optimizing some parameter. This parameters are the result of the minimization of the error measure for example. The case of study of this chapter is to build a Code breaking system. 
  • PCA: This technique allows to reduce the complexity of the data reducing the dimension of the problem and is useful to extract a vectore that resumes all the data set.
  • MDS: Sometimes is difficult to see the relations between different features without a graphical help. The MDS algorithm allows to create a clustering of all the data and is able to plot this clusters in a meaningful way.
  • K-nn nearest neighborhood: Sometimes isn't possible to define a model general for the whole dataset so, we can make a prediction using the nearest possible choices and give a score for each one. This system is used in the case study to realize a recommandations system that suggests packages based on the installed packages.
  • Social Graph: this chapter explains how social website define their connectivity model and explains how to study the relationships realizing a "Who to follow" system for twitter.
  • SVM: the support vector machine is another powerful tool for machine learning and is widely used when isn't possible to define a linear decision boundary. The case of study of this chapter is a comparison of the prediction algorithms used in the previous chapters.
For my point of view, this is a good book for who wants to dive into machine learning without know anything about math, statistic and probability. Honestly I think that this approach doesn't work well, at least for me, because some algorithms are difficult to use correctly or find a relation with our problems without the abstraction that math gives. Also, theory is useful to understand better how some parameters affect the prediction. Sometimes in the book there are notions that needs theory but instead there are explained as "change the value and see what happens" method.
Even if this is not a R programming book, the language is not clearly explain in the text and a previous study of the language is probably necessary or translating the code in a more common language as Python will help understand the problems. I've also notice some incoherence between the text and the code, in fact I've faced some errors using the code in the text while the code in the CD-Rom work perfectly.

As conclusion, I will suggest this book to someone who wants to learn autonomously concepts of machine learning but, I suggest to use the online courses for study the theory behind these algorithms.

Monday, April 23, 2012

Machine Learning Class

Hi everybody,

it's online the new Machine Learning class of Standford University through the Coursera website.

http://www.coursera.org/course/ml

Refresh your linear algebra....


This link contains an useful pdf regarding linear algebra. It's a good reading if you want to refresh your knowledge. Probably for the newbies the relations between the arguments are not so explicit and i suggest to use this pdf as complement to another book.

HTML:
http://www.numbertheory.org/book/

PDF:
http://www.numbertheory.org/book/mp103.pdf

Thursday, April 19, 2012

Hi-Tech websites

Hi folks,

I don't like to copy piece of articles from other website. So, I share with you two very famous website I use to visit. Usually they provide a lot of news and podcast about new technologies. If you know some other website, feel free to share it with everybody just commenting the post.

http://www.engadget.com/

http://www.tomshardware.com/

Friday, April 13, 2012

Pragmatic Debug IT - Book Review

I went through this book because I was interested to learn something more about debugging, not as a simple research of a bug, but as a set of methodologies and pragmatic tips that can help to write robust, clear and self-explaining software. The book is splitted into two main topics, the former is a microscopic journey through four step the author has identified as the principal operations to be executed when facing a bug; the latter is a macroscopic vision of the whole system and the author provides tips and especially tools to deal with the debugging process inside a company.

The first 5 chapter belongs to the microscopic description.
The first chapter is an introduction of the empirical approach used to remove a bug. This chapter introduces the reader to the main step of debugging:
  • Reproduce
  • Diagnose
  • Fix
  • Reflect
The other four chapter deals with each of this steps. The "Reproduce" chapter explains that reproduce a bug is the most important and sometimes difficult step to do during debugging and provides a series of suggestions as logging or control the inputs.
The "Diagnose" chapter explain what happen next the reproduction. In this phase, the programmer must define hypothesis and experiments to find the real cause of the problem. The experiments he/she conducts are aimed to verify or not his/her hypothesis. Typically the experiments:
  • Tries to examine the internal state of the software  (as example using a debugger)
  • Modify the environment the software runs in (input files, OS. variables)
  • Change the logic of the code and see the effect.
The "Fix" chapter helps to understand better the implication of your changes in the code and how to avoid regression. Finally, the "Reflect" chapter describes how the knowledge acquired fixing a bug can be shared with the others and make think about other possible errors.

The next 2 chapters gives a whole vision of bug management inside a software company. Topics of this chapters are how a company should manage bugs and bug reports,how give priorities to the bugs such as none of them is left behind before continue the development, how to deal with the customers and so on.

The last 3 chapters that completes the book gives some useful tips to how avoid bugs or simply make it easy find them. Chapter 8 explains special cases where the normal empirical approach can't be used rigorously. Chapter 9  instead explains how Automatic Testing, Automatic Builds, Source Control, Continuos integration system and so on can be a blessing for debugging. The last chapter close the book explaining ways of how our code can be "prepared" to be debugged in a more easy way and how our software can give us useful information without effort.

I found this book very helpful and even if doesn't teach you to found a bug in 2 seconds It gives you a method to debug your software more efficiently and make the software debug itself. Also provides some clues about set of tools that can be used for the process. The "experiences" paragraphs through the book helps to understand better how to apply the tips of the book and also clarified which are the errors I used to do while debugging.