Type Safety

As you know, PHP has dynamic type variables which is not type safety. I am not good at such programing language like PHP. So I had used the concept of type safe in XCube.

HTML is just text. Therefore, it’s very powerful that PHP has string type. But, are you happy at integer variables can take string? Other languages have an excellent cast mechanism. Perhaps, it’s enough spec. PHP doesn’t need such casting, but it’s not useful but dangerous.

XCube has property classes for some primitive types. You can use these classes in XCube_ActionForm. And, these classes will be used in XCube_Object so that XCube_Service will handle WSDL well.

I say there is the following structure;

struct student {
  string first_name;
  string last_name;
  int hight;
  int weight;
}

You can write it as the following;

class student {
  var $first_name =& new XCube_StringProperty(“first_name”);
  var $last_name =& new XCube_StringProperty(“last_name”);
  var $hight =& new XCube_IntProperty(“hight”);
  var $weight =& new XCube_IntProperty(“weight”);
}

It is good at fetching requests from user access and XML web service. Especially, in XML web service, WSDL offers structure informations that XCube primitive classes can match with.

When I come back to XCube from my job, I always think that dynamic type variables are not good. Of course, in some parts, PHP is excellent than other languages…

Advertisements
This entry was posted in XOOPS Cube. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s