Monday, November 26, 2007

Services

I am not sure where did that came from, but I think about system as collection of services [i]. This gives at least three tangible advantages [ii]:
  • Reusability: When you add the functionality as a service in your application, it becomes reusable more than you think. Let's take the easiest example: The Random Number Generator. I wanted a good random number generator, so I searched over the internet for one, and I found this one. It seemed really interesting; depending on the server clock [iii], so I decided I will consume it. I felt the Reusability advantage with I wanted to generate 5 random numbers to be used for retrieving the MCQs, and another 5 numbers for retrieving the True/False questions. I did not have to rewrite the random number generator code for the TF Qs, I just reused it.
  • Single Code File: Later, I noticed that this Random Number Generator can produce repeated values, which is not accepted. I had to modify the code to eliminate redundancy. Because Random Number Generator exists in a single file, I needed to modify this only file.
  • Modifiability: If you checked the article before this one, you should have found the part that talks about: Adding an email field to Students table. So, when I add this field, do you think current stored procedures and / or direct SQL statements will continue working peacefully, or I will just start getting the non lovely debugging page ? Well, if you hate this page; like me, you will do anything to avoid seeing it, and one of those things you can do is using: Services. Let us see, I have implemented the database; without the email field for student, implemented the stored procedure, consumed it in the Student Web service, exposed the service, consumed it in the application, and it is working. When I add the email field, I will need to write a new stored procedure, add a new method to the Student Service, update the Student Service Web reference at the application, and start using the new service immediately leaving the old one running and leaving existing application not affected.
Those are the direct effects I felt immediately when I implemented Web services in the Assessment Management System. Later, we will discover many advantages of presenting our Information Systems as collection of services [iv].

During my previous evaluation of Stored Procedure against Dynamic SQL [v], Performance was not affected by implementing one over the other; so it is up to you to decide the way you will go. Now, we have two stored procedures:
  • Insert Results
  • Insert Passwords
And the following Services:
  • Random Number Generator
  • Student
  • Results
  • Grade
  • MCQ
  • True / False
--
[i] Web services are not Service Oriented Architecture (SOA) despite the fact that Web services are the main SOA enabler. For more discussions about that topic, please contact me.

[ii] Those entries does not include definitions that can be used for scientific research. You know where to get those definitions, but here I am relating my background with the experience I gained from implementing that system.

[iii] Discussions over the internet regarding efficiency of random number generators are widely available. If you are interested in such a topic, you might want to take a look.

[iv] My Master Thesis is entitled: Evaluation of Service Oriented Architecture (SOA) in e-Learning. I think I have designed and implemented enough SOA based applications to feel SOA's effect.

[v] This evaluation was a Performance one; so from performance perspective Stored Procedures and Dynamic SQL is the same at performance. Still the fact remains that; from Security perspective, it is not a recommended practice to include Dynamic SQL Statements in your application. I use a hybrid of both techniques.

No comments: