Archive for October 2008

Form Manager

I finally found a decent name for this “DynamicDataModel” project I have been working on; Form Manager.

Synopsis: A set of objects to allow the developer to write as little code as possible to instantly get a form with validated fields and basic data manipulation.

My idea to was to write something that would allow me to quickly describe what data I want to edit/display, have a standard mechanism for verify data from the user and a generic method of talking to a database to create/get that data.

So far this is what I have come up with:

I built the diagram in NClass, but I kind of cheated and built the model in C# and imported it

The modes know how to render the data, where the data needs to come from and at what time.
The fields are quite the opposite, they know where the data is, and what to do with it, but don’t know when to use it.

So I built this model, the TableDefinition and FieldSet have all the fields hanging off them. And the relevant modes are hanging off the FormManager.

Although I plan to integrate this into phpBB, I have put in layers that should allow for this model to be used in anything.

The other thing is that I am trying to build in as little state as possible so that it can be cached to improve speed. However this will be seen once I start using it in more realistic situations.

The only wierd thing about the model that I am not completely happy with yet is that when the field is told to render itself, it is given the data to use.

I have unit testing around it all, and generated documentation so once its finished I should have quite a nice comprehensive application.

The Perpetual ToDo List

Like pretty much everyone else, I have a todo list with things on it that I never get round to doing. 

For a long time I used a text file sat on my desktop to keep track of all the bits I had to do, but that really didn’t cut it. Which items were high priority, when were they due by?

That why I have started to use this funky little free program from Abstract Spoon (which you can also get from CodeProject) called ToDoList.

Its a neat little app where you can enter all your tasks, create sub tasks and categorise them. Set due dates, priorities, effort and more.

Bash is Back!

The renowned quote database Bash.org, is back up and running. It is a favourite of mine to while away the hours.

Documenting your code in PHP

Whilst working on this model, I found myself forgetting various parameters or names of methods I had created. I can’t believe how much I rely on an IDE to provide me with all my prompts.

I did try setting up Eclipse again with PDT (had tried to use phpEclipse in the past with dissapointing results) yet I was getting UI errors all over, no matter what I tried (updating the JRE, grabbing various packages) I could not get the thing to work.

So I resorted to the next best thing, I went and found something called phpDoc. It reads DocBlocks from your code and creates a set of html pages containing all the information about your code.

Again, I installed it from pear on the command line, there are lots of site out there to help with installing it on Windows. Once installed, you can use the phpdoc -h to get all the command line parameters.

Similar to my last post, I use an msbuild script to run the documentation tasks


<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">

    <PropertyGroup>
        <BuildDir>$(MSBuildProjectDirectory)</BuildDir>
        <DocumentationTitle>Dynamic Data Model</DocumentationTitle>
        <HelpOutput>HTML:Smarty:HandS</HelpOutput>
        <DocumentationFolder>$(BuildDir)Documentation</DocumentationFolder>
    </PropertyGroup>

    <ItemGroup>
        <CodeFiles Include="$(BuildDir)***.php" Exclude="$(BuildDir)**.svn***.*;
                                 $(BuildDir)**tests***.*" />
    </ItemGroup>

    <Target Name="Clean">
        <RemoveDir Directories="$(DocumentationFolder)" Condition="Exists('$(DocumentationFolder)')" />
    </Target>

    <Target Name="Setup" DependsOnTargets="Clean">
        <MakeDir Directories="$(DocumentationFolder)" Condition="!Exists('$(DocumentationFolder)')" />
    </Target>

    <Target Name="Build" DependsOnTargets="Setup">
        <CallTarget Targets="BuildDocumentation" />
    </Target>

    <Target Name="BuildDocumentation" DependsOnTargets="Setup">
        <CreateProperty Value="@(CodeFiles, ',')">
            <Output TaskParameter="Value" PropertyName="FilesToDocument" />
        </CreateProperty>

        <Exec Command='phpdoc --sourcecode --target "$(DocumentationFolder)" --output $(HelpOutput) --title "$(DocumentationTitle)" --filename $(FilesToDocument)' />
    </Target>
</Project>