29 December 2011

Using C++11 std::tuple

A snippet of C++ unit test code showing how to use std::tuple. Using enums to help index the std::get function that is used to retrieve tuple values. Note that std::tuple_size class is used to get the value (size) of the typedef Tuple_t.

 #include <UnitTest++.h>  
#include <tuple>
SUITE(TUPLES){
TEST(Tuples) {
enum TupleIndex {MEAN, STDDEV, SIZE};
typedef std::tuple<double,double> Tuple_t;
CHECK_EQUAL( SIZE, std::tuple_size<Tuple_t>::value );

Tuple_t T1( 99.0, 0.5);
CHECK_CLOSE( 99.0, std::get<MEAN >(T1), 1e-09);
CHECK_CLOSE( 0.5, std::get<STDDEV>(T1), 1e-09);
#if 0
//Out of Range ... caught at compile time.
//g++ error message not so helpful.
std::get<SIZE>(T1);
#endif
}
}

27 November 2011

What Did We Do Before Google and Wikipedia






















This one animation explained a lot without words.

Wish Google and Wikipedia were around when I was in school. Recently had to relearn about ellipses. Actually never learned it that well. But with Wikipedia and some references within then I figured them out well enough for my needs.

Wikipedia::Ellipses

25 November 2011

Collaborative Workspace Ideas

When conference rooms are hard to book .... this may be a warning sign that your company may not take collaborative efforts seriously. With age and more work experience, I find that the more time working in close collaboration than not produces better results. Not only do I find this for myself but observe it with many others. Unfortunately, with my aging and growing, I find myself suspicious of those who do not grow more into collaborative efforts and work alone consistently. Suspicious of what, I am unsure but perhaps suspicious something is not healthy somewhere.

Finding articles like this .... about businesses and companies who are finding great value in collaborative space gives me motivation to continue pursuing this behavior and process at work. Ideas and reasons can be found in the following article.

Inventing The Collaborative Workspace

An Effective Looking Presentation

Found this keynote by Gojko Adzic. There is no audio which it makes it hard to pickup every point he is trying to make but the format and presentation in the slides alone is worth a look. I think even without the audio you can pick out several of his points effectively. Almost no bullets and if the audio is half as good as the slides then it is well worth thinking about this type of presentation style. I like it a lot.

Death To The Testing Phase by Gojko Adzic

24 November 2011

Boost Modf Function - Integer and Fractional Parts

Have been wanting a function in C++ that would handle finding the integer of a floating point number without integer division. The boost::math::modf function finds both the integer and fractional parts.

Also I wanted to try out this source code formatting tool for blogspot. The snippet below is a unit test written in the UnitTest++ framework.


#include <UnitTest++.h>
#include <boost/math/special_functions/modf.hpp>
using namespace boost::math;

SUITE(BOOST_MATH_MODF) {
const double pi = 3.141592653589793;
TEST(modf) {
double* pIntegerPart = new double;
CHECK_CLOSE(0.141592653589793, modf( pi, pIntegerPart ), 1e-15);
CHECK_CLOSE(3.0, *pIntegerPart, 1e-15);
delete pIntegerPart;
}
}

31 October 2011

Distributed Version Control - Joel On Software

Joel on Software blogged about DVC over a year ago and included a link to a pretty nice Tutorial to Mercurial. Might want to bookmark these sites.

30 October 2011

Information Gap - Have You Got This In Your World

Mind The Information Gap

Unequally Yoked - Reminder

An individual's personality affects his ability to perform particular job assignments: One of the bullets was ..... The best programmer was put in charge of a team of beginners. Not having the patience to tutor his people, he changed their code in the middle of the night! Although his designs were wonderful, his team neither enjoyed working with him nor learned much about programming.

Page 45 in Agile Software Development - Alistair Cockburn

Motivational Quote On Permission

Once again, I find myself pointing to the keyboard and saying get back to work and do your job the way you know you need to. Stop letting them make you compromise so much. Prove to them why you are so valuable and stop marching according to their defined instruction. Be the expert at how to do your job and manage your craft!

By Kevin Schlabach

Responsive Design - Interesting

One of the things I really appreciate about Kent Beck is that he constantly is thinking about how people do things, especially in programming software. He does not seem to take for granted anything related to how we work. Always wanting to look deeper and find out why and how we as programmers do our work then he tries to articulate what he has learned for others to learn from and build on. A couple of examples of his sharing are Extreme Programming (XP) and Test Driven-Development (TDD). In recent, years Kent has been studying and researching Design.

Here is an article summarizing some of his thoughts about Responsive Design.

Definitely, food for thought. I look forward to more information on his research and results.

Version Control By Example - Cool

Appreciation of good and pedagogical examples is one of my Learning Languages. A while back I came upon this website that offers a free book on version control. Everything from VCS (SVN) to DCS like Git and Mercurial is touched on in this document.

I have a quick link to Version Control By Example when I want to share Version Control or to learn something new. I even keep a pdf version on my laptop. Have a look and see if it is useful to you.

29 March 2011

Error Prevention

Michael Feathers gave this presentation two years ago and I just got around to listening to it. This is a nice summary of a handful of techniques (like Test Driven Development and Design By Contract for example) you may have heard of but never understood what they do.

He asks in the end why don't we use them more and what do they have in common?

It is worth listening to and following his slides below the video. One slide that surprised me was a study by Caper Jones showing that the defect rate by language went down as the language became a higher level language (or more OO and Functional). Assembly and C had the highest rate of defects for the ones studied.

The Ethics Of Error Prevention - Michael Feathers