A program is a sequence of instruction codes. It is executed according to the sequence of instructions. In the realm of software development, programs are developed to provide certain degree of automation for an application. The ability of the application software to solve problems lies heavily on the logic of the program which I will describe as the “reasoning provider” of a program or application. Logic gives an application the ability to reason. The more advanced the logic, the greater the reasoning power of the application and the more the degree of automation. There is no ready-made logic for solving all problems. The development of the correct logic is a function of the IQ and experience of the programmer which determine his ability to meet the challenges of developing the right logic. However, tools like program flowchart and UML could assist in developing the algorithm and by extension, the logic of a program.
Tasks like signing up and signing in on the web can be used to demonstrate the artificial reasoning by a program or script. When you sign up and submit your profile, if the username and/or password have been used by someone else, the script would deny you signing up. How did the program know that the username and/or password exist? It is through the reasoning power of the program given by the logic which ensures that the script searches first for the existence of the username and/or password and then prevents the submission of data into the database upon finding that the username and/or password exist. The same thing goes for signing in into an account. It is through the reasoning power (logic) of the program that the script is able to know whether the username and/or password exist in the database. If the logic is wrong or inadequate, you might find a situation where a user can sign in successfully with a non-existent username or password.
We have seen what logic is all about. It is processed back-end and so site visitor does not see it and he needs not see it but he needs to see some results of logic processing such as login and sign up denial and the reason why. To this end, provision is made in scripts for outputting to the browser custom messages that are quite explanatory to the visitor. Dynamic messages like this and things like text, images, animations, forms, and what have you that enable visitor interact with a web site and browse are what you call presentation. You can create presentation using scripts and static HTML tags. Each scripting language has its own built-in function for creating presentation. For instance-
- JSP- out.println()
- PHP- echo()
- ASP.NET- response.write()
- ASP- response.write()
With these functions when used in web pages, you can create forms, tables, custom messages which visitors can interact directly with. The appropriate HTML tags are put inside the bracket according to the specific syntax and create presentation the way a static HTML web page would. In dynamic web pages, server-side scripts containing logic and these presentation creating functions can be interspersed with static HTML tags like in PHP, JSP, and ASP where you separate the server-side portion from the static HTML portion using special symbols like
Separation of logic and presentation is the key to highly maintainable software. The idea is simple- if the designers intend to change the presentation of the site, no logic should be modified, and if the editors change the content, no change should be reflected in the logic of an application. An effective way of separating logic from presentation is by the use of Server-Side Includes (SSIs) in dynamic web pages. SSIs allow you to insert the content of one file in another web page. By so doing, you can incorporate a single file in multiple web pages or multiple files in a single web page.
In PHP, it is stated as follows- include(‘filename.php’). What you do to separate logic from presentation is to create separate pages for the scripts that contain logic and separate pages for those that create presentation. The logic files and the presentation files will be made to work together with the inclusion of the Server-Side Includes (SSIs) statements in the appropriate positions in a web page which is determined by the order of execution of instructions in the page. For example, a Server-Side Include (SSI) statement containing a logic file can be put in the middle of dynamic web page that is a presentation file and all you will see are the details of codes of the presentation file while the details of the logic file will be elsewhere and the same result will be obtained with when there is no separation of logic from presentation.
However, maintenance is easier when there is separation especially when you are dealing with complex web application. If there is need to amend logic, you can quickly locate the file and changes in the presentation and design of the site will not necessitate changes in the logic scripts.
Olumide Bola holds a bachelors degree of the University of Ibadan, Nigeria and is currently pursuing chartered membership of the Computer Professionals Registration Council of Nigeria (CPN). He is also a member of Nigeria Computer Society (NCS). He has trained scores of people for well over a decade in programming and non-programming courses. He is currently a Software Developer and the Managing Director/CEO of Victolay Technologies Limited. Official web site: http://www.victolaytechnologies.com.