Angel “Java” Lopez on Blog

October 31, 2009

NHibernate running in the Azure Cloud

Filed under: .NET, Azure, Cloud Computing, NHibernate — ajlopez @ 1:12 pm

Yesterday, I was talking with Fabio Maulo (@fabiomaulo) about many things, related to software development, teaching programming and, of course, NHibernate. We are living in Buenos Aires, Argentina, and it was a pleasure to talk with him, as usual. Í’m following Fabio in Twitter, and I’m a suscriber of his blog. Fabio is collaborating with NHibernate project for years, and he is a recognized developer in the .NET software community.

He told me details about a site built using NHibernate, and running on SQL Azure. You can see it online (Spanish content, Mexican site):

http://salondetokio.autocosmos.com.mx/

Fabio and his team worked hard to write this site, in less of a month (I’m waiting the team posts, with more detailed info, so, I’ll write only about the public parts here).

Curiously, the site is running using WebForms, but without ViewState, and without form tags embracing the full body inner HTML. All we are waiting Maulo and his team, explaining the implementation details. The code is based on using Model View Presenter, and it was build using tests, mocks and stubs, from presentation to persistence. Hey, Fabio! Please, write about the process and architecture decisions! :-)

More info about NHibernate and Azure:

NHibernate on the cloud: SQL Azure Ayende NHibernate test results on Azure

Quick news NHibernate with SQL Azure Fabio’s first steps “All work… even the SchemaExport.” !!

NHibernate dialect for SQL Azure Adjustments for SchemaExport

I’m collecting links about NHibernate and Azure at:

http://delicious.com/ajlopez/nhibernate+azure

There is an excellent post serie from Brad Adams, explaining Azure, Azure SQL, NHibernate, Silverlight, RIA .NET Service, and more:

Index for Business Apps example for Silverligth 3 RTM and .NET RIA Services July Update

Related to NHibernate and Azure, in that series:

Part 20: NHibernate
Part 23: Azure

Any other project using NHibernate on the cloud?

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

September 21, 2009

AjSharp programming language: a C#-like dynamic language

Filed under: .NET, AjSharp, Programming Languages — ajlopez @ 8:58 am

During the creation of AjGenesis, my code generation project, I defined an interpreted language, named AjBasic, used to write templates and tasks for code generation process. Last year, I began to separate AjBasic implementation of AjGenesis core, and as a proof of concept, I wrote AjSharp, another interpreted language but with more C#-like syntax, using the same core interpreter that I wrote for AjBasic. The core machine was AjInterpreter. More info at:

AjSharp- a C Sharp-like interpreter, work in progress

Now, this year, I started a clean implementation, inside my AjCodeKatas Google Code. The core interpreter is now AjLanguage, and AjSharp is the language with a parser that relies on the core “virtual machine” to build and execute an abstract tree:

Current source code (under development) can be downloaded from:

http://code.google.com/p/ajcodekatas/source/browse/#svn/trunk/AjLanguage

Variables, expressions and commands

Variables are untyped, and are automatically declared when they are used:

a = 1;
b = 2;

These variables contain integer values, but they can be assigned to values of other types:

a = “one”;
b = “two”;

The common commands are supported:


if (k>0)
 return;

for (k=1; k<=10;
k++)
 sum = k+sum;

while
(j<10)
 DoProcess(j);

foreach (element in
elements)
 AddElement(element);

Conditional expressions can be any expression, not only boolean ones. See above, False value explanation.

Functions and Subroutines

This is the sintax to write down a factorial function:

function Factorial(n)
{
 if
(n<=1)
 return
1;
 return n * Factorial(n-1);
}

The word “sub” can be used to define subroutines.

Functions and subroutines are like any other values. They can be defined without name and assigned to variables:


Add1 = function (n) { return n+1; }
two = Add1(1);
function Apply(func,values)
{
 list = new
List();
 foreach (value in
values)
list.Add(func(value));
 return list;
}
numbers = new
List();
numbers.Add(1);
numbers.Add(2);
numbers.Add(3);
function Square(n) { return n*n; }
squared = Apply(Square, numbers);
squared2 = Apply(function (n) { return
n*n; }, numbers);


Native .NET objects

One of the design goals of AjLanguage core is to have access to .NET objects. They can be created using the new keyword:


ds = new System.Data.DataSet();
dinfo = new System.IO.DirectoryInfo(“.”);
foreach (fi in dinfo.GetFiles()) {
PrintLine(fi.FullName);
}

Dynamic objects

Dynamic objects can be created using the new keyword. A dynamic object accepts new members (variables and methods):


dynobj = new DynamicObject();
dynobj.FirstName = “Adam”;
dynobj.LastName = "Genesis”;
dynobj.Age =
800;
dynobj.FullName = function() { return FirstName + “ “ + LastName; }

Another notation:

dynobj = new { Name = “Adam”, Age = 800 };

Another notation:


dynobj = new { var FirstName = “Adam”; var LastName = “Genesis”; function
FullName() { return FirstName + “ “ + LastName; }

Dynamic objects are defined automatically, setting theirs properties:


Project.Database.Provider = “…”;
Project.Database.ConnectionString =
“…”;

creates Project dynamic object, with a Database property pointing to another dynamic object. It’s equivalent to:


Project = new DynamicObject();
Project.Database = new
DynamicObject();
Project.Database.Provider =
“…”;
Project.Database.ConnectionString = “…”;

An experiment: lists are defined automatically using Add method:

Project.Entities.Add(new { Name = “Customer”, Table = “dbo.Customers” });

it’s equivalent to:


Project = new DynamicObject();
Project.Entities = new
List();
Project.Entities.Add(new { Name = “Customer”, Table = “dbo.Customers”
});

Dynamic classes

A class can be defined using this sintax:


class Person {
 var FirstName;
 var
LastName;
 var Age;

 function
FullName {
 return FirstName + “ “ +
LastName;
 }
}

A new instance can be created as usual:

adam = new Person() { FirstName = “Adam”, LastName = “Genesis”, Age = 800 };

The instance is dynamic: new members can be attached to it, and methods could be redefined:

adam.FullName = function() { return “The “ + FirstName; };

You can create class as values:

Person = new DynamicClass();

but the interface to add members is still in flux.

Defined Classes

There are some predefined classes:


dynobj = new DynamicObject();
list = new List(); // implementing 
IList
dict= new Dictionary(); // implementing IDictionary

Primitive Functions

A few functions and subroutines are predefined:


Print(“Hello”);
PrintLine(“Hello World”);

There three predefined functions to execute and evaluate dinamic code:

Include("program.ajs");
Evaluate("k+1");
Execute("k=1;");
Include execute the commands in a file. Evaluate parses and evaluate an expression. And Execute compile and execute commands.

False value

Anything that is false, null, zero or empty string, is evaluated as false in conditional expression:


if (k)
 PrintLine(“true”);
else
PrintLine(“false”);

The above command prints “false” on execution, if k is zero or undefined. If a variable is undefined, any access to its member returns null, instead of a null exception:


if (Project.Database.ConnectionString)
PrintLine(“true”);
else
 PrintLine(“false”);

This command prints “false” again, if variable Project is undefined.

Arrays, List and Dictionaries

Native arrays can be defined with length:


firstprimes = new int[10];

or with values:


firstprimes = new int[] { 1, 2, 3, 5, 7, 9 };

A list is created if you need a dynamic array:


numbers[0] = “zero”;
numbers[1] = “one”;
numbers[2] =
“two”;
numbers[3] = “three”;

A dictionary is automatically created if the subindices are not numeric:


numbers[“one”] = 1;
numbers[“two”] = 2;
numbers[“three”] = 3;

If you need more feature, remember, you can use the native .NET framework.

Console interface

The project AjSharp.Console is a console application, where you can enter and execute AjSharp commands (not expressions):

No command to exit, yet. Just control+c in Windows.

Next steps

There are so many features I want to add. Partial list:

- AjBasic as another language over AjLanguage

- Generics support

- Template support (as in AjGenesis)

- Integrate to AjGenesis code generation

- Compile AST to Dynamic Language Runtime

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

September 8, 2009

Microsoft Surface Demo: Patient Consultation Interface by Infusion

Filed under: .NET, Interface, Software Development — ajlopez @ 9:40 am

Currently, I’m working in an agile team, development a health care and administration application. I’m a newbie to health development world, but I’m impressed about the complexity and variety of requirements and opportunities to explore and exploit. It’s an exciting field for development.

Presenting patient information to medical professionals can be a challenging job. One of the team members just discovered this video, from http://www.infusion.com Microsoft partner, demoing a Surface application to view patient information:

I read at Youtube video page information:

MICROSOFT SURFACE PATIENT CONSULTAION INTERFACE
The Microsoft Surface Patient Consultation Interface enables doctors to relate complex concepts through simple interactions.

APPLICATION COMPONENTS

The Surface Patient Consultation Interface augments and facilitates the conversations that a doctor regularly has with his or her patients through a unique, interactive representation on the Microsoft Surface. With the use of static and active media elements, a doctor is able to demonstrate and relate complex medical procedures or conditions in laymans terms to their patients.

Doctors are able to use this tool to exchange content and information with their patients, adding a feeling of security to the transfer of electronic information between doctor and patient. Through the use of slide menus, touch interaction, and a simple navigation system, the application gives doctors the opportunity to provide their patients with a valuable educational experience.

The application is divided into 2 distinct views and makes use of five interaction points:

VIEWS:

The Content View allows the viewing of shared content in a free-form fashion. This view facilitates easy observation and a simple summary of any topics shared during a session.

The Anatomic View presents content for viewing in the context of the human body. This view enables the uncomplicated observation of specific diagnosis information and educational content.

Within both views, content can be manipulated to allow doctor and patient to easily see and access information together. The three primary forms of content that can be displayed include: documents, photographs, and videos. The capability also exists for presenting additional content such as 3D models.

INTERACTION POINTS:

The Content and Anatomic views are traversed via 5 common elements.

PERSONAL IDENTIFICATION components enable both the patient and doctor to share and store information. Identification occurs when the patient or doctor places their identification card on the Surface. For the patient, the identification card provides the ability to share and receive content from their Microsoft HealthVault account. For doctors, identification allows them to share generic and educational content with the patient.

The ANATOMIC LOCATOR enables the doctor to focus on a specific area of the body. This action is performed by selecting and manipulating one of five body types that can be used for accessing content: exterior, organ, circulatory, nervous and skeletal.

The ORB MENU draws data from the patients HealthVault account when a patient enters the content view. This hierarchical and easily navigated menu enables the selection of new content for the current session through the selection and dragging of content orbs located near the patients HealthVault card.

The WEB MENU allows the doctor to display content within the Anatomical View. Once a body type is selected, key points on the body relating to the shared content are highlighted. This content includes documents, static images, and videos arranged around the point of interest.

CONTENT ITEMS are a part of the overall interaction within the application and consist of documents, photographs, and videos. These multimedia tools are embedded into the patients information, interaction points within body types, or any other educational portion of the application.

To learn more about Infusion and Microsoft Surface, visit: www.infusion.com or email surface@infusion.com.

More info about Infusion works with Surface, at their blogs:

http://www.infusion.com/surfaceblog/

There are interesting topics, as tips for Surface development and UI design.

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

July 14, 2009

ASP.NET example using Mere Mortals Framework

Filed under: .NET, ASP.NET, Mere Mortals Framework, Visual Basic .NET — ajlopez @ 8:31 am

I was working reproducing the ASP.NET example described in Mere Mortals Framework Developer’s Guide, using Northwind MS SQL database, using VB.NET as implementation language (the guide explains the steps to create this app using VB.NET or C#).

You can download the result from my Skydrive:

MMNorthwind.zip

Load the solution in VS 2008 (you must have Mere Mortals Fwk DLLs in your machine).

This is the CustomerOrders.aspx page:

The first column is a link, that points to OrderEdit.aspx, where you can edit

You can change the connection string at web.config:

In my current project, the team is working improving the validation process, specially in grid fields. I hope I will rewrite this example as templates and tasks using AjGenesis. Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com/
http://twitter.com/ajlopez

July 7, 2009

Remember Clipper

Filed under: .NET, AjClipper, Programming Languages — ajlopez @ 9:28 am

These days, I’m working in a reimplementation of a full health systems, originally written in the venerable programming language Clipper. It’s a big project, with many use cases, including administration, pharmacy, stock, diets, health management.

I met DBase II at early 80s. It ran in many operating systems, as an interpreter. At late 80s, I met Clipper from Nantucket, for DOS. Some of you remember Fox, adquired by Microsoft years later.

I found some info about Clipper. Those interested in the language, can visit:

CA-Clipper 5.3 . Guide To CA-Clipper – Menu

Clipper (programming language) – Wikipedia, the free encyclopedia

Code examples at:

The Oasis Clipper Source. Over 300,000,000,000 bytes served!

Frequent asked questions about Clipper and related stuff:

Frequently Asked Questions (FAQ 2.31) about CA-Clipper and CA-Visual Objects

One of the member of the development team, commented that while Clipper was from Nantucket, it kept updated, but when it was bought by Computer Associates, it entered in a shadow, full of pitfalls, so it was surpassed by other options.

If you still have Fox, Clipper, DBase files in your disk, you can check the products from:

CodeBase Products Overview

It seems an interesting open source project, with SQL Server support, running in many plataforms, implementing a Clipper to C compiler:

Harbour Project

As language, Clipper had its quirks, as:

- The use/abuse of SET, as in SET EXACT OFF, SET EXACT ON, that modifies the behaviour of the application
- The concept of work areas
- Thinks like MEMVARS, that I still to understand)

I’m having fun, writing an interpreter, AjClipper in C#:

I have two simple programs running using my interpreter:

? "Hello World"

y

? "This is a test"

foo := "Hello"

bar := "World"

? foo, " ", bar

You can run them using

AjClipper.Console HelloWorld.prg SimpleTest.prg

It’s not a “killer application”, but it´s taking form. You can see my advances in my AjCodeKatas trunk:

http://code.google.com/p/ajcodekatas/source/browse/#svn/trunk/AjClipper

Están escritos los tests (dando verde, por ahora):

Good Code Coverage:

 

I´m adding any interesting link about Clipper under http://delicious.com/ajlopez/clipper

I could write an interpreter for Visual Fox dialect? I should study http://delicious.com/ajlopez/visualfox :-)

Angel “Java” Lopez

http://www.ajlopez.com/en

http://twitter.com/ajlopez

June 21, 2009

Code Generation for Mere Mortals Framework

In the current project, my agile team is developing a full health application (Medusa Project), using Mere Mortals Framework as a base to business objects, persistence and WinForm/ASP.NET presentation. You can download a trial version of this framework:

http://www.oakleafsd.com/

There is a feature list at

http://www.oakleafsd.com/MMNetFeatures/pgMMNetFeatures.htm

You can download the developer Guide from

MM .NET Developer’s Guide

The framework were developed by Kevin McNeish, Microsoft MVP, president and Chief Architect of Oak Leaf Enterprise. The framework supports typed entities, but in the background, it’s based on datasets. You can generate a business objects project from templates, and with a code generator provided by the product, you can populate that library with classes, derived from a database.

In my team, we are feeding metadata reading database information, and then, we are generating a full ASP.NET Web Application, a business object libraries, stored procedures, and DDLs for database regeneration. All using AjGenesis, my open source code generation utility. I should post about the experience. The seed task and templates, were derived from the example:

AjGenesis- Generating the model from the database

In this post, I describe another approach: starting from an abstract model, I’m generating:

- Scripts for creating the database
- Business Objects a la Mere Mortals class library
- WinForm project with maintenance forms

I posted about generating applications from an abstract model at:

Application Generation using AjGenesis

but caveat: AjGenesis is based in a free model. You can model what you want. The trivial example:

Code Generation with AjGenesis- A Hello World application

The model

You can download the example from the Codeplex project site example page:

MereMortalsExamples200906.zip

It contains:

The model resides in Projects/AjFirstExample/Project.xml

<Project>

    <Name>AjFirstExample</Name>

    <Description>First Example using AjGenesis</Description>

    <Prefix>AjFE</Prefix>

    <Domain>com.ajlopez</Domain>

    <CompanyName>ajlopez</CompanyName>

    <Model>

        <Entities>

            <Entity Source="Entities/Customer.xml"/>

            <Entity Source="Entities/Supplier.xml"/>

        </Entities>

        <Lists>

            <List Entity="Customer"/>

            <List Entity="Supplier"/>

        </Lists>

        <Forms>

            <Form Entity="Customer"/>

            <Form Entity="Supplier"/>

        </Forms>

        <Views>

            <View Entity="Customer"/>

            <View Entity="Supplier"/>

        </Views>

    </Model>

</Project>

There are two entities, Customer and Supplier. The Customer entity:

<Entity>

    <Name>Customer</Name>

    <Description>Customer Entity</Description>

    <SetName>Customers</SetName>

    <Descriptor>Customer</Descriptor>

    <SetDescriptor>Customers</SetDescriptor>

    <SqlTable>Customers</SqlTable>


    <Properties>

 

        <Property>

            <Name>Id</Name>

            <Type>Id</Type>

        </Property>

 

        <Property>

            <Name>Name</Name>

            <Type>Text</Type>

            <SqlType>varchar(200)</SqlType>

        </Property>

 

        <Property>

            <Name>Address</Name>

            <Type>Text</Type>

            <SqlType>text</SqlType>

        </Property>

 

        <Property>

            <Name>Notes</Name>

            <Type>Text</Type>

            <SqlType>text</SqlType>

        </Property>

 

    </Properties>

</Entity>

 

There is a technology dependent model at Projects/AjFirstExample/Technologies/VbNet3.xml:

<Technology>

    <Programming>

        <Dialect>VbNet3</Dialect>

    </Programming>

    <Database>

        <Dialect>MsSql</Dialect>

        <Name>AjFirstExampleMM</Name>

        <Host>(local)</Host>

    </Database>

</Technology>

You can change the host to .\SQLEXPRESS if you don’t have a running MS SQL Server. You can add <Username> and <Password> if you are using SQL security. If there are not present, the code uses integrated security.

Generating the application

You must download AjGenesis current release 0.5 from http://ajlgenesis.codeplex.com. Add the bin directory to your path. Then, run from the example directory:

GenerateProject.cmd AjFirstExample VbNet3

The first parameter is the project name, and the second is the technology to use. The command invokes

AjGenesis.Console Projects\%Project%\Project.xml tasks\BuildProject.ajg  Projects\%Project%\Technologies\%Technology%.xml tasks\BuildTechnology.ajg tasks\BuildProg.ajg tasks\BuildSql.ajg

It loads the project model, execute the BuildProject task, then loads the technology model, executes the BuildTechnology tasks. The task BuildProg generates the code, and BuildSql generates the DDL to create the database.

It creates a new folder, Build, containing

In Sql folder, you find the ExecuteAll.cmd to create the database

You can run it with a parameter, specifiying your server:

ExecuteAll.cmd Bombadil

If you run this command without a parameter, it uses the host specified in the technology model. There is a VS 2008 solution with two projects, in Src folder:

You can load and compile in Visual Studio (you must have Mere Mortals Fwk installed).

The class library project contains Mere Mortal business objects definition (using partial classes, data access calling stored procedures, rules)

The Win form project has two maintenance forms, for Customers and Suppliers:

Well, it’s not the “killer application” but it’s running:

You can download the generated solution, from my Skydrive

AjFirstExampleMereMortals.zip

Conclusions

Using an abstract model, we can generate the usual text artifacts required by Mere Mortals fwk (or any other framework, technology). With partial classes and separated files, we can regenerate the code from the model, without losing our manual code. We can augment the generated code with automatic validation, rules, and any coding standard we were using.

But the main point, for me, it’s that using an abstract model, we are separating the important core from the technicalities. I could regenerate the application with other base framework, other languages, but our model could be the same. The model describes what we want. Tasks and templates compose an expert system, that knows HOW to get what we want as application.

Angel “Java” Lopez

http://www.ajlopez.com/en

http://twitter.com/ajlopez

June 3, 2009

First NHibernate 2.x example

Filed under: .NET, C Sharp, NHibernate — ajlopez @ 9:23 am

I was working creating a .NET solution, containing a minimal NHibernate 2.x example. I’m using NHibernate GA 2.0.1 binary distribution, following the reference manual instruction.

You can download the source code from my Skydrive folder:

NHibernateExample1.zip 

I was using the online documentation from

http://nhforge.org/doc/nh/en/

and I built the same manual in .pdf format, from the SVN trunk:

https://nhibernate.svn.sourceforge.net/svnroot/nhibernate

You can download the manual in .pdf from

nhibernate-reference.pdf

The solution contains two projects: a class library, and a console application:

The domain contains only one class, Cat (following the first example included in the NHibernate doc):

namespace NHibernateExample1.Domain
{
    public class Cat
    {
        private string id;
        private string name;
        private char sex;
        private float weight;

        public Cat()
        {
        }
        public virtual string Id
        {
            get { return id; }
            set { id = value; }
        }

        public virtual string Name
        {
            get { return name; }
            set { name = value; }
        }

        public virtual char Sex
        {
            get { return sex; }
            set { sex = value; }
        }

        public virtual float Weight
        {
            get { return weight; }
            set { weight = value; }
        }
    }
}

There is an embedded resource describing the mapping: Cat.hbm.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="NHibernateExample1.Domain" assembly="NHibernateExample1.Domain">
  <class name="Cat" table="Cats">
    <!-- A 32 hex character is our surrogate key. It's automatically
generated by NHibernate with the UUID pattern. -->
    <id name="Id">
      <column name="CatId" sql-type="char(32)" not-null="true"/>
      <generator class="uuid.hex" />
    </id>
    <!-- A cat has to have a name, but it shouldn' be too long. -->
    <property name="Name">
      <column name="Name" length="16" not-null="true" />
    </property>
    <property name="Sex" />
    <property name="Weight" />
  </class>
</hibernate-mapping>

There is an ExecuteAll.cmd in Sql folder, that creates the database (you can pass the MS SQL Server as parameter, .\SQLEXPRESS is the default value):

The console application is simple: configures NHibernate, gets a session, inserts new objects inside a transaction, executes a query, and list the result:

        static void Main(string[] args)
        {
            ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory();

            ISession session = sessionFactory.OpenSession();
            ITransaction tx = session.BeginTransaction();

            Cat cat;

            cat = new Cat() { Name = "Moe", Sex = 'M', Weight = 9.0f };

            session.Save(cat);

            cat = new Cat() { Name = "Larry", Sex = 'M', Weight = 8.5f };

            session.Save(cat);

            cat = new Cat() { Name = "Sue", Sex = 'F', Weight = 7.5f };

            session.Save(cat);

            tx.Commit();

            IQuery query = session.CreateQuery("select c from Cat as c where c.Sex = :sex");

            query.SetCharacter("sex", 'M');

            foreach (Cat kitty in query.Enumerable())
                System.Console.Out.WriteLine("Male Cat: " + kitty.Name);

            session.Close();

            System.Console.ReadLine();
        }

Running the console application inserts this data in the database:

The example is simple. Now I have an updated running example using NHibernate 2.0, I’m planning to update my AjGenesis templates for NHibernate to use that version.

Angel “Java” Lopez

http://www.ajlopez.com/en

http://twitter.com/ajlopez

May 28, 2009

AjGenesisCF: code generation for .NET Compact Framework

Filed under: .NET, AjGenesis, Code Generation — ajlopez @ 10:29 am

Thanks to Federico Boerr and his team, there is a new version of AjGenesis, rewritten to run using .NET Compact Framework:

http://ajgenesiscf.codeplex.com/

This version uses only the reflection features supported by CF. Then, you don’t have all the original features. As example, the creation of instances using parameters in the constructor is not supported in CF. But you can compile AjGenesis as a .DLL, and invoke it from your program, use templates, tasks and AjBasic. The published code contains a sample program.

More information about the original program at:

http://ajgenesis.codeplex.com
http://ajlopez.wordpress.com/category/ajgenesis/

Angel “Java” Lopez
http://www.ajlopez.com/en
http://twitter.com/ajlopez

April 27, 2009

Presenting AjCat

Filed under: .NET, C Sharp, Programming Languages — ajlopez @ 9:16 am

Some weeks ago, I was working on an interpreter of the Cat language:

The Cat Programming Language

Cat is a functional stack-based programming language inspired by the Joy programming language. The primary differences is that Cat provides a static type system with type inferencing (like ML or Haskell), and a term rewriting macro language extension language called MetaCat.

Cat is a high-level intermediate language translation that can also be used as a stand alone language for simple application development. In this way it occupies a similar niche to PostScript. Cat is also an appropriate language for teaching of basic programming concepts.

If you are not familiar with Cat language, you can learn more at:

Cat Tutorial
Cat Specification
Cat Primitives

I published the code as part of my Code Katas Google code project. It’s named AjCat:

http://code.google.com/p/ajcodekatas/source/browse/#svn/trunk/AjCat

The solution contains three projects:

The implementation is not complete. It’s only support integers, no .NET object support yet, and no graphics primitives.

Running the console program, you can enter and evaluate expressions:

This code is dedicated to Rodolfo Finocchieti (@rodolfof in Twitter) who pointed me to Cat language, a fascinanting idea.

Tests are green:

And good code coverage

Angel “Java” Lopez
http://www.ajlopez.com/
http://twitter.com/ajlopez

April 22, 2009

Introducing AjProcessor (Part 1)

Filed under: .NET, AjMessages, Grid Computing, Windows Communication Foundation — ajlopez @ 7:05 pm

Last month, I was working in AjProcessor code, as part of my code katas Google project:

http://code.google.com/p/ajcodekatas/source/browse#svn/trunk/AjProcessor

The idea is the evolution of some exploratory coding with AjMessages and other examples. I want to have an application, based in message passing, that can be run in a grid of heterogeneus machines. The application could 
be partitioned in steps, and each step could run in the same host machine, or on a another machine. The deployment in machines should be transparent to the writing of the application code.

Some of those goals were reached with AjMessages, but this time, I want a more clear kick off, based on the lesson learnt of my previous attempts.

First, I want to write down some basic ideas, to explain the motivation of the initial code written for AjProcessor. The basic idea, is to have message processors. A message processor is a code that receives a message, and process it.

 

The message has a payload (an arbitrary object, string, anything), and additional properties, with key/value.

Another essential brick in this lego-like application, is the element that publish messages. That is, there is a publisher:

 

An outgoing message could be received by any other code. The same message can be processed by more than one processor:

 

It’s like the publish/subscribe pattern. Another pattern to take into account, is a router-like component. Depending on the message (property, content), it could be send to different targets.

 

Frequently, a component will implement both roles, message processor and message publisher. In order to call plain old .NET objects, it would be nice to have a processor that receives a message, take some part of the message (i.e. the payload), and send it as a parameter to one its methods. The return value could feed a new message.

 

The components can be arranged as a chain, implementing a pipeline to process a message:

 

A more complex arrangement could receive a message, and forward it to different pipelines, according to some property or content in incoming message.

 

(this concept could be mapped to an application in AjMessage, but without the idea of distributed processing). A more interesting idea is to run that kind of pipeline routers in many machines

 

AjProcessor infrastructure is in charge of the serialization/routing/deserialization of messages between host machine. It could be WCF or anything else. The basic idea is to have a pluggable transport.

Well, these are the seed ideas behind the project. In an upcoming post, I’ll explain some of the current code (only few interfaces and classes, now).

Angel “Java” Lopez
http://www.ajlopez.com/en
http://twitter.com/ajlopez

Older Posts »

Blog at WordPress.com.