The Mythical Man-Month
I am currently reading The Mythical Man-Month from Fred Brooks. This book consists of essays on software engineer. These essays draw from his experience as project manager for the IBM System/360 computer family and then OS/360, its massive software system.
I suggest read this book if you take part in any software project. I believe you will find parts similar to your own projects and learn from Brooks' experience.
For example, when a task cannot be partitioned because of sequential constraints, the application of more effort has no effect on the schedule. However, project managers sometimes try to shorten the schedule by assigning men. The following phase from the book perfectly explains the situation.

The bearing of a child takes nine months, no matter how many women are assigned.
Endianness
I found a paper about endianness while I was looking on Intel's developer documentations. I have been wondering what kind of advantages can be gained to store the data in little endian or big endian format. There are some explained advantages and disadvantages in that document. However, I haven't been enough convinced with these explanations. I think there are many others related to CPU and hardware design.
Anyway, that document well describes the endianness and the portability issues. It should be read if you have got some questions in mind.
I implemented a function which checks the endiannes of the CPU on run time. It is possible to decide the architecture by comparing one byte. However, I like to perform strict check on multi-byte data.
Here is the link of the Intel's document.
union {
char array[sizeof(int)];
int intVal;
} testUnion;
int main()
{
int i, bigEndVal = 0, littleEndVal = 0;
char c = 'a';
for(i = 0; i < sizeof(int); i++) {
testUnion.array[i] = c;
bigEndVal = (bigEndVal << 8) | c;
littleEndVal = littleEndVal | (c << 8 * i);
c++;
}
if (testUnion.intVal == bigEndVal)
printf("Big Endian\n");
else if (testUnion.intVal == littleEndVal)
printf("Little Endian\n");
else
printf("Unknown\n");
return 0;
}
C++, Functions That Return Two Values
I am going to explain the class pair that is provided to treat two values as one. The class pair is used several times in STL. The container classes map and multimap use the class pair to handle the key/value pairs. The other usage of the pair class is functions that return two values. I choose the title as 'Functions That Return Two Value' instead of 'The class pair' because it sounds much more attractive since developers used to hear functions can return one value.
The pair structure is defined in <utility> as follows;
template<class T1, class T2>
struct pair {
typedef T1 first_type;
typedef T2 second_type;
T1 fist;
T2 second;
pair() : first(T1()), second(T2()) {}
pair(const T1& val1, const T2& val2) : first(val1), second(val2) {}
template<class Other1, class Other2>
pair(const pair<Other1, Other2>& p) : first(p.first), second(p.second) {}
};
}
The pair is defined as struct. Therefore, accessing the members (first and second) is possible. The definition is short and straightforward. However, the template version of the copy constructor may seen confusing. The template copy constructor is called whenever implicit conversion is needed. There are many good books about C++, STL and Templates, two of them are as follows;
1. C++ Primer, by Stanley B. Lippman, Josée LaJoie, Barbara E. Moo
2. The C++ Standard Library: A Tutorial and Reference, by Nicolai M. Josuttis
The make_pair() template function makes the life easier by creating the pair without explicit types.
template<class T1, class T2>
make_pair(const T1& val1, const T2& val2)
{
return pair<T1, T2>(val1, val2);
}
}
In conclusion, here is an example of function that returns two values, including use of the pair class and make_pair function.
#include <iostream>
#include <utility>
using namespace std;
const double PI = 3.14;
pair<double, double> areaAndCircumferenceOfCircle(double r)
{
return make_pair((PI * r * r), (2 * PI * r));
}
int main(int argc, char *argv[])
{
pair<double, double> circle;
circle = areaAndCircumferenceOfCircle(5);
cout << "Area: " << circle.first << endl;
cout << "Circumference: " << circle.second << endl;
return 0;
}
Graphical Editor – Programming Challenges
In my previous post, I wrote about the website includes programming problems. I aimed to emphasize the importance of careful problem text reading.
After that post, I should be more careful. However, I spent last 3 hours to find out what was wrong with my solution. I had checked every line again and again. I even implemented same functionality in different ways. I had submitted 30 times and received the 'wrong answer' every time.
I found the problem only ten minutes ago (BTW, time is about 2.25 am). Here is the problem that took 3 hours...
The problem text says "Create a new M x N image with all pixels initially colored white (O)". Yes, color white is capital letter O, not 0 (Zero). My last 3 hours and 30 submits included 0 (zero) instead O.
Programming Challenges
I discovered a new website while I was reading 'The Algorithm Design Manual' from Steve Skiena (I have read only one chapter so far. However, I can say it is worth to read all).
On that website, You can find hundreds of problems that are like the ones used during programming contests. You can submit your solutions in C/C++, Java and Pascal.
This is really interesting opportunity to the developers who haven't got many challenging tasks at work and to who like to solve puzzles. I am some more lucky, my company develops real time billing systems on Unix/Linux. Therefore, I do much more interesting than reading/writing database. However, even in my company, the most challenging parts are already developed and they are put to the libraries. Therefore, I don't face challenging problems every day. I mostly don't do more than calling library functions in order or fixing cheesy bugs. Fortunately there are times that I am asked to develop tough projects.
I have solved only two of the problems so far. I received 'wrong answer' for one of them due to the '\n' character at the end of the file. The code printing one less '\n' character is accepted. The results are checked by a software and every byte of the output is important. If you receive 'wrong answer' as a result and you are sure about your solution, you should read the problem text carefully for the output format.