April 2008

When to inline!

Today we were working on a bit of code that is at the centre of our application. It is the front controller for the entire website.

There are several loops in there which switch between different page renderers and handlers for the request.

We initially thought to put these into seperate methods to make the body of this method shorter but actually in the end it looked much better with everything inline.

We did have quite a bit of exeption handling so we decided to create a “handleInternal” method which does the actual work and so we seperate the loops from the exception handling code.

This is a good example of when it is not so good to factor everything into seperate methods – it was actually more confusing for another person to look at – as we had to be sure to name all the methods right – in such a critical piece of code it is maybe easier to read if the loops are there.

I think.

Im still slightly undecided – sometimes i find it easier to read code if the details of looping etc are hidden away from me – and im just presented with a set of method names that are descriptive about the process.

In this case however maybe the clue was that we couldnt really find some unambiguous names for the methods and also you did actually care what they did somehow.

  • Share/Bookmark

code
design

Comments (0)

Permalink

Update to the site…

I’ve been playing with media wiki all weekend and now have it behaving pretty well.

You can click the links in the header of this page and it will seamlessly go to the mind web!

which is also of course here

Now all I have to do is work out how to convert LaTeX to HTML properly and i can start putting some articles up here.

The other option of course would just be to make a nice CSS stylesheet for an xml format and write everything using that. I can simply print to a pdf then.

wait a minute! google docs somehow manages to show stuff as html ….

so you can just send yourself a pdf and then view as html and save the result!

it doesnt do pictures though unfortunately, but it wouldn be all that hard to put them back in for short articles….

So I also updated the pictures part – customising the gallery application which now looks cool to!

  • Share/Bookmark

code
web
website

Comments (0)

Permalink

Javascript Javascript JavaScript JavaSCRIPT!!

Just been shown how to do the old hiding and showing trick with javascript so that when javascript is turned off the thing shows by default.

simple trick – have a stylesheet that is itself loaded by javascript in the on load method of the dom.

Then you can override a class which has say “display:block” in a base css file with “display:none” in the JS loaded one.

After that you simply do the normal toggling.

A nice adaptation is to change a class name you use :

    if (className.indexOf('js-hider') > -1) {
        document.getElementById('element-to-hide').className = className.replace('js-hider', 'js-shower');
        console.log(document.getElementById('element-to-hide').className);
        theLink.innerHTML="Hide thing";
    } else {
        document.getElementById('element-to-hide').className = className.replace('js-shower', 'js-hider');
        theLink.innerHTML = 'Show thing';
    }
  • Share/Bookmark

code
javascript
web

Comments (0)

Permalink

Test Google Code Syntax Highlighting…

So Just installed the google syntax highlighting plugin for wordpress:

Plugin home

So now i should be able to do :

public class JimsClass {

    public static final void main(String[] args) {
        System.out.println("Hello, Dolly!");
    }
}

sweet!

  • Share/Bookmark

code
website

Comments (0)

Permalink

test post from blackberry !

How very modern !

I can post whilst strolling down the street !

  • Share/Bookmark

website

Comments (0)

Permalink