N-Tier Web Applications using ASP.NET 2.0

11 06 2008

When .NET Framework was first introduced, it provided excellent features that made the construction of ASP.NET applications a breezy experience. Then the next version of .NET Framework (version 2.0) along with SQL Server 2005 builds on the foundation of the previous versions and introduces some new features that can greatly aid in the design and development of N-Tier ASP.NET 2.0 applications.

Introduction

Designing N-Tier client/server architecture is no less complex than developing two-tier architecture, however the N-Tier architecture, produces a far more flexible and scalable client/server environment. In two-tier architecture, the client and the server are the only layers. In this model, both the presentation layer and the middle layer are handled by the client. N-Tier architecture has a presentation layer and three separate layers – a business logic layer and a data access logic layer and a database layer. The next section discusses each of these layers in detail.

Different Layers of an N-Tier application

In a typical N-Tier environment, the client implements the presentation logic (thin client). The business logic and data access logic are implemented on an application server(s) and the data resides on database server(s). N-tier architecture is typically thus defined by the following layers:

  • Presentation Layer: This is a front-end component, which is responsible for providing portable presentation logic. Since the client is freed of application layer tasks, which eliminates the need for powerful client technology. The presentation logic layer consists of standard ASP.NET web forms, ASP pages, documents, and Windows Forms, etc. This layer works with the results/output of the business logic layer and transforms the results into something usable and readable by the end user.
  • Business Logic Layer: Allows users to share and control business logic by isolating it from the other layers of the application. The business layer functions between the presentation layer and data access logic layers, sending the client’s data requests to the database layer through the data access layer.
  • Data Access Logic Layer: Provides access to the database by executing a set of SQL statements or stored procedures. This is where you will write generic methods to interface with your data. For example, you will write a method for creating and opening a SqlConnection object, create a SqlCommand object for executing a stored procedure, etc. As the name suggests, the data access logic layer contains no business rules or data manipulation/transformation logic. It is merely a reusable interface to the database.
  • Database Layer: Made up of a RDBMS database component such as SQL Server that provides the mechanism to store and retrieve data.


Advertisements




Artificial Intelligence with PHP

23 05 2008

Humans have long been fascinated with Artificial Intelligence. Online artificial intelligence, often called bots, are all measured against the mother of all online intelligence, A.L.I.C.E. Standing for “Artificial Linguistic Internet Computer Entity,” A.L.I.C.E is a chat bot developed in the mid 90s that is capable of holding intelligent conversation, and giving relevant answers.

A.L.I.C.E. and variations of her, respond to the language AIML (Artificial Intelligence Markup Language) to get instruction about how to “think.” There are several implementations of this in languages such as Java, Ruby, Perl, Python, etc, including one in PHP called Program E.

Program E
Program E is a platform for running artificial intelligence robots. It is written in PHP and uses MySQL for its backend database. Program E runs bots that are written in Artificial Intelligence Markup Language or AIML.

Paul Rydell was the original author of Program E. It has since been worked on by Anne Kootstra and Icomsec. You can find Program E on Sourceforge

Try to chat with A. L. I. C. E.





Compiled PHP Script

21 05 2008

PHP script are usually naked, but sometimes we need to capsulating out script for security reason or commercial. There is many way to hide our script, we can use Base 64 Encoding combined with Inflate Compression function and other PHP function that can be reversed. This is the only reason why we need to avoid encrypt the code using PHP function. Every encrypted script need to decrypt first before they run. What should we do is just set a tricky scenario to encrypt and or decrypt back.

I’ve try to using compiled PHP script. I use Bambalam PHP EXE Compiler/Embedder, a light and fast compiler to bundling our PHP script including library, CSS, and external file, except image, sound, and other multimedia file.

There is many way to invoking our compiled script. We can put them into CGI or just execute them using PHP shell execution function (read the PHP Documentation).

Web Server PHP EXE Achitecture

We should design a n-Tier PHP application, then assuming we have a web server with PHP, an application server, and a database server. In this case, an application server is used to put our compiled PHP script and external library. Classes wrote in PHP script that we’ve compiled. Some of our class is used to accessing database server and then compiled class script sent back to web server to displaying the result. So here, a web server is used to show user interface.

I think this way is secure enough to hide our PHP script.





Recognize Text & Objects in Graphical Images with PHP

21 05 2008

An OCR with PHP ? it doesn’t sounds very common topic for PHP developers, but Andrey Kucherenko from Ukraine have made a very interesting project to realize the first phpOCR. His classes can recognize text in monochrome graphical images after a training phase. The training phase is necessary to let the class build recognition data structures from images that have known characters. The training data structures are used during the recognition process to attempt to identify text in real images using the corner algorithm.

PHPOCR have win the PHPClasses innovation awards of march 2006, and it shows the power of what could be implemented with PHP5.

Certain types of applications require reading text from documents that are stored as graphical images. That is the case of scanned documents.

An OCR (Optical Character Recognition) tool can be used to recover the original text that is written in scanned documents. These are sophisticated tools that are trained to recognize text in graphical images.

This class provides a base implementation for an OCR tool. It can be trained to learn how to recognize each letter drawn in an image. Then it can be used to recognize longer texts in real documents.