CRM day 999999 - Buildprovider DAL - subsonic dal is not sufficent -

by Tom 22. February 2007 02:57

It's been really busy since my last post, but I can allready tell you that I did not make the deadline.

Instead of using the SubSonic framework, I have been developping my own framework using buildproviders. The subsonic framework seemed to have a few things that were not really natural/flexible enough for me.
My own project is still in development, but I can assure you that I currently only need to implement some finetuning and cleanups. Lack of time is the main issue here.

Just a few hints :

  • The model is built dynamically & based on the database structure and some default templates
  • No mapping code required to start using the objects
  • Inheritance is derived from the database model (some conventions need to be followed)
  • The model supports intellisense
  • DSL-like language with syntax-checking to create queries.
  • The DAL only updates the fields that have changed, so no unnecessary updates
  • The DAL supports updates and deletes using where clauses (like SQL)
  • The DAL uses an SQL-Like syntax, see below !!!

Just to give you another clue, here's a question I got from somebody online (in Dutch).
(The explanation is also in Dutch, but since you can see the code (in bold) you can make your own mind up.)

>Hallo Tom,
>
>Momenteel ben ik bezig met mijn afstudeerproject voor mijn studie  
>Informatica (HBO NL).
>Het afstudeerproject gaat over het maken van een DSL in JRuby/Ruby,
>het  zelfde onderwerp waar jij in 2005 een topic over opende bij
>tweakers.net.
>(http://gathering.tweakers.net/forum/list_messages/1047491///dsl%2Cruby)
>Ik vroeg mij af of je er nog verder mee bent gegaan en wat je
>ervaringen  hierbij zijn.
>
>Alle suggesties, tips en hints zijn welkom.
>
>Ik hoop snel wat van je te horen.
>
>
>Met vriendelijke groet,
>
>Arjan Blom


And my response to it :

Hey Arjan,Sorry dat ik zo laat reply, maar mijn hotmail-adres controleer ik maar sporadisch eens.

Uiteindelijk heb ik voor dat project een simpele DAL icm c# gebruikt, aangezien een DSL niet haalbaar was binnen het gestelde budget en de termijn.

Momenteel ben ik voor een ander project de route van c# verder aan het volgen, maar het gaat eigenlijk niet echt meer om een DSL, eerder een soort van automatisch gegenereerde DAL/objectlayer .
Een voorbeeld :List<Person> l = Model.Person.Fetch(Db.Person.Name.Like("Arj*").And(Db.Person.DateOfBirth > #1/1/1980#));
Console.WriteLine(l.Count);
Person p = l[0];
Console.WriteLine(p.Address.City.Name);
p.Status = PersonStatus.Fetch(db.PersonStatus.Name="VIP");

Je kan makkelijk de functionaliteit van de classes uitbreiden, omdat ze partial & afgeleid zijn :
class Model
{
   public partial class Person : _Person
   {
      public override void Save()
      {
         if (DateOfBirth == null)
           throw new Exception("Date of birth is not set");
         base.Save();
      }
   }
}
En dan : 

p = new Person(); // bewaart automatisch de oude
p.FirstName = "Tom";
p.LastName = "Janssens";
p.Save();  // throws error : Date of birth not set

Het speciale aan dit model is dat het dynamisch gegenereerd wordt aan de hand van een database die volgens bepaalde regels opgebouwd is (dmv een buildprovider).
Uit de structuur van de database wordt dan een reeks klassen afgeleid (met inheritance), en deze worden dan middels een DAL opgehaald, alhoewel je deze misschien ook wel een DSL zou kunnen noemen.

Een voorbeeld :

Db.Select(db.Person.FirstName,db.Person.LastName,Invoice.LogicalId)
  .Tables(db.Person,db.Invoice)
  .Where(db.Person.Id == db.Invoice.PersonId)
    .And(db.Invoice.InvoiceDate < DateTime.Now.AddYears(-1)
  .OrderBy(db.Invoice.InvoiceDate)
  .Execute(oledbconnection)

Zoals je ziet benadert dit eerder de sql-syntax dan de c#syntax, terwijl dit wel nog voldoet aan de conventies van c#.

Ik vrees dus dat ik je neit echt verder zal kunnen helpen, maar wens je veel succes met je project.

Mvg,
Tom


Maybe (MAYBE) I'll release it on CodePlex if there are enough people asking the source... :P

Bookmark and Share

Tags:

Development

CRM day 4 : Discovered a new approach

by Tom 28. September 2006 03:42
Yesterday I had some things to do, so I could not really implement the main classes.

Today, I am happy not to have started, since I have discovered Subsonic. (Screencast at http://www.wekeroad.com/actionpackintro.html ).
This is a very nice ASP.Net prototyping framework, that has all the necessary buzzword features implemented. Atlas/AJAX/...
Later this day I will implement my basic data model, and try to extend the generation classes to implement the ActAs.. functionalities...

Basicly the generation will work like this : if the table contains the fields BaseTableName and BaseId, it will autogenerate some specific code.

For example, this should be possible :
Table Comment(id,name,text,basetablename,baseid,createdby,createdon,modifiedby,modifiedon)
Products.Comment


 

Bookmark and Share

Tags:

Development

CRM day 2 : some general stuff

by Tom 26. September 2006 10:10

I have had some other things to do today, but I did find the time to read up on some of my rather basic & rusty knowledge (ASP.Net 2.0 / Atlas / ... )
I am hoping to put together the base classes this evening.

As a simple data mapper I will use ORM.Net because :

  • I am familiar with it
  • It works rather quick & correct for a data mapper
  • It is open source, so it could easily be adapted
  • It does the job for me
  • It implements a very nice query system

Some disadvantages :

  • .Net 1.1, not 2.0, so no generics/partial classes etc
  • Not a real ORM, only data mapper, but since one can define a 1:1 relation, ORM should be quite easy to implement
  • Currently only SQL Server is supported
  • Not a really active userbase

I will keep you all posted about my progress tonight !!!

Bookmark and Share

Tags:

Development

CRM day 1 : Some simple ideas explained

by Tom 25. September 2006 12:55

Today I will not actually program any stuff, but i will layout some basic stuff on paper this blog.

First draft :

I will start from the default object properties :

DefaultObjectProps :

  • id : unique identifier
  • description : text description (for dropdownlists etc)
  • created : date of creation
  • created by : user
  • modified : date of last modification
  • modified by : user

Then the default act_as_props

DefaultActAsProps < DefaultObjectProps

  • Parent (id, type)

ActAsSecured < DefaultActAsProps

  • OwnerUser : user
  • OwnerGroup : group
  • UserRights,GroupRights,AnonymousRights : CRUD bools
  • implements :
    • bool Allow Read (type,int id)
    • bool Allow Write (type,int id)
    • bool Allow Create (type,int id)
    • bool Allow Update (type,int id)

ActAsTree < DefaultActAsProps

ActAsPageable < DefaultActAsProps

ActAsSortable < DefaultActAsProps

ActAsFilterable < DefaultActAsProps

ActAsTaggable < DefaultActAsProps

ActAsSchedule < DefaultActAsProps

ActAsCommentable < DefaultActAsProps

ActAsRule < DefaultActAsProps

ActAsFileContainer < DefaultActAsProps

An object instance can be represented in two ways

  • PresentAsRow : Object row view
  • PresentAsForm : Object Form view

These rowpresenters will be used in a form. The default form view will be modified by the act-as modules

For example :

  • If an object implements ActAsTree, the grid can be modified into a treeview
  • If an object implements ActAsTaggable, each object can be tagged
  • If an object implements ActAsSchedule, the objects can be shown in a calendar view
  • ... 

I hope you get the idea from these examples...

That is it for today... See you again tomorrow...

Bookmark and Share

Tags:

Development

Develop a CRM-app prototype in one (yes ONE) week

by Tom 25. September 2006 07:59
After developing several base implementations of a CRM package I have decided to re implement the full app from top to bottom.
So what is the big deal about it ?

  

I have only a week left to develop a fully functional prototype.

Why ?

I am currently developing a CRM framework for one of my customers (private banking).
While the current framework is working pretty decent, I am very unhappy with the current implementation (fifth already).
Every developer has experienced at least once that building an app from the ground up can be pretty cumbersome, since adding functionalities changes/extends the framework gradually, and some adaptations are pretty ugly to implement in your framework.

Why do you blog about it, and why would I bother ?

For me : some constructive criticism might give me the extra boost I might need.
For you  : you might see me totally miss my deadline, and mock with me.

How will you be able to do this ?

The whole idea around this short time frame is based around the following aspects :
  • Since we have documented all company terminology/procedures/assets etc in a wiki, I will not need to contact my customer for further info.
  • Developing several extensive prototypes (5) gives you a main idea how to do it.
  • I need a really flexible framework that I can sell to other clients as well, so adaptation for other customers will be easy.
  • I work better under pressure :p .
  • Since the initial scope is quite small, technical difficulties are rather obsolete. The big challenge will be in the generalizations etc...

What is the scope ?

Being able to manage contact(group)s/resources/products/activities/campaigns, using security policies etc..
Email/reporting/integration will be considered later....

What is the target platform ?

SQL Server & ASP.Net 2.0 / C# using Atlas

3.2.1 Go !!!!

I have already been working on this for quite a while, but decided to let go the current implementation.
The basic idea is to start from nothing.

I have had my own "Eureka" moment while driving to one of my customers.
It is actually based upon the act_as_...-modules from RubyOnRails.

The whole idea is using some kind of loosely coupled objects & tables to extend the base functionality from the core objects.
Some possible implementations :
  • ActAsCommentable : by invoking this module the users will be able to add comments to the base object
  • ActAsTaggable : this module will make a base-object taggable. Hierarchies should be possible in a vocabulary
  • ActAsSecured : will (dis)allow CRUD operations
  • ActAsDefaultForm : will create a basic browsable/editable table using some kind of template.
  • ActAsList : will modify a certain field to be represented by a field from another table.
  • ActAsLoggable : self-explanatory
  • ...
This list will probably extend over time... Some people might recognize this stuff as AOP ...

Well, that should be it for the first post. Now I'm off to home, and later this evening I will start with the implementation.

Wish me Luck !!!!





Bookmark and Share

Tags:

Development

About me

Tom Janssens op LinkedIn

Tom Janssens op twitter

Core bvba RSS

My name is Tom Janssens and I am the owner of Core bvba, a software and consultancy company.
I am married to Liesbeth and have 2 sons named Quinten and Matisse.
ICT is both my job and passion.
Next to this my other hobby is actively playing music (mostly guitar), and I am also a lousy poker player.

I am also the founder of the following LinkedIn groups:
BDD Professional
Asp.Net MVC professional

More info about me and my company...