XSLT and your mother don’t speak C#

Being an integration specialist is never dull.

I am going to excerpt from an IM chat with one of the programmers on my team, about an SSIS package we are developing.

He:
I got:
 
A package of type Policy, labelled as ECWISE\XXX 2009-07-03 15:33:17.940, FAILED during its run from 2009-07-03 to 2009-07-03.\r\nHere is the error information: \r\n"\r\n—————————————————-Please do not reply to this automated message.

 
why the \r\n escaped in the mail?
i used the xslt to transform the xml column into a string variable, and later i use this variable as the MailMessage.Body
Me:
how do you set message body on the Send Mail task?
He:
i'm using the script task and using the smtpclient
Me:
You put in the carriage return and newline escaped in your body, what do you expect?
He
i expect a real new line
Me:
Why? That's ridiculous. what do you mean by "real"?
He:
I expect:

Here is the error information: C:\temp31 does not exist!
———————————————–
Please do not reply to this automated message.

Something like that.

Me:
FOR GOD SAKES
I KNOW WHAT A NEW LINE AND CARRIAGE RETURN LOOK LIKE
I mean: why do you use the word "real"…
What makes \r\n "real" to you?
Think about it.

Sigh.

At this point, everybody who knows me can tell this is a verbatim conversation, right?

To continue:

He:
I used the wrong word, sorry.
Me:
No, don't say "sorry". Figure it out!
Why is \r\n "real"?
Think why you said it.
they are only characters, why are they "real" ?
\r\n is real because…
He:
I thought they are carriage return in text
Me
Really? If you are writing a letter to your mother, and you write \n\r does she interpret it as lf cr?
The letter is text.
[A long pause here]
When you wrote that string in your code what did you do?
did you write x + "\r\n" + y in the script task?
He:
Almost
I'm doing it in XSLT, so concat(x, "\r\n", y)
Me:
<rofl>
That is utterly ridiculous.
Let me ask you about your mother again
Does she read \r\n as CRLF?
He:
Never.
Me:
That's right, never.

So why do *you* read it that way? Why does it seem "real" to you?

I will tell you why, but you will kick yourself… It's because you are a C# programmer .

\r\n is not "real. It is just a convention in some languages. There is nothing "real" about it.
Your mother and XSLT don't speak C#.

  

It's not XSLT's fault, or your mother's.

In XSLT he ended  up using <xsl:text> to force a line break in his text e-mail message. That's okay, but please note you can use properly encoded entity references to create a CRLF in XSLT, just like you can in C#. 

As an interesting side-note, this project was being written in SSIS 2005. SSIS 2005 script tasks don't speak C# either. So, even if we were not using XSLT to formulate the message from the XML source containing the error information, we would have to use a VB convention, not \r\n, to get the job done.

If he were sending the message body as HTML rather than text for this error notice, he'd have to use <BR/>. SSIS 2005 script and HTML are two more environments that don't understand \r\n.

There's always a way to do it. But there is nothing inherently "real" about \r\n, no matter a person who is single-language-centric might think.

I want to be fair and say that this particular programmer is usually very agile-minded as we hook differently-abled types of code to each other in an integrated application. I'm not pointing him out in particular.

We live in the Matrix

I'm trying to say: in the world we live in now, nobody can afford to be language-centric.  I'm trying to say: none of this is real. 

Use what's best for the customer and best for the product. Don't get hung up on what's cool or what a vendor recommends.  Don't get freaked out by the little places, like representation of characters, that are different in each environment. 

Just take a breath, get your bearings, you'll find the right "words" in the right dialect. If what you're trying to express is important, have a little faith and realize there's a way to do it, in any language, no matter where in the world you are. 

And be careful out there.

23 thoughts on “XSLT and your mother don’t speak C#

  1. You got that pissed off over such a simple question? You really need to relax. All it would have taken was explaining the correct method, but you had to be a dick. Was this in the documentation? If so did you recommend the person read the documentation for other pitfalls he may come across? No, you got hung up on the use of the word “real”. Yes, it may be an inaccurate and strange way of saying it, but it’s really clear what the person meant. All it took would have been a simple explanation, yet you had to be a dick.

    Don’t be an unprofessional arsehole to your colleagues. You’re the one who should worry about finding the right words in discussions.

  2. I wasn’t pissed off. But I wasn’t just going to give him a simple explanation; he’s my student, not my colleague, and I generally like to lead him to the answer rather than giving it to him — because he is a very good and promising student, and we have a long relationship and pretty good understanding of each other and how these conversations are supposed to work.

    I do need people on my team to lose “language tunnel vision”, because of the kind of work we are asked to do.

    I do find that simply giving the explanation doesn’t bring us any further on that path, because the individual makes the same mistake next time unless led to think for himself.

    And, Brad, I don’t like to work with people who think they should be “given a simple explanation” so they don’t have to think about the wider context of why the mistake is being made. I try to kick them off my team as fast as possible, so as not to make them uncomfortable, and so as to continue Getting Stuff Done.

    See http://spacefold.com/lisa/2007/09/21/The-only-acronym-that-really-counts; I’m quite serious about this, and I have to be.

  3. I don’t know why I am writing this other than your article annoyed me.

    For one trying to claim the person is single language minded due to \r\n is silly. One \r\n is not a convention of C# it is in fact a convention of C; Two Java, C#, PHP, Python all accept this information as new line and C++ and Perl interpret \n the same as C. So for a single language mind set we have 5 languages that accept this convention and two languages that almost accept this convention.

    It seems to me you are ridiculing a person over the notion that their experiences says \r\n can be a new line in programming languages just because he hasn’t interacted with other languages that say other wise. A simple example would be you throwing something at a person because they picked up a Japanese book and assume you read it right to left.

    Another statement that I find flawed is that XSLT and C# don’t talk this is not entirely true (nor entirely false). An XSLT style sheet can run scripts and last I check C# can be scripted which means XSLT can talk to C#. In fact many XSLTs that I have been writing utilize C# Script in order to manipulate the XML document being translated in ways that would be more cumbersome if I were to do it in “pure” XSLT.

    And last but not least I think the thing that annoyed me the most is the I lead a team and he is my student comment. Now I could be wrong but typically a person can only claim another as their student if one they are in an academic arena for learning and you are his professor or two the person is genuinely under you for the purpose of learning (mentoring in a company setting). Frankly if I worked with such a person who happened to be my team lead and he made the assumption that because he held such a title that I was his student and therefore he could insult my intelligence and speak to me how you transcribed the conversation I would be seeking a new place of employment after a visit to HR. Even if he is under you; he is still a colleague; a person you are suppose to be working with not talking down to.

    Anyways I will wrap this up since I have ranted long enough; this rant is not meant to be a trolling insult comment (though trolling can be claimed since I neither know you or have read your blog beyond this)

  4. J,

    I don’t tend to put labels on things in general so I’m not going to label you as a troll based on any rules, don’t worry. You’re entitled to your opinion. And you can be annoyed as you want — but I’m going to answer you seriously and at length.

    In *my* opinion, I neither insult my students nor talk down to them, and I believe that they understand this. For one thing, the people who really do talk down to them are legion, and they can tell the difference. For another, they are appreciative of the fact that I actually expect more of them and trust that they are flexible enough to do more than one thing. This, again, is in contrast to how they are usually treated.

    It’s a little scarey for some people to be held to high expectations, but it also helps them think better of themselves and their own potential.

    I’m also not going to be labelling you as “bad” or “wrong” based on your statement about scripting XSLT using C# (and yes, you can use libraries with XSLT, although in many cases C# would not be an optimal choice, there are better libraries available in other languages, for other processors). However, in an integrated app, using many different techniques and languages together, there can be real issues with delivering a bunch of DLLs and getting all the permissions and everything else to work in the customer’s environment. In this case, the XSLT is being invoked by SSIS and there are some specific pain points you don’t need to know about, but it’s better not to use a “crutch” like this when you don’t have to.

    The analogy I used (regarding my student’s mother) was deliberate, and reflects my personal relationship with that individual, which is extremely close.

    The analogy I was asking him to envision, and which he did immediately, was this: My student could write a letter to his mother and (1) require that she understand characters indicating a carriage return or (2) employ some device that automatically translates his characters into the expected carriage return in his editor or (3) use a different editor just so he can hit the keys he thinks are a “proper” carriage return or (4) learn what is the right key to hit to get a carriage return natively in this editor, which has many other advantages for this situation.

    Because he is Chinese and we “talk” on IM, my student has to choose (2) when he talks to me. I’m very grateful that he can do it, and astonished that he can do it so well. But when he writes a letter to his mother, should he have to go through the same process?

    The analogy was particularly apt, because as he well knows and often comments on, I’m female and his mother’s age <g>. (So that’s the backstory there, whether you care about it or not.)

    Perhaps you, not being either my student or somebody with whom I have a relationship, would like a different analogy more. Suppose you are negotiating for a price with a vendor. Yes, you could use a translator in the discussion, but if you *could* you would speak the same language to have the most precise and personal understanding without an intermediary or impedance mismatch between language concepts. It’s safest, most accurate, and fastest.

    Yes, there are people who insist on not learning another language, both in life and in code, for their own convenience, for expediency, out of fear of the unknown, or a hundred other reasons. I don’t know what yours are, and they’re probably perfectly valid. But they wouldn’t suit the kind of work I do and they would make life impossible for the situation that my students, none of whom are native English speakers, find themselves in as employees of an American firm. Frankly, I apologize to them *daily* for not being able to speak Chinese — and again I am grateful that they make this huge effort. And they are grateful that I don’t treat them like uncreative, low-potential robotic coders, based on language issues, which many other people have done.

    Yes, I understand that you haven’t read anything else here, and if you don’t want to, that’s fine. But I do talk about this frequently, and I do speculate on the many sides of cross-language communication quite a lot. So, for a little more insight, you might want to read this http://spacefold.com/lisa/2008/12/20/Sensitivity-versus-Consistency-in-Global-Communication.

  5. OK for some reason that URL got munged. Try again (add the HTTP part):

    spacefold.com/lisa/2008/12/20/Sensitivity-versus-Consistency-in-Global-Communication

  6. For what it is worth – I agree with J. – putting labels on things is a sure fire way to come across all manner of difficulties in life. That said I appreciate your elucidation on the subject in your reply.

  7. LOL At first, I thought that the conversation between you and your colleague may be somehow ridiculous, but it really made me laugh. But, if I were in your place, for sure I would be really frustrated or even devastated.

  8. “Just take a breath, get your bearings, you’ll find the right “words” in the right dialect. If what you’re trying to express is important, have a little faith and realize there’s a way to do it, in any language, no matter where in the world you are. ”

    This is true in more then just programming!

  9. I’m C# programmer. And I really loled when saw log of your messenger, I understand your programmer. And beleive me – my mother will do the same thing)

Leave a Reply

Your email address will not be published. Required fields are marked *