Monday, May 28, 2007

compilation model differences in .net 1.1 and 2.0

here's a good article on the differences of the compilation models in ASP.NET 1.1 and 2.0, for those wishing to get the debugging database in 2.0 this article also explores that and tells how it can be achieved, debugging database (.PDB) are useful for getting information like like numbers and other information in a stack dump whenever the code breaks

http://odetocode.com/Blogs/scott/archive/2005/11/15/2464.aspx

Thursday, May 24, 2007

Object orientation in javascript

In almost ever project I have been involved this is the case with javascript, its only used for validation checks and small time jobs etc by making a js library and writing procedural code.

in most large forms, java script methods keep growing and eventually you cant figure out if they are being actually used somewhere for what purpose or just junk code.

Here’s a link to 3 articles that hope to eliminate the issue by implementing client side functionality in classes similar to object orientation in .NET, and eventually ejecting the JS client framework through ASP.NET server controls

Part 1 : http://www.codeproject.com/aspnet/JsOOP1.asp

Part 2 : http://www.codeproject.com/aspnet/JsOOP2.asp

Part 3 : http://www.codeproject.com/aspnet/JsOOP3.asp

I'd love to get my hands practical on this one!

Wednesday, May 23, 2007

Modelling business objects with Encapsulated saving and retreival logic

As I mentioned in the last post that I will be discussing modelling of business objects ,
recently i had a chance to implement the idea that had been bobbing in my head for a
while.

Most of the previous projects that I have worked on had a seperate layer for business
data containers, and another layer for converting the business data container into sql
based information. In my opinion this is an unnesescary , it increases readibility and
maintainance issues.

classic business storage model

I wanted to encapsulate this logic of retrieving and saving the business data within the
business object itself. For e.g. I have a customer object name Customer, i could set all
the information in the customer object and call the save method... Customer.Save();

In the same tradition, i also made methods for retreive by id, retrieve by condition
methods as well, retrieve by id populates and returns an object of type customer,
whereas by condition returns a customer collection. (I didnt use the delete operations,
they wernt required in my case)

Encapsulating the save logic within the business object makes it easier to access and use
by developers. The Save logic consists of a single stored procedure that is used both for
updating and inserting new records. the logic to check wehther the current record is to be
inserted or updated if it already exists can easily be programmed in the stored procedure
itself.

Retriev by id simply constructs the object based on getting the record and populating the
business data by primary key

This type of modelling has other advantages as well, For e.g the Order object
encapsulates a cart object and cart items object, when Object.Save() is called, the
Cart.Save() is called which in turn calls the CartItem.Save() is called for each item in the
cart saving them one by one.

Another thing to keep in mind with a broader vision is that not all items are independant,
and you might want to implement transactions. If the items independantly implement their
own save methods this creates a problem.

Addressing this issue requires that all the classes that need to be saved in a transaction
should have a connection and a transaction members to assign them the connection and
the transaction object being used externally. A boolean transactionMode attribute or
property might be helpful as well


proposed business storage model

there are others who have explored this idea, here's a link to peter bells' blog
entryhttp://www.pbell.com/index.cfm/2006/10/20/Objects-or-Services--how-do-you-desi
gn-your-model


this is also the thinking behind CLSA.NET framework
http://en.wikipedia.org/wiki/Component-based_Scalable_Logical_Architecture

do post your comments on these thoughts

Thursday, May 17, 2007

Finally free!

At last!, finally after missing the original deadline by quite a large margin, I have managed to complete a small independent system for receiving paypal and google notifications.

currently its undergoing testing, but it has been really exciting to develop it, on recieving the information from paypal / google we can traverse the information and create user accounts and place orders for our system automaticlly, hopefully this will take quite a burden off the operations team.

It was a fun challange to design a generic set of business classes that could satisfy the information needs for our system (we have an ecommerce shopping site) , information returned by google, and information returned by paypal, Although i can still think of a few improvements here and there but for the moment the model will suffice and should be expandable by implementing another checkout system with little modification.

I will post the architecture that I have tried to use for comments from others. Designing a system that is generic enough to be loosely coupled and integrates with the legacy code (by legacy I mean ASP 3 and COM+) has its share of design issues. lets have a look at the model:


Level 1 implementation


Level 2 implementation

There are 2 levels of implementation, the first level implementation requires to deliver the information form our website to paypal and google checkout.

As you can see, the first level implementation consists of an independant .net 2.0 assembly, registered as COM. This assembly consists of all the core business classes and supporting utility classes. This assembly has a set of core classes that accept xml (based on our own schema for information) as input and product respective html button code through a factory method. Along the way while parsing and validating the xml it also populates the business objects that can be used sometime later in the application development lifetime.

The level 2 implementation is concerned with implementing a notification service, that is able to receive notifications from both paypal ipn and google notification API, although a single landing page is possible but it would create a tightly coupled integration and would be difficult to maintain and expand to another checkout provider if it came along.

NotificationListener is a single web app but with 2 entry points, once for the google notification serivice and the other for paypal. These are just simple asp.net 2.0 pages that use the business classes generated earlier in CheckoutProvider.dll.

NotificationListener also implement microsoft enterprise library 3.0, which again i have to say save d a lot of coding effort and debugging, I used it for logging and exception logging. It has a pretty good structure and relatively quite easy to implement

the only place where i couldnt force loose coupling with the legacy application was the data layer, since all the information has to go in the same database as the actual commerce site, I believe that it can be worked out into an independent component with a little effort and its own database. but given the time constraints that wouldnt be possible anytime soon, plus if its written as an independent component there would have to be some sort of middle ware in between to connect it to existing applications.

I'm focusing on designing reusable and maintainable components , I'd love to work on a truly SOA based application but not quite there yet, but this is a start anyway... would love to hear comments about it.

In my next post i'll also discuss an idea that I have implemented in this implementation, about implementing the save/retrieve logic right inside the business entity object... this approach has a number of flaws which I'll comment on later...