How to Say “NO” Without Discouraging Your Associates

Saying “no” to trivial and distracting things is the essence of leadership. To achieve the most important goals of a business, the business leader will need to say “no” at some time or another.

Saying “no” can harm your business drastically. It can cause loss of focus, enthusiasm and inspiration in your team members. Luckily, there are productive ways to communicate it that won’t discourage team members. Forbes explores three ways to say no:

1. “Yes!”
2. “Let’s explore.”
3. “What if?”

Read the complete article at Forbes.

Share

HTML5 & CSS3 in Visual Studio 2010 SP1

Visual Studio 2010 was originally released without HTML5 support, so does SP1 finally add support for it? Yes, to some extent. The entire HTML5 specification isn’t supported but most of the new elements and attributes are. That means you get both intellisense and validation for HTML5 with SP1.

Read the full article here

Share

Unit Testing with Boost.Test – Writing Your First Test Case

In this post I will show you how to perform unit testing with Boost.Test. If you do not have the boost libraries installed, read my post “Unit Testing with Boost.Test – Installing Boost.Test”.

Boost Test Library has following four components:

  • The Execution Monitor whose purpose is function level uniformed exception handling and error reporting.
  • The Program Execution Monitor relieves users from messy error detection and reporting duties by providing a replacement function main() which uniformly detects and reports the occurrence of several types of errors, reducing them to a uniform return code which is returned to the host environment.
  • Minimal Testing Facility provides only minimal basic facilities for test creation without any configuration options and supplies a limited set of testing tools.
  • Unit Test Framework is the focus of this post. It is an easy to use and flexible solution for C++ unit test implementation and organization.

For the rest of this post we will focus only on the unit testing framework (refered to hereinafter as UTF).

Boost Test Library components can be used by either linking to the precompiled library or by including the single-header file. For example, to use the UTF you may either include the <boost/test/unit_test.hpp> and link with unit_test_framework shared library or include <boost/test/included/unit_test.hpp> in which case there is no need to link with any precompiled component.

Writing First Test Case (Using Single UTF Header)

To get a grip on how to use Boost.Test in both the shared library and included hearder form, we will first write a program that uses the single UTF header and then change that program to use the pre-compiled UTF shared library. So fire up your favorite IDE, create a new C++ project and paste the following code in your `main.cpp` and compile the project.
In case you encounter errors about `unit_test.hpp` not found, check your include library paths and make sure you have included $BOOST_HOME as a include file location.

#define BOOST_TEST_MODULE MyTest
 
#include <boost/test/included/unit_test.hpp>
 
int add( int i, int j ) { return i + j; }
 
BOOST_AUTO_TEST_CASE( my_test )
{
    // seven ways to detect and report the same error:
    BOOST_CHECK( add( 2,2 ) == 4 );        // #1 continues on error
 
    BOOST_REQUIRE( add( 2,2 ) == 4 );      // #2 throws on error
 
    if( add( 2,2 ) != 4 )
      BOOST_ERROR( "Ouch..." );            // #3 continues on error
 
    if( add( 2,2 ) != 4 )
      BOOST_FAIL( "Ouch..." );             // #4 throws on error
 
    if( add( 2,2 ) != 4 ) throw "Ouch..."; // #5 throws on error
 
    BOOST_CHECK_MESSAGE( add( 2,2 ) == 4,  // #6 continues on error
                         "add(..) result: " &lt;&lt; add( 2,2 ) );
 
    BOOST_CHECK_EQUAL( add( 2,2 ), 4 );	  // #7 continues on error
}

The command line that I used to compile and run the above code and the program output is given below:

$ g++ -o main main.cpp -I/usr/local/include/boost/trunk/
$ ./main
Running 1 test case...
 
*** No errors detected
$

The above code shows seven different ways to detect and report errors in the code. The description of these different tools is available on Boost.Test website so I won’t repeat that here. You should play with the code and change the success conditions to see what happens.

Writing First Test Case (Using Boost.Test Pre-Built Library)

To use the Boost.Test as a pre-built library component (which is the preferred way for large projects) first of all change the path for the include file in the previous example from

#include <boost/test/included/unit_test.hpp>

to

#include <boost/test/unit_test.hpp>

You have two choices to use Boost.Test pre-compiled binary with your project. You can use it as either a shared library (libboost_unit_test_framework.so) or statically compile your program with it (libboost_unit_test_framework.a).

To statically build your program, use the following command:

g++ -o main main.cpp -I/usr/local/include/boost/trunk/ -L/usr/local/include/boost/trunk/stage/lib/ -static -lboost_unit_test_framework

Note the -static compiler option before the library name. It instructs `g++` to statically link the library with the program.

In order to use the boost unit test framework as a shared library, add

#define BOOST_TEST_DYN_LINK

preprocessor directive just before you include boost test header file as below:

#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

and build with the following command:

g++ -o main main.cpp -I/usr/local/include/boost/trunk/ -L/usr/local/include/boost/trunk/stage/lib/ -lboost_unit_test_framework

If you now run this program you might get the following error:

./main: error while loading shared libraries: libboost_unit_test_framework.so.1.45.0: cannot open shared object file: No such file or directory

This is because we are now using Boost.Test UTF as a shared library and for the program to execute, it must find the required libraries. There are three different ways to do that:

  1. You can add library directories to be included during dynamic linking to the file /etc/ld.so.conf OR
  2. You can add specified directory to library cache using ldconfig OR
  3. You can specify the environment variable `LD_LIBRARY_PATH` to point to the directory paths containing the shared object libraries

After you have updated the library search path using either one of the above methods, you can run the program as before and verify that all tests are successful.

Congratulations, you are now able to use Boost.Test in your programs to write basic unit tests. In a future post, I will show you how to use the UTF in more complex programming scenarios.

Share

Unit Testing with Boost.Test – Installing Boost.Test

if Jeff Atwood and Mr. T can not convince you of the benefits of unit testing then I don’t know who else can. So I won’t press the issue of writing test cases before coding or unit testing at all. Instead, as you are reading this post, I am assuming that you are not “the fool” being pitied upon by Mr. T and actually consider writing test cases a coding prerequisite.

Now that we have agreed upon (at least I am assuming we have) the importance of unit testing, we’ll come to the title of this post “Unit Testing with Boost.Test”. Why Boost.Test (or any other testing framework for that matter)? You can very well write test cases using `assert` macros but this approach is very trivial and rigid and does not lend itself to flexibility and versatility in the writing of test cases (as we shall see in the next part of this post). These limitations render the `assert` macro unsuitable for more complex projects. Boost.Test is an easy to use and flexible way to write use cases and is part of the boost c++ libraries which is a set of standards compliant, cross platform c++ libraries.

In this post I will show you how to install the boost libraries. You can download a version appropriate for your platform from http://www.boost.org/users/download/#releases and extract to a folder in a common location (e.g. /usr/local/include/boost). If you’d rather checkout an svn snapshot, you can do an svn checkout by issuing following command in a shell:
$ svn co http://svn.boost.org/svn/boost/trunk boost-trunk
Please visit http://www.boost.org/users/download/#repository for more instructions.
If you are using Ubuntu, you can also do
$ sudo apt-get install libboost-test-dev
But I don’t recommend this approach as the packages are somewhat out of date.

I will be using version 1.45.0 of boost libraries for this article which is the latest at the time of this writing. if you have any previous version installed, please check the changelog to see if you need to upgrade to this version. eventhough its always best to use latest release build of any library, some of your projects might break with new changes so be carefull to read the changelog carefully before upgrading.

If you need more info about installing boost libraries, please visit this page if you are on *nix or go here if you are on Windows platform.

Now that we have installed boost libraries, we need to set up our development environment but before that there is something else that we need to take care of. The boost libraries are mostly header only. That is, they consist entirely of header files containing templates and inline functions and require no separately-compiled library binaries but there are some libraries that must be built separately and then there are some libraries that can _optionally_ be compiled separately. Boost.Test is of the latter form. You can use it as a header only library or you can pre-compile it and link your project to this binary. It is recommended that this library be used as a separately compiled binary as it will greatly reduce the compilation time for your project.

Building the Boost.Test library is not very complicated. Boost has its own build system which is accessible from the boost installation directory. To build Boost.Test perform following steps:
`cd` to the boost installation directory (assuming your installation directory is /usr/local/include/boost/trunk)
$ cd /usr/local/include/boost/trunk
To see all available options
$ ./bootstrap.sh --help
To see a list of all libraries that need to be / can be built do
$ ./bootstrap.sh --show-libraries
You probably only want to build Boost.Test so type following in a shell
$ ./bootstrap.sh --with-libraries=test
When this command successfully finishes execution you will get a message indicating that bootstrapping has been successfully done. Next you will actually build the library. Type following on the shell
$ ./bjam
Once `bjam` finishes successfully, it will place the library binaries in $BOOST_HOME\stage\lib directory.

Verify the existance of `libboost_unit_test_framework.a` and `libboost_unit_test_framework.so` in that directory. Your Boost.Test installation is ready. In the next post we will set up a sample project and look at how we can use Boost.Test in our projects to benefit from this great testing framework.

Share

OpenID OR OAuth – That is the Question

You probably have heard about OpenID and OAuth (if you haven’t been living in a non-connected place for past few years) and you’re probably wondering when and why should you choose one over the other or why can there not be only one, why they both exist.

In this blog post I will try to explain what OpenID and OAuth are and what differentiates the two from each other.

What is OpenID

OpenID is an open technology standard that allows the users to sign-in to all (OpenID enabled) websites across the Internet.

Once you sign up for an account with an OpenID provider, you will be able to simply provide any OpenID enabled website with the URL of that provider which will send you to your provider to verify your account. After verification with your provider, you will be sent back to the website you were originally visiting and be signed in to that website, automatically

I will further narrate this with the help of a little vignette:

  • You want to log in to www.example.com
  • www.example.com (“Relying Party”) gives you the option to login with your OpenID
  • You provide your OpenID or the URL the OpenID Provider
  • The “Relying Party” redirects your “browser-agent” to the OpenID provider
  • You authenticate your account with your OpenID provider which then redirects you back to www.example.com
  • You are signed in to www.example.com and can continue using your account

Here is a list of OpenID providers on Wikipedia

What is OAuth

OAuth (Open Authorization) is an open standard for authorization. This means that it is a means for users to give access rights to their resources (photos, contacts, groups etc.) on one website to another website without providing their login information to the requester. For example when you “Allow” an application or website to post tweets on twitter on your behalf. Another case would be when you need to import your contacts from your email provider (e.g. Gmail) into a social networking website (e.g. Facebook), if they are OAuth enabled, you will only need to set access rights on your address book to allow access to Facebook. Otherwise you’d have to provide your Gmail user name and password to Facebook (something that I never ever do, the reason for which requires another blog post and some more investigation) for it to access your Gmail address book.

So here is how OAuth actually works:

  • User has created a cool new group on www.example.com
  • User wants to tweet about this group so his friends become aware of it and join it
  • www.example.com (“Consumer”) redirects the user to twitter.com (“Service Provider”)
  • User authenticates himself to twitter.com
  • twitter.com asks the user if he wants to allow www.example.com access to his account
  • Based on the user’s decission, twitter.com redirects the user back to example.com
  • example.com tweets user’s latest activity on twitter

To summarize all this we can say that both OAuth and OpenID exist to serve distinct purposes even though they might have similarities in the way they work. OpenID is a means for users to authenticate themselves (i.e. prove that they are who they claim they are) whereas OAuth provides the users with a means to authorize one website (or application) to access their data stored on another website without sharing the authentication information for the provider website (which could very well be using OpenID to authenticate the user in the first place).

Share

Adobe AIR goes Cross-Platform

At the MAX 2010 conference, Adobe announced the launch of the cross-platform AIR runtime environment. What this means is that the now apps created for the Adobe’s AIR runtime will now have a larger audience in the form of televisions (Samsung has announced the support for the new AIR 2.5 runtime in its SmartTVs), tablets and smartphones based on BlackBerry Tablet OS, Android and iOS, along with the already supported, desktop operating systems including Windows, Macintosh and Linux.

In addition to AIR 2.5, Adobe has also unveiled Adobe InMarket, a new service that allows developers to distribute and sell their applications across different device types on app stores from Acer, Intel, and others.

The new AIR runtime includes new features such as support for SQLite databases, accelerometer, camera, video, microphone, multi-touch, gestures and geo-location along with the ability to support native browser controls within the application.

Share

Microsoft meets Minority Report

Malcolm Moore tells us about his day at Microsoft Research Lab in Shanghai where he had a sneak preview of some of the technology that is being developed there.

These futuristic technologies include glass computers that you wave your hands in front of as well as mirrors that let you model your wardrobe virtually and glasses that tracked your eye movement.

More about this on China Economic Review.

Share

London Stock Exchange smashes world record trade speed with Linux

“The London Stock Exchange has said its new Linux-based system is delivering world record networking speed, with 126 microsecond trading times.

The news comes ahead a major Linux-based switchover in twelve days, during which the open source system will replace Microsoft .Net technology on the group’s main stock exchange. The LSE had long been criticised on speed and reliability, grappling with trading speeds of several hundred microseconds.

The record breaking times were measured on the LSE’s Turquoise smaller dark pool trading venue, where trades are conducted anonymously. That network switched over to Linux from Cinnober technology two weeks ago. Speed is crucial as more firms trade automatically at lightning speed, using advanced algorithms.”

Computer World UK has more on the story

Share

Mac OS X Lion and the new Mac App Store

Shipping in the summer of 2011 and sporting many of the iPad’s software innovations, Mac OS X Lion will be the eigth major release of the so-called “world’s most advanced operating system”. According to the Apple’s Mac OS X Lion website, features that OS X Lion will have include the Launchpad, a new home for Mac applications which gives instant access to apps in iPad’s style; support for full-screen apps; and Mission Control which will give users a bird’s-eye view of Expose, Dashboard, Spaces, and full-screen apps.

For application developers, the newly introduced Mac App Store will be most interesting which will enable them to distribute apps written for Mac OS X in the same way they are used to for apps for iPhone, iPod touch, and iPad via the App Store.

It promises to make it as easy to download Mac OS X apps as it is to add a favorite magazine to an iPad or a new game to iPod touch by allowing the users to browse Mac apps by category, such as games, productivity, music, and more or by searching for specific apps.

Apple is also launching the new MacBook Air, which will replace mechanical hard disks and optical drives with Internet services and solid-state flash storage, the first of the next generation of notebooks. Available in 11-inch and 13-inch models and weighing as little as 2.3 pounds, the MacBook Air is Apple’s lightest notebook ever. MacBook Air uses the same solid-state storage technology as iPad to deliver instant-on responsiveness, up to seven hours of battery life, and up to 30 days of standby time.

Share

Haze along the Himalaya

A layer of haze has been covering Lahore and upper Punjab areas and according to NASA Earth Observatory, this ranslucent veil which concentrates in the southeast, covered southern slopes of the Himalaya, in late October 2010, straddling the border between Pakistan and India stretching over hundreds of kilometers.

Share
Return top
 

Switch to our mobile site