They say you learn something new every day.

Archive for January, 2012

Asps in Nets (31/01/2012)

I’m struggling a little bit with .Net. It’s a little bit different from languages I’ve used before, and I’m worried that I’m falling back on what I know a bit – doing things in less efficient ways because that’s how I’ve always done them.

This is a bit of a problem really. What’s always inspired me to learn something new is the drive to get something to work. If I can get it to work, albeit in the “wrong” way, then I tend to stop.

Now, on the one hand, this may result in code that’s a little tatty, but on the other, the user doesn’t care. What they want is the functionality, and if it looks nice, works and is easy to use, they’re happy.

If it’s written in nice OOP code, or cobbled together from bits and bobs then they’re happy.

Now, I’m not advocating crappy code in any way. Oh God no, I’ve had enough problems with my own crappy code without writing more. But what I’ve realised is that more important than the neatness of the code is the richness of the application.

It’s much more important to get the functionality in there, make it work and tweak from there.

I realised this when putting together this function to return the group membership for a particular computer. It’s a little cobbled together, but it works. And now that I’ve got the functionality I can start tweaking it to make it work better and faster, and start identifying faults and fixing them.

I think people need to remember. We don’t code to write code. We code to solve a problem. 

FUNCTION GetMembers(Asset AS String) As String

DIM members

DIM objADAM As DirectoryEntry = New DirectoryEntry() 

objADAM.RefreshCache()

DIM objSearchADAM As DirectorySearcher = New DirectorySearcher(objADAM)

objSearchADAM.Filter = “(&(cn=” & Asset & “))”

objSearchADAM.SearchScope = SearchScope.Subtree

DIM objSearchResults As SearchResultCollection = objSearchADAM.FindAll()

If objSearchResults.Count 0 Then

Dim objResult As SearchResult

For Each objResult In objSearchResults

DIM memberof AS Object = objResult.GetDirectoryEntry.properties(“memberof”).value

IF NOT IsNothing(memberof) THEN

DIM collectiontotal= objResult.GetDirectoryEntry().Properties(“memberOf”).Count -1

Dim member,adgroup, i

For i = 0 To collectiontotal

member = objResult.GetDirectoryEntry().Properties(“memberOf”)(i).ToString(

members = members & member
Next

ELSE

members = “There are no groups on this computer.”

END IF

Next objResult

Else

members = “Computer could not be found.”

End If

GetMembers = members

END FUNCTION 

At Least the Directories are Active (30/01/2012)

I may be struggling with my house situation, but life trundles onto.

I’ve been building my web application at work, which I’ve really been enjoying doing. It’s great to be totally in control of a project and just fix it however you like.

However, I’m writing it in ASP.Net, which is a language I don’t really know that well.

Today I a discovery. If the DNS is set up correctly, you can get the asset number of the machine that’s connecting to the webpage.

Assetnumber = System.Net.Dns.GetHostEntry(Request.ServerVariables(“REMOTE_ADDR”)).HostName

This is brilliant. It’s something I didn’t think you could do. But the header data contains the IP address, and if you do a Reverse DNS lookup, you can get the asset number.

Of course, it’s the full domain name, so you have to trim a bit off the end, but that’s easy:

Assetnumber = UCASE(LEFT(Assetnumber,INSTR(Assetnumber,”.”)-1))

Once you can do this, the possibilities are quite exciting. It means you know who the user is, and what computer they’re on, so you can really tailor the results back to them.

Arrogrance (29/01/2012)

I suddenly realised today that I’m quite arrogant.

Not in the sense that I go around saying “I’m the best”. But I do tend to think it. Which is strange considering how much time I spend thinking about the gaps in my knowledge (this is called “Less Stupid Than Yesterday” for example).

The problem is, I think, that deep down, I think I’m cleverer than a lot of people I meet. And that’s wrong. I know it’s wrong, and I’ve even discussed with myself how opinions about other people are wrong, and how you can’t really know how clever someone is until you really know them.

I need to remember this a bit more, as this is a bad trait.

Bad Days (28/01/2012)

I’ve had a rubbish day today. I’ve been flat-hunting, and I’ve been on an emotional roller coaster. One moment, every thing is sorted. The next, it’s all a mess. It’s difficult to keep a clear head and keep perspective when things are like this. But that’s what you’ve got to do: don’t give up, and don’t lose site of the goal.

Negative Feedback Loop (27/01/2012)

I had to tell someone off today.

It’s the first time I’ve ever done it. All my life I’ve been the pupil, the child, the employee – and generally I’ve struck a fine line between compliance and rebellion. (My English teacher once called me “subversive” which I took as a massive compliment. And knowing him, he probably meant it as one).

In the words of Jack O’Neil from Stargate:

I have spent my life sticking it to the man. Now I am the man.

But I think this is probably good. You want your people in authority to have a healthy distrust of authority. You want them to be challenging themselves and aware of what authority does to people.

I think I handled the telling off quite well. It struck the right balance, something L has always been good at at work, between chastising without getting personal.

The one thing I did forget to say was something along the lines of “this isn’t an exercise in fault finding, we just want to make sure it won’t happen again”. But I think that was the general impression.

I didn’t bulldozer quite as much as I have before, and in hindsight perhaps I should have a little bit more. But what I did right was leave it a few days. The “incident” (I’ve made it sound a much bigger deal than it was here) happened on Tuesday, but I left it until Friday, once everyone had calmed down, to have a chat about what had happened and to give the firm message that this wouldn’t happen again.

If you can keep your cool, I think you keep your respect as well. Fear isn’t any way to manage, and if you get too authoritarian, people will start coming up with ways to bypass you.

Unlocking the Scroll (26/01/2012)

Do you know, after all this time, it was only today that I discovered what the Scroll Lock key does. There’s been a couple of times in Excel when I’ve found that the arrow keys are scrolling the window rather than moving cell, and I’ve assumed that there was a setting on, but it was only today that I thought it might be scroll lock.

So scroll lock sets the arrow keys to scroll the active window. Simple, eh? But I’ve never realised that before. And, asking around the office, no one else had either.

Of course the question now is whether I can actually use this knowledge in anyway way. I suspect it’s not that useful, but at least I’ll know to turn it off when Excel starts behaving weirdly.

Never underestimate (25/01/2012)

There’s a couple of projects I’ve been working on that I thought were going to be really easy and were actually incredibly difficult. I’ve realised, there are so often so many unforseen circumstances.

I’ve realised that even though I’d read Jeff’s article on estimating before, I’m still rubbish at estimating how long things will take:

When you compare the original single-point estimates to the Best Case and Worst Case estimates, you see that the 11.25 total of the single-point estimates is much closer to the Best Case estimate of 10.5 days than to the Worst Case total of 18.25 days.

You’ll also notice that both the Best Case and Worst Case estimates are higher than the original single-point estimate. Thinking through the worst case result can sometimes expose additional work that must be done even in the best case, which can raise the nominal estimate. In thinking through the worst case, I like to ask developers how long the task would take if everything went wrong. People’s worst case estimates are often optimistic worst cases rather than true worst cases.

I need to start doing this in my projects, and, also, asking other people to do this as well.

I had to get angry with our outsourced IT partner this week as they came to a meeting having not done the one thing I asked them to do. I think I got the balance right – calm but very displeased. So we’ll see if they do it again.

Afterwards, they were so eager to please me that they said they’d get the next bit of work done within a week. I probably should have pushed more for best case/worst case estimates.

Don’t look back in anger (24/01/2012)

I’m in the middle of a situation at the moment. My landlord (a hideous multi-million pound corporation) has cut short my contract and is throwing me out of my flat (they gave me notice on Christmas Eve). They want to sell the flat. But they don’t have a buyer lined up, they haven’t put it on the market and they don’t even know what the flat looks like.

When we asked for a month’s extension, they refused.

I’ve taken this opportunity to see if I can afford to buy a flat, and at the moment I’m waiting on the seller to come back to me. It’s a hideous experience, and the most stressful thing of my life.

A few times now, when thinking about my project to “write about something new I’ve learnt every day”, I’ve thought that if I get this flat I’ll write about how disasters are an opportunity. And if I don’t I’ll write about how sometimes you have to know when to walk away.

However, this is ridiculous. I’m arguing it both ways. And an explanation that works both ways is meaningless. It can explain anything. I came across this idea in Thinking Fast and Slow a few days ago:

A story in Nassim Taleb’s The Black Swan illustrates this automatic search for causality. He reports that bond prices initially rose on the day of Saddam Hussein’s capture in his hiding place in Iraq. Investors were apparently seeking safer assets that morning, and the Bloomberg News service flashed this headline: U.S. TREASURIES RISE; HUSSEIN CAPTURE MAY NOT CURB TERRORISM. Half an hour later, bond prices fell back and the revised headline read: U.S. TREASURIES FALL; HUSSEIN CAPTURE BOOSTS ALLURE OF RISKY ASSETS. Obviously, Hussein’s capture was the major event of the day, and because of the way the automatic search for causes shapes our thinking, that event was destined to be the explanation of whatever happened in the market on that day. The two headlines look superficially like explanations of what happened in the market, but a statement that can explain two contradictory outcomes explains nothing at all.

Again, this is something I’d come across before (and even written about before) in a talk by Michael Blastland:

It’s amazing how powerful these beliefs can be. Michael Blastland tells the story of a journalist looking at the figures for alcohol consumption during the recession. He saw that alcohol consumption had gone up.

“Oh,” he thought, “that follows, since people have lost their jobs and have gone out to drown their sorrows.”

Then he realised, this was before the recession had started. After this, alcohol consumption had actually gone down.

“Oh,” he thought, “well, that makes sense, since during the recession people have less money and so can’t afford to go out.”

Then he realised the figures were for 2007.

In each case, he was able to justify the figures by fitting them into his existing worldview. The point is, he could have justified it either way, and then used it as a headline to support his argument.

The point in both of these things is that as humans we look for “agency”. By that, I mean we assume there is a reason for things. In fact, often there isn’t. Often stuff just happens.

As Daniel Kahneman explains:

The prominence of causal intuitions is a recurrent theme in this book because people are prone to apply causal thinking inappropriately, to situations that require statistical reasoning.

I think this is a key thing. And there’s a confirmation bias here as well. When we do something, and then things go well, we assume that things went well because we did that thing. If we pick our lucky number, or pray or even something that seems logical, like make a compelling argument, and then something happen, we think we made it happen. In fact, that thing might have happened anyway for a different reason entirely.

If you want to get to the heart of something and make a difference, you need to fight against this view. Which is very difficult because we’re hard-wired to think like this. There’s a video of some triangles moving around, created psychologist Fritz Heider. It’s just shapes, but as you watch it it’s almost impossible not to create personalities for the different triangles.

Sometimes, you have to avoid seeing patterns where there are no patterns. 

Walk in the park (23/01/2012)

I walked to work today. In London! That’s really living the dream.

Generally, you only get to walk to work if you live in a tiny town somewhere with one shop and one house and you live in one and work in the other.

It took 45 minutes, which was my best case guess. And I felt really good.

I’m going to start doing this more. Not only does it save me money (£1.35 each way on the bus – which adds up over a year), but also it’s healthy!

At Christmas when I went home I took a picture of myself to draw. Due to an optical illusion I looked really fat, and I had a hideous premonition. I’d really hate to be massively fat. I should add, despite the fact I work in IT, and my hobby is sitting in front of a computer not moving very much, I’m actually pretty slim. I guess when you’re hobby is not moving very much it can go either way.

It’s beginning to occur to me that I’m reaching the stage in my life where I may have to do something to keep looking like this. Oh, ageing!

My attitude towards exercise is largely the same as my attitude to backing up my stuff:

  • It must be free.
  • It must not affect my life.

I’ve realised this is probably a little harder to achieve with fitness.

But I’m reminded of when L and I lived in Dulwich. She had to walk up a hill to get to the train station. She said she kept in shape doing that more than any gym membership or exercise regime.

I guess the thing here is, if it’s “automatic” (in the sense you have to do it), you will do it. If it’s optional, then you won’t. “Oh I don’t feel like the gym today, I’ll go another day”, you’ll moan to yourself.

One thing that surprised me about my walk to work was how much it took out of me. I’m not sure I’m quite ready to walk 3 miles, work a full day, then walk 3 miles back just yet. But if I walk there each morning and get the bus back, not only is there a financial reward for me (as long as I don’t spend it on chocolate when I get there), but it will boost my fitness too.

Not Knowing and Not No-ing (22/01/2012)

I’ve been quite stressed this week. Probably most stressed than I’ve ever been in my life before. I’ve realised that “not knowing” and having to wait is probably the most stressful thing in the world. There’s nothing you can do about it, so you just have to wait. It’s even harder when you don’t know how long you may have to wait.

There’s several times you’ll have this in your life: exam results, job interviews, medical tests, large negotiations etc. But no matter how many times you have it, if it’s something your emotionally engaged with, it never gets easier.

The thing is, your brain continues to play scenarios through in your head. Scenarios that you’re helpless to do anything about. I’m no psychologist, but I suspect your brain is planning what it can and hitting a brick wall. And so it keeps running through it over and over again in an attempt to see a way round it. But there is no way around it.

The only things I’ve managed to do so far are:

  • Try to distract myself through other activities
  • Decide on what action I’ll take if things don’t work out how I want
  • Set myself a deadline for taking action

I don’t think there’s much else I can do here, other that recognise that there is nothing I can do, put it out of my mind, and concentrate on things I can do something about.

Tag Cloud