Entries for month: July 2010

Easily Ignore CFBuilder Meta Files in a new Git Repo

When you create a new ColdFusion project in CFBuilder, you end up with 3 things in your project folder:

  • A .project file -- this is par for the course in Eclipse
  • A .settings folder
  • And a settings.xml file

During the pre-release process I voiced my opinion that this was too much meta and that they should find a way to cut back or combine where possible. That hasn't happened. In addition, I complained that the file name "settings.xml" is too generic and quite likely to be something that the average developer would want to create for their project. This, too, seems to have fallen on deaf ears.

Oh well. Maybe next time.

However, in the meantime, I've created a quick shortcut for my Mac to create a new git repository and ignore all of the CFB Project Meta files all in one step. On Snow Leopard, edit the .profile file in your account folder (/Users/[your username]/.profile) and add this line:

alias cfgit="git init;echo '.project' >> .gitignore;echo '.settings' >> .gitignore;echo 'settings.xml' >> .gitignore;echo '.gitignore' >> .gitignore;git status"

It all has to be on one line to work properly, but I'll break down each command individually here so that it's easier to read.

alias cfgit="..."

Here we're creating a bash command alias. This translates to, "When I type cfgit I want you to do [this] instead." Where [this] is what you put inside the quotation marks. You can put multiple commands here as long as you separate them with a semicolon.

echo '.project' >> .gitignore;
echo '.settings' >> .gitignore;
echo 'settings.xml' >> .gitignore;
echo '.gitignore' >> .gitignore;

Each of these appends a new line to the file .gitignore with the contents of the single-quotation marks; so in this case it's adding a new line for .project, .settings, settings.xml, and .gitignore (ignore itself). By using >> instead of >, you append to the file if it exists, or create it otherwise. If you're unaware, the .gitignore file tells the local git client which files in the folder are to be excluded from the repository.

Lastly, it runs git status to show the current status of the folder/repository; mostly just as a sanity check to make sure that everything that I want to have happened has.

in CFBuilder | Apple | Git | 4 Responses Posted 2010-07-06 12:46

Inheritance vs. Access Levels

I did google this, but the terminology is so ubiquitous to all programming languages that I wasn't able to find anything specific to ColdFusion. So hopefully this isn't a repeat of anyone else's post. And a huge hat tip goes to Nathan Mische for pointing this out in my code.

So let's say you have some inheritance going on:

parent.cfc

component {
    public string foo(){
        return "I am the parent class.";
    }
}

child.cfc

component extends="parent" {
    private string foo(){
        return "I am the child class.";
    }
}

And then you call the foo method on an instance of the child object:

obj = createObject("child");
writeOutput(obj.foo());

You might expect the output to be:

I am the child class.

But you would be wrong. I was. Did you catch the subtle reason that the parent class implementation of the foo method is what runs?

The foo method override in the child class is private while the foo method in the parent class is public. Since private methods aren't visible to code executing outside the same component, the parent class' implementation is used.

I suppose this makes sense on some level. Part of me was under the impression that by making the override private, the public function in the parent class would become private as well; but that is obviously not the case.

I have verified that this behavior is the same on both ColdFusion 8 and 9, but I have no idea how Railo and OpenBD handle this.

in ColdFusion | No Responses Yet Posted 2010-07-02 10:20