Forward declaring std::string in C++

One type you can't forward declare in C++ is std::string
class string; // Computer says no
This does not say a lot but what it does say is that string is a class and unfortunately it's not - it's a typedef of basic_string<...>

If I compile a file containing just the line
#include <string>
then g++'s -H flag tells me that pulls in over 100 other header files! Avoiding those #includes might make an appreciable difference to build times in some C++ codebases. You can fake an std::string forward declaration by using a type wrapper. For example:
#ifndef EG_HPP
#define EG_HPP

class fwd_string; // instead of #include <string>

void eg(const fwd_string &); 
// instead of
// void eg(const std::string &);

#endif
Where fwd_string.hpp looks like this:
#ifndef FWD_STRING_HPP
#define FWD_STRING_HPP

#include <string>

class fwd_string
{
public:
    fwd_string();
    fwd_string(const char *);
    fwd_string(const std::string &);
    std::string string;
    ...
};

#endif
You can also use this "type-tunneling" technique to forward declare enums in C. I've never seen this used in anger in an actual codebase. It's just an idea. Caveat emptor.


Accu conference charity book stall

Once again I'm going to give away a load of books at this years ACCU conference. As before I'll choose a charity and ask everyone who takes a book to make a voluntary donation. I've already collected two boxfulls. If you're coming to the conference please consider bringing along some books and contributing them to the stall.

The logic of failure

is an excellent book by Dietrich Dorner (isbn 0-201-47948-6). As usual I'm going to quote from a few pages:
The English psychologist James T. Reason thinks that this kind of error is the result of a general propensity for "similarity matching," that is a tendency to respond to similarities more than differences.
The effectiveness of a measure almost always depends on the context within which the measure is pursued.
A rule such as … is too general to be useful, and measures based on it will be wrong much of the time.
We often overlook time configurations and treat successive steps in a temporal development as individual events.
Go make yourself a plan,
And be a shining light.
Then make yourself a second plan,
For neither will come right.
People look for and find ways to avoid confronting the negative consequences of their actions.
If we never look at the consequences of our behaviour, we can always maintain the illusion of our competence.
The results also support the idea that activity may foster an illusion of competence.
Other investigators report a similar gap between verbal intelligence and performance intelligence and distinguish between "explicit" and "implicit" knowledge.
Mistakes are essential to cognition.
We humans are creatures of the present.
It is impossible to do just one thing alone. Any action in one area affects others.

On becoming a person

is an excellent book by Carl Rogers (isbn 978-1-84529-057-3). As usual I'm going to quote from a few pages:
The first stage… There is an unwillingness to communicate self. Communication is only about externals… He is structure-bound in his manner of experiencing. That is, he reacts "to the situation of now by finding it to be like a past experience and then reacting to that past, feeling it".
The concept of "cure" is entirely inappropriate, since in most of these disorders we are dealing with learned behaviour, not with a disease.
Thus scientific methodology is seen for what it truly is - a way of preventing me from deceiving myself...
It is a type of learning which cannot be taught. The essence of it is the aspect of self-discovery.
Involved in this process of becoming himself is a profound experience of personal choice. He realises that he can choose to continue to hide behind a facade, or that he can take the risks involved in being himself.
He is more open to his feelings of fear and discouragement and pain. He is more open to his feelings of courage and tenderness, and awe.
Such living in the moment mean an absence of rigidity, of tight organisation, of the imposition of structure on experience. It means instead a maximum of adaptability, a discovery of structure in experience, a flowing, changing organisation of self and personality.
The good life is a process, not a state of being. It is a direction, not a destination.
He has changed, but what seems most significant, he has become an integrated process of changingness.
The process involves a shift from incongruence to congruence.
The incongruence between experience and awareness is vividly experienced as it disappears into congruence.

Freedom from command and control

is an excellent book by John Seddon (isbn 978-0-9546183-0-8). As usual I'm going to quote from a few pages:
You cannot 'motivate' someone… You can provide conditions in which employees are more likely to be motivated or demotivated, but it is a conceit to believe that managers can motivate people.
There are two jobs: job one to serve the customer and job two to improve the work.
If design is separated from process, work becomes a prescription.
Deming often asserted that knowledge should not be thought of as experience.
The value of knowledge is its use not its collection.
Leadership , in my view, is about influencing.
Some followers of Deming are unhappy with this adaptation [Check,Plan,Do] of his cycle. I believe Deming wrote about 'plan-do-check-act' on the assumption that managers who started at 'plan' were already systems thinkers. He saw 'plan' as 'have an idea based on what you "know"'; 'do' was followed by 'check' to see if the idea was right; finally 'act' meant 'put it in the line'. His model was built on manufacturing, where changes were tested off-line.
Without doubt the most important system condition affecting performance is measurement. It goes hand in hand with command-and-control hierarchical structure.
The first-level manager works with people on the work, not on the people.
Consultants who see culture change as something distinct from the work and, as a corollary, something that can be the subject of an intervention, miss the point. When you change the way work is designed and managed, and make those who do the work the central part of the intervention, the culture changes dramatically as a consequence.

The psychology of computer programming

is an excellent book by Jerry Weinberg. As usual I'm going to quote from a few pages:
I know I've snippeted this before, but I've read it again and I don't see why a really good book shouldn't get repeat snippets. It was published in 1971. If there's an earlier software-related book still in print I don't know what it is.
We must deal with one other problem, which is important because of a seldom questioned view of programming - a view which this book will spend a great deal of time questioning. That view is that programming is an individual activity.
In the end though, it's their method of learning that distinguishes teams from groups… team members always have a common goal, regardless of the product - the goal of helping each other learn to perform better.
If egoless programming is used, everyone in the group will have the opportunity to examine the work of everyone else at some time, thereby tending to prevent the establishment of strong hierarchy.
The greatest challenge, then, is not creative thinking, but creative communicating: representing our thoughts in a way that other persons - each with a unique style - can understand.
The programming business relies more than any other on unending learning.

The XP question

What can you tell me about XP?

That's the question.

Take a moment to think about it.

What thoughts immediately pop into your head?

What words would you use if I was an alien and you were telling me about XP?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Pair Programming is a common first choice. Also common are Testing (TDD), Refactoring, Collective Ownership. These are all fine things but notice that they're all directly related to the code. Programming the code in pairs, testing the code, refactoring the code, ownership of the code.

When I'm coaching or consulting I often ask the XP question. The overwhelmingly most common replies relate to the technical practices and not to the underlying values. I think that's a shame. I feel my understanding of XP's technical practices became much deeper when I thought about them in the light of XP's values.

Can you name the Four XP Values?
That's what the question is really about.
Can you name one XP Value?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
If you did name a value what was it?
Was it Simplicity or Feedback, the values with a technical aspect?
Or was it Courage or Communication, the values with a stronger social focus?

Reading chapter 7 of Kent's book it's clear to me that the four values are core to XP. Kent writes (my emphasis)...

We need some criteria for telling us if we're going in the right direction... Short term individual goals often conflict with long-term social goals. Societies have learned to deal with this problem by developing shared sets of values... Without these values, humans tend to revert back to their own short-term best interest.


The four values - communication, simplicity, feedback, and courage... tell us how software development should feel.


How you should feel!
Do those words surprise you?
How do you feel about your answer to the XP question?

Bordeaux kanban 1's game

Philippe Launay is an Agile team lead and Coach for AGFA in France.

Phillipe recently organized a Kanban 1's game in Bordeaux after he and Fabrice Aimetti translated the slide-deck into French.

Way to go Phillipe.



Phillipe gave me some great feedback
  • printed handouts of the rules on each table.
  • instead of story-cards with numbers on why not have story-card with dots on. Instead of a 4 have 4 dots.
He writes:

We really had some fun and we learned a lot. The feedback is very very positive... All attendees, the two observers, and the two organizers are more than satisfied with the result. So again thank you to for providing the game.

It's my pleasure Phillipe. And in case any else is wondering, please feel free to translate the Kanban 1's Game slide-deck if you want to. Just send me an email and I'll collect links in this blog.

Understanding comics - the invisible art

is an excellent book by Scott McCloud (isbn 0-06-097625-X). As usual I'm going to quote from a few pages:
Do you hear what I'm saying? If you do, have your ears checked, because no one said a word.
For now I'm going to examine cartooning as a form of amplification through simplification.
Since cartoons already exists as concepts for the reader, they tend to flow easily through the conceptual territory between panels. Ideas flowing into one another seamlessly.
These first symbols - cartoons really - gradually evolved away from any resemblance to their subject, toward the highly abstracted forms of modern languages… and eventually to our totally abstract sound-based system.
The longer any form of art or communication exists, the more symbols it accumulates.
In this chapter, we've dealt with the invisible worlds of senses and emotions, but in fact all aspects of comics show it to be an art of the invisible.
The more an artist devotes him/herself to either of these two focal points (form and idea/purpose), the more dramatic the change if he/she decides to switch.
Symbols are the stuff of which gods are made.
All media of communication are a by-product of our sad inability to communicate directly from mind to mind. Sad, of course, because nearly all problems in human history stem from that inability.
The wall of ignorance that prevents so many human beings from seeing each other clearly can only be breached by communication. And communication is only effective when we understand the forms that communication can take.

The C Standard

is an excellent book (isbn 0-470-84573-2). As usual I'm going to quote from a few pages:
Except when it is the operand of the sizeof operator, the unary & operator, the ++ operator, the -- operator, or the left operand of the . operator or an assignment operator an value that does not have an array type is converted to the value stored in the designated object (and is no longer an lvalue). (6.3.2.1 Lvalues, arrays, and function designators)
object: region of data storage in the execution environment, the contents of which can represent values. (3.14 Terms, definitions, and symbols)
Between the previous and next sequence points an object shall have its stored value modified at most once by the evaluation of an expression. (6.5 Expressions)
At certain specified sequence points, al side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place. (5.1.2.3 Program execution)
If a "shall" or "shall not" requirement that appears outside of a constraint is violated, the behaviour is undefined. (4. Conformance)
A conforming program is one that is acceptable to a conforming implementation. (4. Conformance)
implementation: particular set of software, running in a particular translation environment under particular control options, that performs translation of programs for, and supports execution of functions in, a particular execution environment. (3.12 Terms, definitions, and symbols)
A full expression is an expression that is not part of another expression or declarator… The end of a full expression is a sequence point. (6.8 Statements and blocks)

The Pragmatic Programmer

is an excellent book by Andrew Hunt and Dave Thomas (isbn 0-201-61622-X). As usual I'm going to quote from a few pages:
A very simple but particularly effective technique for finding the cause of a problem is simply to explain it to someone else.
Fred doesn't know why the code is failing because he didn't know why it worked in the first place.
Chips are designed to be tested.
Design to Test.
Abstractions live longer than details.
Some things are better done than described.
Don't give in to the false authority of a method.
Test Early. Test Often. Test Automatically.
Organize around functionality, not job functions.
When woodworkers begin a project, they cut the longest pieces first, then cut the smaller pieces out of the remaining wood.
The Law of Demeter for functions states that any method of an object should call only methods belonging to: itself, any parameters that were passed in to the method, any objects it creates, and directly held component objects.

courage

I've been thinking about courage. Scott Peck writes:

The absence of fear is not courage; the absence of fear is some kind of brain damage. Courage is the capacity to go ahead in spite of fear, or in spite of pain.


Courage is one of the 4 values of eXtreme Programming. I was struck by how every mention of courage in Kent's book, and also during a short googling session, has a technical rather than a social slant to it:

  • Communication supports courage because it opens the possibility for more high-risk, high-reward experiments...
  • Simplicity supports courage because you can afford to be much more courageous with a simple system...
  • Concrete feedback supports courage because you feel much safer trying radical surgery on the code if you can push a button and see tests turn green at the end (or not, in which case you can throw the code away).

It's sometimes said that Scrum is very good at surfacing problems, making problems visible, and that if we don't deal with these problems it's not Scrum that's failed it's us. Moments of social tension are exactly like that. Tension surfaces, is felt, but isn't held and openly dealt with, and so slowly sinks out of view.

Problems in software are always a mixture of the technical and the social. I think many developers find it relatively easy to be technically courageous but not so easy to be socially courageous. Being technically courageous but not socially courageous is solving the symptoms but not the root-causes. In every case, if you fail to deal with the underlying causes you create a bad self-fulfilling dynamic.

Courage relates to trust. Holding the issue and not letting it sink away feels risky. But if you never take any risks you're not likely to create any trust. Acting when you feel a little scared is what courage is.

Courage relates to congruence. Congruence is about alignment. If you feel X, it's ok to say that you feel X, to sound like you feel X, and to look like you feel X.

Moments of fear can be precious moments. They can become moments of courage.

My Kanban 1s Game

Update! I've now created a Kanban Board Game around this idea.

Here's the latest slide-deck for my kanban 1s game. Based on feedback from several recent sessions I've changed two features:
  • Backlog It now costs 1 unit of work to create a backlog item. Also a worker on any table can create a backlog item at any time.
  • Bugs There's now a much simpler way of simulating bugs - simply lose all the current work on the story-card.
Jon Jagger's Kanban 1s Game

extreme Programming explained

is an excellent book by Kent Beck (isbn 0-201-61641-6). As usual I'm going to quote from a few pages:
Without courage, XP just simply doesn't work.
Communication supports courage because it opens the possibility for more high-risk, high-reward experiments… Simplicity supports courage because you can afford to be much more courageous with a simple system… Concrete feedback supports courage because you feel much safer trying radical surgery on the code if you can push a button and see tests turn green at the end (or not, in which case you can throw the code away).
Pair programming works for XP because it encourages communication… In my experience, pair programming is more productive than dividing the work between two programmers and then integrating the results.
If people program solo they are more likely to make mistakes, more likely to overdesign, and more likely to blow off the other practises, particularly under pressure.
There are times when problems simply can't be solved by the emergent brilliance of the team, encouraged by a loving and watchful manager. At times like this, the XP manager must be comfortable stepping in, making decisions - even unpopular ones - and seeing the consequences through to the end.
XP is a communal software development discipline.
The best environment is one of mutual trust.
Under stress, people revert to earlier behaviour, no matter how badly that behaviour has worked in the past.
Today's design should be done today and tomorrow's design should be done tomorrow.
Nerds aren't generally good at talking.
When you say one thing and do another, bad things happen. This book [Gerald Weinberg, Quality Software Management: Volume 4(sic), Congruent Action] talks about how to be congruent yourself, how to recognise incongruence in others, and what to do about it.

The Trusted Advisor

is an excellent book by David Maister, Charles Green, and Robert Galford (isbn 978-0-7432-0776-8). As usual I'm going to quote from a few pages:
Trust frees us from the need to spend time on inconsequential projects or tedious procedural issues.
You must be willing to give in order to get.
Creating trust entails taking some personal risks. It is the essence of trust. If you're not a little scared on occasion, then you're not taking a risk. And if you're not taking a risk, you're not likely to create trust.
Trust is personal… "institutional trust" is an oxymoron.
It is not enough for a professional to be right: An advisor's job is to be helpful.
…they are, above all, looking for someone who will provide reassurance, calm their fears, and inspire confidence.
Excellence in advice giving requires not only the right attitude, but also a careful attention to language.
"I was amazed at how many fools I ran into until I noticed the common denominator in all those interactions: me."
Trust = (Credibility + Reliability + Intimacy) / Self Orientation
Reliability in this largely rational sense is the repeated experience of links between promises and action… Reliability in this emotional sense is the repeated experience of expectations fulfilled.
The most common failure in building trust is the lack of intimacy… Greater intimacy means that fewer subjects are barred from discussion.
The purpose of listening in building trust is to earn the right to engage in a mutual exploration of ideas.
Effective trusted advisors are very good listeners.

DaVinci Decoded

is an excellent book by Michael Gelb (isbn 0-385-33861-9). As usual I'm going to quote from a few pages:
Ritual is the husk of true faith [Lao Tzu]
Poor is the man who desires many things. Neither promise yourself things nor do things if you see that when deprived of them they will cause you material suffering. [Leonardo]
He prided himself on being a uomo sense letter (man without academic training) and a disciepolo della sperienza (disciple of experience).
I shall continue. I never tire of being useful. Obstacles do not bend me. Every obstacle is destroyed through rigour. [Leonardo]
You can have neither greater nor lesser dominion than you have over yourself. [Leonardo]
The average person "looks without seeing, listens without hearing, touches without feeling, eats without tasting, moves without physical awareness, inhales without awareness of odour or fragrance, and talks without thinking." [Leonardo]
Mindfulness is complete attention in the now, rather than worrying about the past or investing in expectations about the future.
The Jewish tradition, for example, teaches that "the key to everything is the way you start."
Fill the space with objects and images that inspire you to remember your connection to something greater than your own ego.
In his anatomical studies, as in everything else he did, Leonardo was always striving for the most all-encompassing type of understanding as well as the most detailed.
Leonardo himself was known to be even-tempered and optimistic, even when life was hard. He was also meticulous in his daily habits of eating, exercising, and resting.
Modern research confirms ambidexterity promotes balance and brain development. Not surprisingly, Leonardo was ambidextrous.

Wisdom of the idiots

is an excellent book by Idries Shah (isbn 0-86304-046-2). As usual I'm going to quote from a few pages:
Different modes of behaviour on the part of the wise are to be regarded as due to differences in individuality, not of quality.
Only stupid people and pedants imagine that their duty is to instruct everyone, when the motive of the people is generally not to seek instruction, but to attract attention.
Words alone do not communicate: there must be something prepared, of which the words are a hint.
When you have found yourself you can have knowledge. Until then you can only have opinions. Opinions are based on habit and what you conceive to be convenient to you. The study of the Way requires self-encounter along the way.
…people spend most of their time either jumping to conclusions or else taking no notice at all of facts.
Perception without wisdom is worse than nothing at all.
How much of my life is being wasted while I wait for someone to tell me what to do or something to happen which will change my condition and frame of mind?
'Alas', said the Sufi, 'there was only one thing wrong with your attempt to apply Sufi methods. You were not a Sufi.'
The assumption that anyone of worth can explain himself fully and lucidly in the time allotted him by those who want to learn what he knows - is either a joke or a stupidity.
It is learnt by means of practice. If you cannot practice it, you cannot learn it. If you cannot learn it, you do not really want to learn it inwardly at all.
A crooked plan will benefit only the crooked, a wise one only the wise.

Wooden on Leadership

is an excellent book by John Wooden and Steve Jamison (isbn 978-0-07-145339-4). As usual I'm going to quote from a few pages:
Effort is the ultimate measure of your success.
I believe leadership itself is largely learned.
In the end, the choice you make makes you.
Genius is nothing but a greater aptitude for patience. [Benjamin Franklin]
Sometimes during practice he would have the guards switch positions with the forwards - have us do the other guy's job. He wanted everybody to understand the requirements of the players in the other position… I was so impressed by the control of his practice. [Gail Goodrich]
There are no big things, only an accumulation of many little things.
What happened is a good lesson in how we can limit ourselves and our organisations without even knowing it - how we can say "no" when we should be asking "how?"
Success breeds satisfaction; satisfaction breeds failure.
Lots of repetition. You can't believe the repetition. [Gary Cunningham]
Things turn out best for those who make the best of how things turn out.
I rarely assigned one player to a basket. Basketball is a team sport, and I felt it was unwise to allow players to practice by themselves. Always I wanted them to be interacting with their teammates.
How you practice is how you "play"… It's only natural for those under your leadership - perhaps even you - to focus on the end result rather than learning and doing what it takes to get there. I attempted to solve this particular problem at UCLA by occasionally removing the siren song; specifically, I made them practice and play basketball without the ball.
A good leader always seeks improvement - always.

Measuring and managing performance in organizations

is an excellent book by Robert Austin (isbn 978-0-932633-36-1). As usual I'm going to quote from a few pages:
When outcomes are revealed so slowly, learning is difficult.
The difficulty of verifying quality is heightened when production activity is largely mental, hence not directly observable, as in many professional settings such as software development.
Empirical work on human motivation (Frey, 1993; Deci and Ryan, 1985, McGraw, 1978) has shown that external motivators often crowd out internal motivation.
Alfie Kohn (1993) observes that measurement connotes comparability which, in turn, fosters competition and even unfriendly feeling between workers, thereby undermining any sense of common purpose.
You manage things, and you lead people. You control things, and you release people. [Ed Tilford]
There is reason to question whether the two intended uses of measurement [motivation and information] can be decoupled in real settings.
W. Edwards Deming, often considered the father of both the Japanese and the American quality movements, has declared performance measurement "the most powerful inhibitor to quality and productivity in the Western world".
Dysfunction's defining characteristic is that the actions leading to it fulfil the letter but not the spirit of stated intentions.
Measured performance trends upward; true performance declines sharply. In this way, the measurement system becomes dysfunctional.
…conclude that no measurement system can be designed to preclude dysfunctional behaviours.
…motivational measurement is, by definition, intended to cause reactions in the people being measured, while informational measurement should be careful not to change the actions of the people being measured.
Russell Ackoff draws a careful distinction between organisms and organisations (concisely paraphrased here by Mason and Swanson): … organisms are comprised of organs that only serve the purpose of the system, whereas organisations are comprised of purposeful subsystems with their own goals.
The quality of a product or service is usually much harder and costlier to measure than its quantity.
If there is a single message that comes from this book, it is that trust, honesty, and good intention are more efficient in many social contexts than verification, guile, and self-interest.
The inclination to interpret control narrowly is due to what might be called a standardisation reflex.
Engineering control does not ordinarily assume self-interested behaviour on the part of components of the control system.
Almost all experts strongly agreed that the primary reason to measure in software development was informational rather than motivational.