Friday, August 27, 2010

We were developers

Are you a computer science graduate ?

If so , here is the truth; our education in Egypt don't allow us to be a computer scientist! . i have never had the lecture that supposed to tell you "What Computer Scientists do ?" , it is supposed to be the first lecture in a reputable computer science faculty, any way forget about this lecture.

the software industry in Egypt is as follows:
  1. The Clients:  group of idiots that think you are doing the impossible or some magic for them.
  2. Software house companies:  group of idiots that have some information about the field , well you can say "dummies" not idiots , working without any standards or organized process


i don't mean that there are no reputable software companies in Egypt , there are but few. 

where is the problem? 

most of software engineers become plumbers !!, we used to develop like the plumber , he also used to plumb ! ! , we don't think before we develop . we are not working on the science any more !! , most of us googling all the day for examples !!. 

Another problem , when government created scholarships for any graduate to learn programming , they totally missed up !!!, they are teaching tooooooools not science , so you can hear some one saying "i am studding .Net right now" , what the hell is that !
  
i remembered a discussion between me and a friend , we were talking about MVC , he was telling me that MVC makes websites too slow, and there are some kind of web applications  that cant be implemented  using this design pattern , can you imagine that !!! , we were discussing a topic that was closed in the seventies.

another problem , employers don't know the right qualifications to hire a software engineer , most of the employers  are focusing on the experience  !! , big shit , experience  can be useful , but without science! , you have just hired a new plumber!

i dont mean that learning new tools is not something good, but learning based on knowledge and science is much better

There are hot topics in  science that can be useful to the business , science is created to solve problems , real life problems , guys if we didn't keep up with the science not the tool we will be obsolete and we will say


"WE WERE DEVELOPERS"


Saturday, August 21, 2010

First AJAX Application

Introduction : What Is AJAX

AJAX is very interesting now a days , and a lot of developers want to know what is AJAX , AJAX stands for "Asynchronous JavaScript And XML" which means it is all about Javascript and XML.
Most of people thought that AJAX is a web programming language like PHP , ASP , .. etc. but it is not , whatever the language you are using for your web application , AJAX is totally independent.
we use AJAX when we need to do something asynchronously and don't make the page flashes. Gmail and Google Earth are a good example of AJAX.

What i need to know before i start working with AJAX ?


  1. a web programming language like PHP , ASP , JSP or whatever you want .
  2. JavaScript , and it is actually not a big deal to specify time to learn JavaScript , if you have a small programming background you can learn JavaScript from tracing others code .
  3. XML , also you won't need anytime for XML , for the simplicity sake XML let you express the data using your own tags
  4. DOM : "Document Object Model" , every element in the HTML Page is actually an object of the document , DOM actually is not a different language , you can think of it as a concept


The First Application : Sign Up Using AJAX the HTML Page < span id="Message"> </span> < from action="#" id="SignUpForm" method="POST"> Username :< input id="Form_Username" type="text" value="" /> Email:<input id="Form_Email" type="text" value=""/> Passwoed:<input id="Form_Password" type="password" value="" /> <input id="SignUpButton" onclick="return SignUp();" type="submit" value="Sign Up" /> <form> The goal of the "span" is to use it for printing the messages related to the sign up process. onClick="return SignUp();" will call the javaScript function - we will create it latter- which is responsible to send the request asynchronously The PHP Page
<?php
// SignUp.php
$UserName = $_REQUEST["Form_Username"];
$Password= $_REQUEST["Form_Password"];
$Email=$_REQUEST["Form_Email"]
$Connect= mysql_connect("localhost","root","password");
mysql_select_db("database");
$SQL = "insert into users 
set 
user_name = '$Username',
user_password= '$Password';                                                  
user_email='$Email'; "
$Query = mysql_query($SQL) 
if( mysql_affected_rows() ==1) 

echo "1"; //user added successfully else

echo "0" // //failed

?>
as you see you have to organize your code in a way that only the intended function will respond and print a text that should be displayed Now The JavaScript Part
function XMLHTTPRequest()
{
var xhr=false;
// if running Internet Explorer
if(window.XMLHttpRequest)
{
try
{
xhr= new XMLHttpRequest();
}
catch (e)
{
xhr= false;
}
}
// if running Mozilla or other browsers
else
{
try
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");  
}
catch (e)
{
xhr = false;
}
}
return xhr;
}
function SignUp()
{
var Username=document.getElementById("Form_Username");
var Password=document.getElementById("Form_Password");
var Email=document.getElementById("Form_Email");
var Xml=new XMLHTTPRequest(); 
if (xhr){
var Link=" SignUp.php";
xhr.open("GET",Link,true);
xhr.onreadystatechange = function () { CheckState(xhr);};
xhr.send(null);
}else
return true;
}
function CheckState(xhr)
{
var Message=document.getElementById("Status");
Message.innerHTML="";
if (xhr.readyState == 1)
{
Message.innerHTML="Loading , Please Wait";
}
if (xhr.readyState == 4)
{
if (xhr.status == 200)
{
if(hr.responseText=="1")
Message.innerHTML="User Added";
}
else
{
Message.innerHTML="Error occurred";
}
}
}