FQDN in Solaris 10

The ‘hostname’ command should return an FQDN, that is, fully qualified domain name. For example:

$ hostname
foo.your.domain.com

How do you set it up? Google search doesn’t return much of a useful information. And no, putting stuff into /etc/hosts doesn’t solve the issue. The solution is to edit /etc/nodename and put the FQDN in there and reboot.

echo foo.your.domain.com > /etc/nodename
shutdown -g0 -i6 -y

I have a hunch that reboot is unnecessary, but I haven’t figured out which service needs restarting for this change to take effect.

David Allen: Getting Things Done

David Allen gave this talk when I was in Google campus in Mountain View. It was one of the most popular tech talks, the room was really filled up.

Basic ideas of GTD are simple.  After you get them, they seem to be just common sense.  But it takes a while to figure out what we’re doing when we’re doing stuff.  And also, doing stuff becomes collecting, processing, organizing, reviewing and doing.  Myself, I’ve merely gotten to the stage of organizing.  But at least I started to collect and process.  If you’re curious what that means, sit back, relax and enjoy the talk.

Excuse me, we got a fire alarm

An engineer from Google was supposed to call me on Tuesday but he didn’t. Recruitment coordinator apologized and rescheduled the call to Friday. On the scheduled time I’ve sat by the table gripping firmly my fountain pen and staring at my mobile phone’s display. The phone kept silent. After a quarter I’ve e-mailed the coordinator telling her I’m ready and waiting. The mobile rang few minutes later and I got grilled.

Continue reading “Excuse me, we got a fire alarm”

Genetic data in PostgreSQL

People get usually famous for the things they’ve done. Well, that’s not entirely true. They usually get famous for the things they’ve done, when they were successful. You don’t get famous for attempting and being unsuccessful, now do you?

It works the same way for the scientific publications. All scientists work hard trying various things, and when they finally succeed, they publish a paper. But what happens with all those hours spend on unsuccessful attempts? Nobody seems to be proud of blowing a whole laboratory up. Or whatever didn’t work for them. This means that other people can never learn that something was unsuccessful and they’re likely to get the same, unfeasible, idea and repeat the same research. Needless to say, unsuccessfully.

Not that I’m proud of what I’ve done here, but I will at least allow other people to find this post on Google, when searching for genetic data and relational database. I’ll describe what I did, so they at least don’t do it the way I did.

Continue reading “Genetic data in PostgreSQL”

The word “should” at workplace

Blogging in English seems to be closely correlated with using English. Despite living in Ireland, I don’t use as much English as I wish to. Luckily, it is getting better. Every single coffee break with Irish people makes a difference.

There’s one word which has started to annoy me lately: “should”.

“This should go there.”
“One should do this.”
“You should avoid that.”

The word itself seems to be innocent; the annoying thing is the way it’s being used. Especially, when the information that “something should” is the only thing one has been told, without explanation of any reasons behind it or a chance to express one’s views on the matter.

Continue reading “The word “should” at workplace”

Code over the phone

Two weeks of waiting for it have built it up pretty much. When the phone finally rang, for some reason it felt surprising. No more waiting? Interview begins?

“I would like you to dictate me some code” said the engineer. He was describing tasks and asking me to write code that solves them. They were not daunting; could be easily decomposed into basic operations. Recruiters surely understand that people get nervous when being interviewed. The fact that one is being interviewed, not “just” asked to write some code, makes them make stupid mistakes all the time. Interviewers try to give simple tasks to people. It’s also interesting that the questions were not strictly theoretical, but more like “how would you…” followed by something to find out or to calculate.

Continue reading “Code over the phone”

Prisoner’s dilemma and bullying

Prisoner’s Dilemma is one of the classical games in game theory. It’s an interesting abstraction of a whole class of situations, where two parties can choose between cooperative and non-cooperative behavior. It’s a kind of game where win-win and lose-lose result can be achieved. It doesn’t apply to situations like negotiating a price, where one party’s loss is another’s gain; prisoner’s dilemma applies to situation where two parties form a team and work together.

Continue reading “Prisoner’s dilemma and bullying”

Interfaces in C++

I once had a discussion with other programmer who claimed that interfaces are bad programming practice in C++. I have ordered most well-known and respected books about C++ and looked for quotations corresponding to my question:

Is it a good programming practice to have interfaces?
Are they commonly used?

Let the masters speak.

 

Bjarne Stroustrup, The C++ Programming Language, Addison Wesley, 2006, chapter 25.3, page 769:

The simplest way of loosening the coupling between users of a class and its implementation and also between code that creates objects and code that uses such objects is to introduce an abstract class that represents the interface to a set of implementations of a common concept.

(…) To sum up, an abstract type aims to:

[1] define a single concept in a way that allows several implementations of it to coexist in a program [this is what’s needed for unit testing]
[2] provide a reasonable run-time and space efficiency through the use of virtual functions
[3] let each implementation have only minimal dependency on other classes; and
[4] be comprehensible in isolation

Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Design Patterns, Addison Wesley, 2005, chapter 1 (“Introduction”), page 18:

There are two benefits to manipulating objects solely in terms of the interface defined by abstract classes:

1. Clients remain unaware of the specific types of objects they use, as long as the objects adhere to the interface that clients expect.
2. Clients remain unaware of the classes that implement these objects. Clients only know about the abstract class(es) defining the interface.

This so greatly reduces implementation dependencies between subsystems that it leads to the following principle of reusable object-oriented design:

Program to an interface, not an implementation

Don’t declare variables to be instances of particular concrete classes. Instead, commit only to an interface defined by an abstract class. You will find this to be a common theme of the design patterns in this book.

Bruce Eckel, Thinking in C++, vol. 1, Second Edition, Prentice Hall, chapter 15 (“Polymorphism & Virtual Functions”), page 646

Abstract base classes and pure virtual functions

Often in a design, you want the base class to present only an interface for its derived classes. That is, you don’t want anyone to actually create an object of the base class, only to upcast it to so that its interface can be used. This is accomplished by making that class abstract, which happens if you give it at least one pure virtual function. (…)

(…) The only reason to establish the common interface is so it can be expressed differently for each different subtype. It creates a basic form that determines what’s in common with all of the derived classes ― nothing else.

Bruce Eckel, Thinking in C++, vol. 2, Prentice Hall, chapter 9 (“Multiple Inheritance”, “Interface Inheritance”), page 576

Interface inheritance, on the other hand, only adds member function declarations to a derived class interface and is not directly supported in C++. The usual technique to simulate interface inheritance in C++ is to derive from an interface class, which is a class that contains only declarations (no data or function bodies). These declarations will be pure virtual functions, except for the destructor. (…)

Herb Sutter, Andrei Alexandrescu, C++ Coding Standards, Addison Wesley, 2004, chapter “Class Design and Inheritance”, page 62.

36. Prefer providing abstract interfaces

Summary
Love abstract art: Abstract interfaces help you focus on getting an abstraction right without muddling it with implementation or state management details. Prefer to design hierarchies that implement abstract interfaces that model abstract concepts.

Discussion
Prefer to define and inherit from abstract interfaces. An abstract interface is an abstract class made up entirely of (pure) virtual functions and having no state (member data) and usually no member function implementations. Note that avoiding state in abstract interfaces simplifies the entire hierarchy design (see [Meyers96] for examples).

In conclusion, interfaces in C++, expressed as pure abstract classes, are recommended and commonly used.

Books ordered

I talked with my boss about problem with my co-worker. Although he says it’s not bullying, he sees that a problem exists. I can call that a progress.

I have ordered a book about bullying, as well as few other ones about C++ to have something to refer to when talking about technical things. Not to mention all the goodness of having them available every day.

The survival kit costs over £160 and consists of:

  1. Bjarne Stroustrup: The C++ Programming Language
  2. Gang of Four: Design Patterns
  3. Bruce Eckel: Thinking in C++ (Vol 1 & 2)
  4. Tim Field: Bully in sight