Categories
Blogs Computere og Internet Historier/Stories Kim Blog (English) Technology

No _compiler_ detected errors – but shouldn’t I, at least, have received a warning?

One of the first compilers I worked with, VS-Pascal, had a very “HAL-like” confident behaviour, after it had finished a succesful compile, it wrote:

“No compiler detected errors”

I found that almost rude, but it was also something to keep in the back of your mind, and today I remembered this clearly.

For the last week or so I’ve had a mysterious ASP.NET/C# problem on the back-burner. I’m trying to populate a drop-down list on a webpage. The list is based on a list of documents. For that purpose I had an entity class with a constructor, in the Page_Load code of the webform, I’m initialising the drop-down with a desciption and an id from the document list.

The list was populated just fine, but when I did a post of the form, I was consistently told that the first item was selected, even if I selected item number 2, 3 or 4.

This was very frustrating, especially because I have two drop-downs, and the other was working just fine.

Today I couldn’t postpone the problem any longer, and I tried a number of things, including moving the drop-downs, and finally I started doing websearches for bug-reports, but it’s extremely unlikely that ASP.NET has such a fundamental bug, so I was clearly doing something wrong.

When you’re using frameworks like .NET, a lot is done behind the scenes, luckily I know HTML so I finally hit View/Source, and to my surprise all the option values in the select tag were set to 0, why was that, I knew that my list was initialised to values from 0-4, but it was consistent with the test-results.

I was clearly doing something wrong. Below is the C# source-code for the entity class, can you spot the problem?

public class ShredYearDocument
   {
       private int _shredYearId;

       public int ShredYearId
       {
           get { return _shredYearId; }
           set { _shredYearId = value; }
       }

       string _shredYearDescription;

       public string ShredYearDescription
       {
           get { return _shredYearDescription; }
           set { _shredYearDescription = value; }
       }

       public ShredYearDocument(int ShredYeadId, 
           string ShredYearDescription)
       {
           _shredYearId = ShredYearId;
           _shredYearDescription = ShredYearDescription;
       }
   }

I’ll give you a hint: there are no compiler detected errors, but I’d argue that the compiler should,at least, have generated a warning, because I have something that could be likened to unused, or uninitalised, local variables.

Another hint: Remember that I always had the id set to zero (0), no mater what.

But shouldn’t the compiler generate a warning here?

Categories
Blogs Bookmarks Computere og Internet Hackers Kim Blog (English) Open Source Technology

PHP blues – drawing a blank

Software development can be extremely frustrating, and it might be true that the computer only does what you tell it to do, but these days a lot of people, besides yourself, are telling the computer what to do, a fact that complicates matters “somewhat” (understatement of the year).

The following experience documents a case, where I was sure that I wasn’t doing anything wrong, and you could argue that I didn’t, I just didn’t know any better, but thanks to the community I solved the problem.

The setting

I’ve recently begun doing some PHP programming, and I like it a lot, mostly because of all the wonderful community. it’s my gut feeling that I find answers to my questions much faster when I have PHP related questions, compared to .NET questions.

So I was experimenting with generating some XML code from PHP, but when I gave the URL to the W3C validator, it told me that the XML wasn’t well-formed, and that it was the header that was the problem.

I couldn’t see anything wrong, until I took a closer look. There was a mysterious space prefixed the output when I did a View/Source, a space that I for sure knew I didn’t echo. Hmm…

I tried several things, including flushing the output, but nothing helped.

Then it dawned on me: it’s very likely that someone else has had this problem, and if they did, for sure they would have the generosity to share it, so Google to rescue.

I googled: problem php output leading blank, and hit number two yielded this article:

Script for removing blank spaces before and after PHP tags « memento

The solution

It turns out that PHP is quite sensitive if you, by accident, leave prefixed or sufficed blank spaces outside the starting and ending php tags.

So I went through my PHP files, luckily I only have two, made sure there were no leading or trailing blanks og lines, and I get well-formed XML now.

This is a rather annoying bug in, or should I say feature of, PHP, and it exists in both PHP4 and PHP5.

Once again the community came through, without it I’d still be drawing blanks.

And I love the drawing on the memento site, it doesn’t get geekier, and I think I’ll remember to strip leading and trailing blanks now.

I’m still looking for a modern development environment for PHP development (e.g. sourcecode debugging). PHPEclipse, a plug-in for the Eclipse development environment, should provide a relatively modern development environment, even though it’s not up to the standards set by Microsoft VisualStudio, that I’m so accustomed to, Microsoft has spoiled me.

Categories
Blogs Kim Blog (English) Music

You know loud’s my diagnosis

OK, you’re on your own, it’s late
Your girlfriend is on another date with the hero in your dream
Turn around, ask yourself. So, you think you’re gonna win this time Manchild?

Is it the pain of the drinking
Or the Sunday sinking feeling
The car never seems to work
When it’s late your girlfriend’s on a date
And the hero with her in your dream
In your sleep it seemed like you
Turn around ask yourself
Turn around ask yourself

Chorus:
Manchild, will you ever win
Manchild, look at the state you’re in

Could you go undercover
And sell your brand new lover (could you)
Be someone else for a night
Maybe someone else will love you
You’d sell your soul for a tacky song
Like the ones you hear on the radio
Turn around ask yourself
Turn around and ask yourself

Chorus:
Manchild, will you ever win
Manchild, look at the state you’re in
Manchild, he will make you cry
Manchild, Manchild, Manchild

From Monday down to Friday
You’re working on another man’s car
Or is it in the factory?
It doesn’t matter where you are

Just turn around and ask yourself is this communication
Accentuate the positive to give some illustration
See Manchild, you’re no one, I turn the microphone on
Control communication when I’m kickin’ it and so on
To the point that I need, the air that I breathe
Into an audience that’s waiting and ecstatic to receive
For the meantime another mean rhyme, I keep on sayin’ it
I know what the time is in the crowd we’ll keep on playing it
Through the speaker boxes loud’s my diagnosis
‘Cause I believe in miracles and words in steady doses.
Enough R-E-S-P-E and C-T
Respect yourself express no stress the mike is easy
Just believe that all you need is the air that you breathe.
(Turn around ask yourself)

Chorus:
Manchild, will you ever win
Manchild, look at the state you’re in
Manchild, he will make you cry
Manchild, Manchild, Manchild
He’s the apple of your eye

Once bitten twice shy, why don’t you bite me again
Just take it in the right and go tell your friend
Are you ready for the words I turn the microphone on
A figure of speech to reach you at the back and so on
The style I’m stimulating dance floors
Raise your body temperature now and
This demands for power in the amp you know loud’s my diagnosis
‘Cause I believe in miracles and words in heavy doses