Przejdź do głównej zawartości


Wyświetlanie postów z 2014

The pitfall of teaching C++


Many years ago I read a book from Prentice-Hall about object oriented programming. I don't remember exactly when that was - either shortly before starting studies at university or at the very start of the first year there. I read about methods and messages and I analyzed diagrams on which object A was said to be passing a message to object B by the means of calling one of B's methods.

Objects then seemed to me like active, almost living entities able to communicate through this mechanism of message passing (calling each other methods). I was disillusioned to learn later that this was not true. Objects didn't have concurrent lives and the so called message passing turned out to be ordinary, synchronous function call.

(The book contained examples in C++ and Smalltalk; I ignored Smalltalk examples while reading it; I realize now that my first impression of how objects communicate through message passing was, to great extent, true for Smalltalk).

That was the first bad…

Common NonSense

I am very upset when common sense is mentioned during discussions about Scrum and generally about software development. It is usually used in sentences like: "yes, we use Scrum, but we are not erthodox about it, we just use common sense".

Why would I be so angry about it? Isn't it good that people actually use common sense to make decisions? After all, Scrum is also said to be "based on common sense".

This is the question to everyone who claims that the use of common sense is a virtue: what brought you to where you are now? Wasn't that common sense?

Wasn't that common sense that told you to separate programmers from testers?Wasn't that common sense that told you to separate analysts or architects from development team?Wasn't that common sense that helped you invent "iteration zero" in which you are excused for not delivering anything useful?Wasn't that common sense that helped you invent "hardening sprint" in which you exe…

Michael Feathers' visit

In May this year I had the pleasure of hosting Michael Feathers at Motorola Solutions in Krakow. We invited Michael to do a kind of extension, in the form of workshop and a lecture, to his great and well-known book "Working Effectively with Legacy Code".

Michael's skills are very rare as not only is he skilled in teaching the methods of dealing with legacy code, but he also feels comfortable with doing so in C++, in addition to Java and C#, which both are more pervasive among XP professionals.

It was a great experience and I think many of us will remember some of the ideas we learnt during this visit.

Agile in metaphores: angle of repose

This is my latest idea for a nice exercise that could be used during an Agile / Scrum or XP training for a development team. You are welcome to copy this idea and use it in your training, especially if you give me the credits :-)

Every loose material has a property known as the angle of repose. It is the angle that is naturally formed when a material is loosely spilled out, for example to be stored:

The task:
Give the development team an amount of loose substance such as salt of sugar and ask them to produce a measurement of the angle of repose of that substance. Then leave the room. Give them a protractor and leave the room.

Conclusions after the task is executed:
When you are back in the room, the engineers will have hopefully measured the angle in the experiment of spilling out the substance and measuring the angle more or less accurately. Explain to them that although a theoretical computation of the angle is possible, it would be extremely complex, compared to simply d…

Career advice: where do you want to be (and in what order)?

In one of Capers Jones' books (I think this was "Estimating software size") I came across a categorization of software projects that looked interesting to me. It put kinds of software projects in relation with the ability to perform the same tasks without a computer. Although I'm not able to cite it, it was something like this:
all tasks can be performed without a software system; computers are used only to make it easier or fasterbookkeeping in a small company could be an example tasks can theoretically be performed without a software system, but they would require so much time and involve so much risk of human error, that it would be extremely impractical or close to impossible to perform them without using computersfinding items in an extremely large collection (e.g. a huge library) could be an examplesome banking operations could be even better exampletasks cannot be performed by a human by their very nature; there must be a software system in place in order to pe…

You need to know: tail end recursion

A few years ago I did a small quasi-prepared-Kata exercise to demonstrate differences between programming in (and thinking in) different programming languages. I chose a simple state machine as an example and implemented it in Common Lisp, Java and C.

Having programmed in each of these languages at some point in my life, I deliberatly used approach typical for each of the languages. I even exaggerated a little to emphasize the characteristics of languages and how they influence our thinking. For example, I used a little more than needed classes and objects in Java and avoided recursion, whereas in Common Lisp, the state machine was transitioning from one state to another by a recursive tail call.

One of the observers questioned the Lisp implementation saying that it would quickly result in stack overflow. Although I intuitively felt that was not true, I was not able to explain why. Right after that session, I searched for information about recursion in functional languages and I learn…

Beware of theoretical problems

Anybody who was a change agent or acted as one knows this too well. You meet a development team of 15+ engineers and do an introductory talk on Scrum. Even before you are one third through the talk, there is a question or an interruption from the audience - similar to one of the following examples:
this is all very interesting, but how it [Scrum] would deal with a situation when half of the team quits their job on one day?this may work in an experienced team, but imagine that you have a team where there is just one experienced developer and all others are fresh graduatesI don't understand why you are against my idea of recording the stand-up meetings; sometimes the amount of input from the team may be too large for the Scrum Master to remember If you hear that (and it could be on any meeting you talk about change, not necessarily about Scrum), don't engage into discussion.They are all extremely theoretical questions that will NEVER happen in real life. What's more, whateve…

The (unpleasant) truth about concurrency

As Robert C. Martin writes in his wonderful book "Clean code", concurrency is hard. Concurrency is indeed so hard that most software developers do not know how to deal with it properly. Please don't feel offended. I myself thought I was quite good in writing concurrent programs at my first job, around the year 2000. But now I recognize I was rather lame about it back then and I'm only very very slightly better in understanding it. Honestly, the part I am really somwhat better at is the understanding of how many of concurrency aspects I still don't understand.

If you believe I am talking nonsense, let me just ask a simple question: have you  every read and understood this fundamental work about concurrent systems by C.A.R. Hoare? I think most programmers have never read it.

Is it so bad and should we all go back to a classroom and study CSP deeply? Not necessarily. I believe that most programmers (here I think of programming as a profession) do not really need pro…

Code Kata: Crazy letter delivery

Imagine you live in a crazy town inhabited entirely by mathematicians. Each day a postman delivers some letters to the citizens. There are no street names in town, just house numbers. Because the traditional delivery seemed boring to the mathematicians, they invented a kind of game and talked the postman into playing it: the postman changes the original numer of house on a letter to an alternate number (read below how) and delivers the letter to the alternate house. The mathematician that lives in that house knows both the alternate and original house number from the postman. He indulges in the task of converting the original number to the alternate and only when he knows the proper conversion does he deliver the letter to the proper receiver. Example:

Original house number: 139.
Alternate house number: 126

Conversion: 139 - (1 + 3 + 9) = 126; original number minus the sum of its digits.

Another example:

Original house number: 222
Alternate house number: 8

Conversion: 2 * 2 * 2 = 8; d…

Agile in metaphores: cars cleaning

Last Saturday I decided to clean our cars, both mine and my wife's. They really needed cleaning. A few days before I bought a nice, industry-grade vacuum cleaner, better suited for this job than the one we use at home. Basic set of tasks that I have to work through to clean a car is this:

vacuum the cartake out foot pads and clean them with water and a detergentclean the inner sides of windowsclean the cockpit with a special detergent so that it looks glossy The weather on that day was not bad, though pretty windy and when I was about half way through the job, it looked like it was going to rain.
What is the best way to complete as much cleaning as possible, if there is the risk of rain? Should I vacuum both cars first, because I already have the vacuum cleaner running? But would anybody consider a car that has been vacuumed, but still has lots of dust on the cockpit clean? I wouldn't and, what's more, my wife certainly wouldn't either. What is the best way then, again,…

An opinion on code review

Code review is often seen as a way to enhance code quality. My personal views on code review are quite different. I will try to summarize them in a short list. You are welcome to disagree.

code review frees the author from the responsibility for the code; "I don't have to care so much, since others are looking at it as well"code review fits very very poorly into Scrum framework; it delays the completion of tasks and backlog items and produces an inclination in teams to aggregate the reviews into a several-days-long "phase" placed at the end of an iteration (making it effectively a wateration)code reviews are much easier as a process to learn than TDD or SOLID, so developers do them gladly and receive in exchange a feeling of accomplishment (unfortunately):"I give my code to others to review, because I care for code quality""I review the code of others, because they value me as a knowledgeable person"code reviews drag the feedback to the very …

Code Kata: toy fleet management

Background: there is an infinite grid with one point selected as a fleet management centre. There is a number (> 1) of cars that move through the grid, one step at a time, only in up, down, left and right directions. The cars periodically send their position on the grid to the management centre.

The task: we are to write a program that accepts coordinates sent by the cars and then can tell us the current total distance travelled by a car.

Points to consider: we assume that the coordinates are send periodically, regardless of the car's movement. Thus, a car may send various series of coordinates that our program must be able to interpret. Tip: the calculated total distance will be an approximation, not an exact value.

Additional functions (to be done as a next step, do not bring it outright into the design): if a car travels away from the management centre farther than N units, the program will signal that fact. Just use any method you wish to signal this, but remember that it shou…