Monday, November 13, 2006

Amazon and Google use Table-Based Layouts

This is my addition to the already over-blogged "table-based vs. CSS-based layout" debate. The older, tried-and-true technique for laying out web pages is to use HTML tables. A newer way is to use CSS Floats. Neither floats nor tables were ever intended to be used for page layout. I won't restate what's been stated but here are my 2 cents on the issue:

  1. The benefits of float-based layouts are overstated.
  2. The difficulty in using float based layouts are understated.
  3. One of the benefits of float-based layouts is separation of content from layout. This benefit can be achieved in other ways, for example on the server-side, by using XSLT, sitemesh or portal technologies.
  4. Amazon and Google use table-based layouts. That has to count for something.
[Update: 5/1/2009] : Today, Amazon and Google's Blogger.com both use CSS based layouts. And so do I.

Friday, November 10, 2006

10 IDE Shortcuts Everyone Should Know

Below are 10 IDE shortcuts that everyone should know but many don't. These are tricks that save me lots of time. I use them so often they are hard-wired into my brain. They work in IntelliJ and Eclipse and probably others.

1. Introduce Variable


IntelliJ calls it "Introduce Variable" (Ctrl Alt V)
Eclipse calls it "Extract Local Variable" (Alt Shift L)

Here is how it works. You type this:

new FooBanger();

Then, with your cursor positioned at the end of the line, press Ctrl Alt V. IntelliJ prompts for a variable name and then changes the code to this:

FooBanger fooBanger = new FooBanger();

Alternately, if you have a long expression like this:

x.getPerson().getCompany().getCEO().getLastName();

You can highlight an expression within the expression, for example:


Then press Ctrl Alt V. IntelliJ prompts for a variable name and changes your code to this:

Company c = x.getPerson().getCompany()
c.getCEO().getLastName();

2. Goto File


IntelliJ calls it "Goto File or Goto Class" (Ctrl Shift N or Ctrl N)
Eclipse calls it "Open Resource" (Alt Shift L)

A large part of what modern IDE's do falls under the heading of "Project Navigation", i.e. making it easy to quickly move from file to file within a large project. This and the next two tips deal with project navigation.

If you remember the name of a file but don't feel like navigating 8 folders deep to get to it, then use this trick. Press Ctrl N. Then type the first few letters of a file name. The IDE then takes you to that file. You don't have to remember what folder the file is in.

3. Hyperlink (Jump to File)


This works the same in IntelliJ and Eclipse. Hold down the control key, then hover your mouse over a class name. As your mouse moves over the class name, it turns into a hyperlink. Click the hyperlink to goto the highlighted file.

4. The Back Button


IntelliJ and Eclipse both have a browser style Back button which takes you to the previous file you were working on.

5. Delete Current Line


Eclipse: Ctrl D (D for delete)
IntelliJ: Ctrl Y (Y for yank)

6. Duplicate Current Line


Eclipse: Ctrl Alt Down
IntelliJ: Ctrl D (D for duplicate)

-----------
OK, so I stopped at 6. This blogging business is tiring.