Saturday, July 31, 2004

Being a beginner...

Hmmm. It's a funny thing, starting in .NET development.

Here's a guy who laments the day he ever saw a 'web based application'.

I feel for him, but I'm afraid to say I can't sympathise too much - apart from anything else I've spent too much time on MSDN reading about the differences between the two...

Thursday, July 29, 2004


NOt sure if I'm too keen on this. It seems to me that in the future, any work we do with a computer will just be flitting from wizard to wizard to wizard.

Okay, so they look nice, and yes, as MS say on their site:

The Web-style approach does have an interesting advantage over the Windows Forms-style, particularly if your users have lower windowing style expertise. It is likely that most users have had some type of experience browsing the Web, using one of the many browser applications available today.
But please, is the only way to get people to use new software to handhold them through every little task they might have to do?

Oh well. Such is life.

Interesting thing...

I knocked up an interesting thing over my lunch hour today. What's more, it's 2 versions of an interesting thing. How's about that, then, eh?

It's a little bit of ASP.NET stuff that reads the source code of the page. The first version's here. That one works fine if the whole lot is built as a single page with a script block. I tihnk it looks quite cool, too.

The second one's here.This one took a bit more work since it reads the source of a page built with a code-behind file. I think it's quite good. It reads the code-behind filename from the aspx page's Src attribute, and hey presto, it's reading that code too.

Well, I didn't think it was bad for a little lunch time relief. Didn't resort to VS to write it, either. The whole lot's written in Notepad. Hand formatted and everything. Neat, huh?

Friday, July 23, 2004

Brick Walls...

Back when I was at school, they always told me that being bright, enthusiastic, and most of all eager to learn would open most doors for me. After I got my degree, I learnt that professional qualifications will get you a hell of a lot further than any "education" will.

So I set out to get myself qualified in programming. I figured, hey, even if I have just a baseline certificate, somebody's got to think I'm worth employing...?

It would seem I am wrong. As far as I can gather, there are no qualifications that will get me hob-nobbing with the cognoscenti.

Oh well. Such, as they say, is life.

Tuesday, July 20, 2004

Praise be for the quick wins

There's something very satisfying, I think, about building UI's. Although at times they can be quite tedious, particularly the finer points of layout, they do provide some of the really quick dirty wins. And I like that.
I'm just putting the dektop UI on SavageBlog (which is what I've decided to call my little blogging app), and I've done something really rather clever. Well, I think, anyway. What I wanted was a textbox for putting the content into blog entries. Although I'm not averse to adding my own tags for formatting, I wanted something a little quicker to work with, something not dissimilar to's very own UI for editing posts. So I added a little toolbar, with buttons for Bold, Italic and Hyperlink text. All I wanted, when I clicked the button, was for the selected text in the box to be prepended and appended with the opening and closing tags for my format of choice (<b> and </b>for instance). The way I did it was this:

txtContent.SelectedText = String.Format("<b>{0}</b>", txtContent.SelectedText)
Which worked fine. Happy as larry. I just select some text to embolden, and it adds the right tags. After using it a couple of times, though, I wanted to improve it a bit. If there was no text selected, I wanted it to add the tags, and then reposition the cursor between the tags. So, if there was nothing selected and I hit the bold button (I haven't added ctrl+x key mappings yet) I could just carry on typing rather than having to move the cursor back between the tags.
The solution I came to was simplicity itself, it just needed an extra 4 lines of code: For your enjoyment, here is the whole lot:
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
    Dim SelLength As Integer = txtContent.SelectionLength
    Select Case CType(sender, ToolBar).Buttons.IndexOf(e.Button)
        Case 0
        txtContent.SelectedText = String.Format("<b>{0}</b>", txtContent.SelectedText) 
        Case 1 
        txtContent.SelectedText = String.Format("<i>{0}</i>", txtContent.SelectedText) 
        Case 2 
        txtContent.SelectedText = String.Format("<u>{0}</u>", txtContent.SelectedText) 
        Case 3 
        Dim Linker As New HyperLinkBox 
        If Linker.DialogResult = DialogResult.OK Then 
            txtContent.SelectedText = String.Format("<a href="{0}" target="_blank">{1}</a>", Linker.LinkAddress, txtContent.SelectedText) 
        End If 
        End Select 
    If SelLength = 0 Then 
        txtContent.Select(txtContent.SelectionStart - 4, 0) 
    End If
End Sub
For reference, Linker is a dialog box that allows the user to enter a URL for the link.
It's not terribly exciting, and to be fair, I reckon 90% of people would never even notice of that feature hyadn't been added. HOWEVER, it did make me feel happy. And it didn't take very long to do. And it worked (quite amazingly, for me) first time. Like I said, quick dirty wins. I should imagine there'll be quite a few more.
On a related note,'s just upped the ante, and improved its UI.

Wednesday, July 14, 2004

Hornets' Nest Tomfoolery

Yet again, this old argument has been started.

Although some of the people who read his blog (like these) are prime tits, Rory's put forward about the only lucid and sensible argument I've heard on the matter. Live and let live, just 'cos it's good for you, doesn't make it good for me, just because it's 'harder' doesn't make it more worth doing. More importantly, just because it looks more complicated, doesn't a) make it so, or b) make it better.

That's all I've got to say on that.

When I Paul Kimmel's excellent VB.NET unleashed, I sat and pondered just what on earth anyone would use MyClass for (as in MyClass.New()) Why not just use MyBase?. I now know. Whilst putting together a load of overloaded constructors I discovered its use. I'll explain:

One of the classes I've built, BlogEntry, uses an internal ArrayList to store Comments. Arraylists are great, but they do need initializing before you can use them (I'm always catching myself out with that if I have an empty arralist). Rather than

If Not MyArraylist is Nothing Then...
or anything like that every time it's referred to, I just created an empty ArrayList in the deault constructor.

Then I got on to more constructors (I got up early this morning and had a boit of a constructor fest!) and found myself writing MyArrayList = new ArrayList over and over again.

That. THAT was when I remembered the wise words about the MyClass keyword.

Now, the default, unparameterized constructor has all the initialization bits and bobs that need to be done, and all the overloads just add on the bits that are specific to them. I thought that was kinda clever. I think I shall make an effort to use it more often.

Tuesday, July 13, 2004

Change of Plan

Well, it's been a busy couple of weeks. Been down to Plymouth and stuff. And plenty of sleeping as well (don't know why I've been so knackered of late... Hmmm... Must upgrade my coffee =-)

Anyway, SavageBlog has had a bit of a change of plan. I've been trying to think of a way to design it. There were 2 options that I could think of:

  1. Store the data in am xml file, and then either run it through a stylesheet for the web UI, and a different one or the feed.
  2. Keep all the data in a SQL Server DB, and then incorporate into the DAL/BLL functions for producing the XML to go through the same transforms etc. For the web and feed
but I think I'll skip both of those stages. The actual content per se isn't going to be used by anything else, and there's something else I haven't really had a chance to use yet, which I think I could do with using, Serialization. It'll work out nicely in this case. Each blog object can be stored as a different xml file and I can use the folder hierarchy to organise it. Hmm. Yes. I thin that's what I'll do.

Need to read up about iSerializable, now. That'll be cool. It's always more interesting reading about stuff when you actually need to use it.

Monday, July 05, 2004

Really quite useful...

... I'm guessing that's why they built it.

I'm talking about the System.XML.XMLDatadocument class. I'm really quite liking using this.

In my new little blogging app, I want to have all the actual content saved as XML (several reasons, not least of which because I haven't had a chance to really use XMLfor much yet). However, I also didn't want to spend days writing UI code that pulled the XML file apart and bound that data to the form.

Enter the XMLDataDocument. It's got all the usual XML stuff, Node collection, Load method, Save method. Everything you'd need to work with an XML file on disk. It also has another property that I really like: XMLDataDocument.Dataset. It's really handy.

The dataset in this case is just another dataset Just like the ones you pull out through data adapters, this one just represents the XML data as a dataset.

To use it, you need to feed it an XML schema. It'll then create the dataset and populate it with the XML data from the document.

Presumably (although I haven't had a chance to ty this yet) taht also means you can use the XMLDataDocument.Dataset to represent an interpretation of the data by feeding it a different schema. Kind of like adding views to a dataset, but doing it at an earlier point in the process. I know one limitation to that is that you wouldn't be able to change the schema after you've loaded the data (you can't set a schema after the data's been loaded) but if you're looking at an app with several data-access filter option type things (if you have different sets of data used by different people) then it could be useful.

Although having said that, if you've got a need that complicated I guess you're a milion times more likely to use SQL Server instead.

Oh well. I'll keep on using it. I kinda like it for my backend code. It's currently keeping things nice and simple in my backend code.