| M Sheik's profileudooz!PhotosBlogLists | Help |
|
|
December 26 Humax v0.2You may aware that I have released version 0.2 of Humax. In this version, I have implemented the AOP programming support. As of my actual plan, I have planned to implement the following things also: · Asynchronous Programming · Packaging script Though I have implemented the AOP concept two months before, I had no time to write the tutorials, due to my sister marriage. It took two weeks to complete the tutorial section for Humax v0.2. I had planned to provide lot of pictorial representation in the tutorial section, but the time did not allow me further. The version 0.2, by the grace of God, has received massive response. I would like to do benchmarking a web application which uses Humax AOP against normal class-hierarchy model. I invite people to give their positive and negative feedbacks on Humax. The main objective of Humax is yet to achieve, to make Humax as an enterprise web framework in very near feature. I invite people to create new design patterns and best practices based on Humax. With your support, I will try to provide best on Humax. Happy Web. July 31 Humax and JavaScriptI’ve started to think on writing a new framework for client side web development after writing series of articles on JavaScript in Web 2.0. The intention is to break barrier between the client and server side integration. Numerous mature technologies/concepts are available under commercial or GPL to provide seamless integration between JavaScript and server side technology. And of course, these tools have features for developing rich internet applications. The justifications for developing Humax framework are: · A framework which enables you to develop RIA applications in a simple and elegant way. · Minimal learning curve. · Minimal integration means that it simplifies and tries to provide a unified platform for developing web applications. The primary difference I’ve focused are the necessary level of abstraction and programmatic approach as like you are working in .NET and Java form application development. I shall update the roadmap and feedback/feature list later. I was started the development in end-June 2007 and because of the other stuffs in my leisure time did not allow me to release this as early. You can download the version 0.1 beta from http://sourceforge.net/projects/humax Tools of the TradeI would like to share the tools I have used for the development of Humax v0.1. Aptana IDE Though it is not a visual editor, I am using this IDE for writing client side script even for my other works also. The code profile and dynamic type redefinition features of this IDE provide you full-fledged intelli-sense in JavaScript file. The JavaScript file skeleton window enables you to manage and navigate the JavaScript files more easily. It supports JSDoc, provides tooltip syntax for your class and normal HTML/JavaScript elements. What else you want? I do not find any other IDE like this in the case of JavaScript. JSDoc This tool generates javadoc-style documentation from well-formed JavaScript source files. It is my favorite document generation tool for JavaScript and I have used this for Humax API reference documentation. JsUnit and scriptaculous-js I was bit confused which tool I need to use for unit testing. In early days of development, I was used “scriptaculous-js”. It is very simple and does not require more settings to start write and test the “unit test”. And after a while I am also started using JsUnit. May 28 Discipline in Object Orientation – [JavaScript – The Platform for Web 2.0 Part III]As per our "Anything on…" slogan, there are numerous ways we can define properties and methods for a class. This flexibility is more helpful in the implementation of bulky script animation, drag n drop, etc. But for a normal UI validation and business entity manipulation we have to follow a discipline. This will enable us to maintain and enhance a JavaScript code in long-time manner. Firstly, let us see the different ways to define a class. Object DeclarationWay 1See the code snippet 1. function Point(x, y) { this.x = x; this.y = y; this.toString = function(){return "(" + this.x + "," + this.y + ")";} } var point = new Point(10, 5); alert(point.toString()); //shows (10,5) Code Snippet 1 Figure 1 explains the nature of this approach.
A class named "Point" is defined with two properties (x and y) and a method "toString()". All the definitions are bundled within "Point" constructor. But technically, there are two issues with this approach; both make this approach as not optimal:
Way 2As we know that "new" operator in JavaScript enables us to create instance of a class. The function followed by "new" means that it acts as a constructor for the class. The declaration and initialization are happened in the same place as like code snippet 1. Also, JavaScript does the more work. The lifecycle of an object creation is depicted in figure 2.
In figure 2, upto point 3, there is no different between way 1 and way 2. After instantiating Point with "new", JavaScript add an object "prototype" to the instance "point" as property. By default, "prototype" object has a property named "constructor". Whenever, prorotype is initiated, it assigns the corresponding object's constructor function to its "constructor" property. If we define the Point class properties and methods in its prototype object, then it can be sharable. That is, each instance has separate "property" values and share same function point. See code snippet 2. Point = function(x, y) { this.x = x; this.y = y; };
Point.prototype.toString = function() { return "(" + this.x + "," + this.y + ")"; } Code Snippet 2 We can refactor code snippet 2 to create more discipline in the next article. May 21 JavaScript – The Platform for Web 2.0 – Part IIThe next feature in JavaScript nowadays acts a protocol between web client and server. We know that there are two types of web development technologies available in the market.
The first one raises necessary level of abstraction between client and server side processing. Second one mixed with actual HTML page. Both have pros and cons. Most consumers wants the first one because of its abstraction and separation between UI rendering and UI processing. And it allows us to do object-design. Also, it provides more flexibility to interact with business services of a particular application. How do the client and this server side talks with each other? Till pre-Ajax, we did by passing a string of HTML/CSV/Plain text/XML. The more general and gentle approach is XML. But based on customer's SLA (Service Level Agreement), the developers selected the feasible one. In any approach, we need a to and fro converter on both server and client. In server, the result of a process (generally business entities or value objects) is converted to anyone of the above approach. In client, based on the approach we need to write JavaScript code to parse these values. We cannot fully say this approach is MVC's (Model-View-Controller) baby because the OO is missing here. Then now, is there any Ajax implementation to resolve this? Solution is available. But it is not an invention of Ajax. It is a feature of JavaScript. What is that? In JavaScript specification, it is called as object literals. Let us take one example. NJS Shopper is an online application for a grocery shop. After a customer placed list of items and paid online, the system finally shows him what are all items he ordered and price for these. The application server returns these information as a business entity named "OrderDetails". The figure 1 shows the details of this entity. I am not going to explain the business details of the above. Before going further on how can we implement a protocol to speak both server and client in "object" context, let us see what Object Literals is? Object LiteralsWe can create a JavaScript object (again object, not class) using object literals. All the members of an object can be declared as name-value pair with color separated. Each members are separated by commas and enclosed within {} as like arrays. For example, var orderDetails = {orderID:19092, customerName:"Sheik", netAmount:2184.00}; Unlike C++/C#/Java, in JavaScript, we can create an object without any class declaration. One more proof of "Anything can be defined…" slogan. Now think that, instead of passing HTML, XML or plain text from server to client, we can create object literals at server side and send it to client. Then, JavaScript can process the object literals. At server side, we have to write a converter for the above entity to JavaScript object literals. For example, here I've written a very basic server side code snippet for OrderDetails excluding orders field in ASP.NET 2.0. StringBuilder orderDetailsBuilder = new StringBuilder();
orderDetailsBuilder.Append("{"); orderDetailsBuilder.AppendFormat("orderID:'{0}', customerName:'{1}', netAmount:{2}}}", orderDetails.OrderID, orderDetails.CustomerName, orderDetails.NetAmount); Response.Write(orderDetailsBuilder.ToString()); Response.End(); Caution: In .NET, using reflection we can generate object literals more general and in abstract manner. The above code snippet is just for example. The following code snippet shows that how to handle the returned object. var asyncReq = new ActiveXObject("Msxml2.XMLHTTP"); asyncReq.onreadystatechange = function() { if (asyncReq.readyState == 4) { if (asyncReq.status == 200) { var resultString = asyncReq.responseText; var orderDetails = eval("(" + resultString +")"); alert("Customer: " + orderDetails.customerName + " Order ID: " + orderDetails.orderID + " Net Amount: " + orderDetails.netAmount); } } }; asyncReq.open("GET", "Default.aspx?a1=od", true); asyncReq.send(null); In AJAX period, this is called as JSON – JavaScript On Notation, a best protocol for server to client transmission. May 15 JavaScript – Platform for Web 2.0I was excluded JavaScript in the "Web 2.0 basic things" intentionally, because JavaScript is the only choice for every web pages. But most of us know and/or use half the feature of JavaScript. JavaScript has more than these. Lot of frameworks which target Web 2.0 and applications utilize these smart features. I would like to share some of these features which make JavaScript as a platform for Web 2.0 applications. If you know these, please have a look and share your knowledge. Before getting into these, keep the following statement in your mind about JavaScript: "Anything can be defined within the context of anything and assigned it to anything". Confused? Let's take an example, you can define a class from a function and enumerate its properties as array elements. And, you can treat an array as a object, function as data, etc. The following sections briefs about this. Lamda FunctionsLamda functions are unnamed functions which can be assigned to a variable like assigning an expression. This is more or less similar to functional programming style. See the following example: var square = function(x){return x*x;} alert(square(2)); // returns 2 * 2 = 4 Code Snippet 1 The square is actually a variable on which the function reference with the above signature has been assigned. What is the difference between normal named functions and lamda functions? Let us see the below code snippets: var square = function(x){return x*x;}
function twoSquare(square) { return square * 2; } alert(twoSquare(square(3))); // returns 9 * 2 = 18 Code Snippet 2 In the above example, the lamda function "square" is passed as argument to "twoSquare" function as function reference. See the body of "twoSquare". It treats the function "square" as a variable. Also, you can assign or treat lamda function to object property and array element. The developers of "C" family can enjoy this feature. The lamda function simulates the C++ or C# style class declaration when creating a class. See the Code Snippet 3. function Customer(title, firstName) { this.title = title; this.firstName = firstName; this.getName = function(){return this.title + " " + this.firstName.toUpperCase();} }
var amid = new Customer("Mr","Amid"); alert(amid.getName()); // returns Mr AMID Code Snippet 3 In code snippet 3, a class Customer has been defined. In this getName is a lamda function. Remember, getName is variable to the function reference. Let us see other features in succeeding articles. April 30 Things behind Web 2.0Recently, I had read an article about Web 2.0. In this article, the author defined a formula for Web 2.0, which is AJAX + SOA + OSS = Web 2.0 AJAX = Asynchronous JavaScript and XML SOA = Service Oriented Architecture OSS = Open Source Software I am ok with the above formula, except for the open source software bit. Note that I am not against OSS, but inspired by.NET and Java technologies. I agree that OSS provides common ground for everybody to build applications/frameworks in a quick and efficient manner. However, commercial software (closed source software) is not at any point inferior to OSS. Also, they are so reliable and scalable. Okay, that’s a separate story. From my point of view, we should consider the industry standard specifications and technologies. What are the things that make the difference between Web (1.0!) and Web 2.0? Web 2.0 is more about the changes in usability or interactivity of web than technologies, because there is no new technology or protocols for Web 2.0. The paradigm shift happened only due to proper usage XmlHttpRequest and SOAP. Both these have been existing in the field since the late 90s. I have used XmlHttpRequest object for displaying “Please wait…” progress indication message in web sites in the pre-ajax period. In these periods, most of us developed web services with an object-orientation mind set. Examples of differences are:
Additionally, web services make things better and interoperable. Here, I’ve shown my first level basic list of technologies behind Web 2.0.
Surprised? We can use the term AJAX, by XmlHttpRequest with some design models and patterns. Otherwise, people in this ajax world will shoot us. Okay, let us explore more about the first two points before getting into the world AJAX in succeeding articles. April 23 Emerging Web 2.0Hope everybody has seen the term “Rich Internet Application”, simply RIA and Web 2.0 in any of the computing technology web sites. Google initiated the second revolution of web and it has impacted everybody in the computing world. We all know about the dot com revolution in 2000 period. With immature web development technologies and low speed internet connections, the revolution was a major flop and it made everyone to think seriously about web based solutions. Limited Internet consumerism was one more factor. At that time nobody was interested in using the Internet for purposes other than email and surfing. Then ASP (Application Service Provider) arrived. No one was ready to think out of their corporate walls. The technology was one reason for that. At that time, web technologies providers did not think of security beyond encrypted authentication mechanisms. And also, CxOs thought of “Enterprise” aspects only within their UNIX box. Almost all major players closed their web shops and provided only web development products. Their Internet ideas were used within Intranet environment. The Internet backbone technologies have now matured and people are enjoying high-speed broadband Internet connections. After that, technologies piled up in companies with garbage restored and refreshed. Though Yahoo! initiated the actual game, Google has made the biggest impression on this. They successfully converted Internet-challenged software applications into simple and powerful web apps. GMail and Google Map are some examples. Google Search is still surviving as the world’s number one search engine because of its right level of software and hardware combination for their search engine. Microsoft had recognized this area a little bit later and started to think seriously about its Live platform and also how to breathe new life into its Windows and Internet platforms. O’Reilly, in 2004, coined the term “Web 2.0” based on technologies from various players especially Google and Wiki. But some do not agree to the versioning of Web. They argued that Web 2.0 is a buzzword. However most Internet players thought that they need that term to define and organize current emerging technologies under one roof. What is Web 2.0? What does Web 2.0 really mean and what are all the technologies behind Web 2.0? Tim O’Reilly tried to define the term in his article “Web 2.0 - Design Patterns and Business Models for the Next Generation of Software”. The Web 2.0 Expo pointed out some approaches proposed by some web products such as YouOS, G.ho.st, Nokia smart phone widgets and Google PowerPoint. And it also pointed out some technologies such as Vidoop’s new authentication technology and IBM dashboard. But people are still confused about Web 2.0. Everybody agreed that AJAX is the core model (Note that it is a pattern not a technology) for Web 2.0 and broadband Internet connection is the basic backbone for this. Notable other aspects are blogs and web syndication. Other than these, they are seriously listed out technologies from the Non-Microsoft campus. Also, they have provided very small space for Web Services. One pathetic truth is that they have listed PHP for web development and missed out ASP.NET and JSP. I do not know what makes PHP a more serious aspect than the mature ASP.NET and JSP. I’m expecting the role of W3C to define and standardize the Web 2.0 technologies. Personally, I would like to prepare a list of technologies for Web 2.0. If anybody is interested please join me. One condition though - you have to look at both open and proprietary platforms. Cheers! |
|
|