Tuesday, June 30, 2009

Template Based Design Technique - Part 1

Challenge of scalability, flexibility, performance and decoupling. To tackle few of these challenges, I have developed my own pattern. One of such pattern is Template driven design.

Let us take an example to understand the challenge and then ways to resolve the same. We all are very familiar with Microsoft Word. It provides ways to create a document-using template. Suppose I wish to create my resume, I can use one of the several resume templates it provides to make one for mine. Essentially this process can be depicted in following picture:



Figure 1

In this process “Resume Template” and “Resume” have separate and distinct life cycles. Destruction of “Resume” does not affect “Resume Template”. Similarly destruction of “Resume Template” does not affect “Resume” once it is created.


Now let us take the same argument a bit further. The advance users of MS Word are also aware that they can make template itself. Essentially they can act as Angle for resume creators. So now keeping Template creation facility in view the whole process can be depicted as:



Figure 2

The “Template creator” acts as Angle for resume creators (assuming template creator can not add fields which go beyond imagination of “Template creator”). The benefits of this pattern are very straightforward.

1. If God is imaginative enough he can accommodate all type of fields in his template. We can consider God imagination as Master Template, which gives wisdom to Angles to create Templates (Essentially we need mechanism to add fields in God’s Master Template as GOD can also lean new tricks over time period).
2. God can appoint various Angles (Template Creators) to create templates for specialized purpose.
3. Mortals (Resume creators) can use one of the “Resume Template” and can create various resumes.

So now question arises how to implement same design pattern in an business application which may be web based or not. For simplicity purpose let us assume the application is a web application and again it is again a resume making service.

So from process perspective this application can be depicted as:



Figure 3

This picture shows only simple flow. In real life there should be ways to perform CRUD operations on resume templates as well as on resumes. In truly flexible application even God’s list must be updatable.

So, how to resolve these challenges?

I will prefer step approach. In first step I will go with all knowledgeable God. List of attributes is final; it will remain same for ever. No changes in this list. In programming terms if any change is required in “Master Template” you need a developer.

So God decided that in resume you can have following fields at the most

1. Name
2. Physical Address
3. Telephone Number
4. Education
5. Employment History

So Angles (Template creators) will see following page:



Figure 4

Now template creator creates two templates, which have following values:

First Template

Template Name: Template-1
Template Description: Resume for fresh graduates
Candidate’s Telephone Number: Yes
Candidate’s Education History: Yes
Candidate’s Employment History: No

Second Template

Template Name: Template-2
Template Description: Resume for experienced
Candidate’s Telephone Number: Yes
Candidate’s Education History: Yes
Candidate’s Employment History: Yes

Now a candidate visits our Resume Service application. He sees two pages, which essentially show two templates created so far.



Figure 5



Figure 6

Suppose candidate who is visiting our application is fresh graduate so he fills up resume template for fresh graduate (Template-1) with following values:

Resume Name: FirstResume
Resume Description: Raj’s First Resume
Name: Raj
Physical Address: B-24, Block 13, Sector 86, Delhi 201001
Telephone Number: 987-654-3210
Education History:



Figure 7

When our candidate have looked at his resume he sees following:



Figure 8

To realize this application, traditional approach of storing data in RDBMS and creating dynamic HTMLs (using JSP, ASP, PHP, etc) will be quite difficult due to real life complexities of Master template and templates.

So what is the answer??

I will cover solution of this challenge in my one of future post.

Saturday, June 27, 2009

One measure for a Service

Customer view the interface part of service. But from architecture and design perspective apart from interface quality of code is very important. Keeping in mind this picture I have developed one measure:

Quality of Code (in percentage) =100* (Volume of code implementing business logic of service)/ (total volume of code for service)

Here the basic question arises how to measure volume of code. The traditional approach is LoC. But in OO world this is one of the biggest problems.

The measure, Quality of Code is not measure of Quality of service but one of the several measure which gives indication on frameworks used to realize a service. In ideal case the peripheral code to create a service should come from the framework/platform.

Friday, June 19, 2009

Parameter

In this article I am trying to comprehend information available about parameters in the wild.

Let’s try to define what parameter is:

Parameter is a software construct whose value decides behavior of a software component/system

Now the next question arises then what is property. In my point of view property is again a parameter (here it is not class property from object oriented world). The word property got its prominence from Java property files which essentially store key value pair in ASCII file.

No we have clear understanding of parameter. Let’s try to understand what are the various attributes attached to a parameter.

1. Data type
a. Simple (primitive – like integer, character, etc)
b. Complex (like an object type in object oriented world, tree structure in XML world)
c. Binary ( e.g. image, audio, video, etc)
2. Value
a. Key Value (x = 10)
b. Key Values ( x = 10, 15, 20)
3. Default Value/s
4. Group it belong to
5. Location in hierarchy ( say Corporate, Regional, branch, etc)
6. Over riding in hierarchy ( say Corporate value of a parameter takes precedence over Regional)
7. Status in life cycle (active, suspend, deleted, marked to be deleted, mark to be suspended, marked for deleted, etc)
8. Effective from ( date and time)
9. In effective from (date & time)
10. To what state of SDLC it belong – design time, test time, complete time, build time, run time, etc)
11. Storage location ( RDBMS, File system, etc)
12. Serializable ( Yes or No)
13. Current value, historical values, future probable values
14. Range of possible values
15. Boundary conditions
16. Who can update it (Role or user)
17. Can it be updated at run time (Yes or No)
18. How to manage changes in parameter value/s if it is under transaction ( changeable at run time or not – both cases)
19. Remarks

Monday, June 15, 2009

SOA Pattern - TestMode

1. Pattern Name
Training Mode
2. Also Known As
N/A
3. Class Name SOA
4. Intent
Even in production environment, it is required to execute a service in testing mode to verify certain facts.
5. Motivation (Forces)
In production environment if some error is occurring which is hard to replicate in testing environment due to lack of proper infrastructure or data?
At the time of deploying a new service in production environment requires assurance due to its importance.
6. Applicability
Service under consideration is composing other services.
Service under consideration has high importance.
7. Structure
N/A
8. Participants
N/A
9. Collaboration
N/A
10. Consequences
1. Increased complexity
2. Ease in testing (especially QoS) in production environment.
11. Implementation
N/A
12. Sample Code
N/A
13. Known Uses
N/A
14. Related Patterns
N/A
15. Reference
N/A

Document at scribd