Mike's Technology Blog

Sunday, January 02, 2005

My print_r() implementation for .NET

I notice that print_r() function is missing in .NET, but that's function is very important for debugging your application. So I posted the source code here. I'm open to your suggestions or critiques.

Two MVC frameworks were found today

Actaully, I could have said 'only one' because one of them is for Java and second one is its port for ASP.NET, but let's get down to the business here is the Java one - http://mav.sourceforge.net/ and ASP.NET http://mavnet.sourceforge.net/.

FireFox is getting widespread

I've just had a look at this blog statistics, nearly 50% of the visitors are using FireFox, of course it's because this blog is intendted for web-developers mostly, but it's still surprising.

So what is so special about FireFox? I dunno.......

Creating a PHP-Based Content Management System

As well as usual, I was simply browsing the Net in the morning today and came across something that can interest me and you. This time it was this article - Creating a PHP-Based Content Management System.

It covers some basics of creating a CMS - general plan, some system classes, validation etc. Although I didn't like some things, for example DBConnector class, I would use the Singleton pattern there, plus they don't have a full separation of content and PHP code, that is not good and look like just another Nuke.

But some thing are rally good, for instance their validation class:




class Validator extends SystemComponent {

var $errors; // A variable to store a list of error messages

// Validate something's been entered
// NOTE: Only this method does nothing to prevent SQL injection
// use with addslashes() command
function validateGeneral($theinput,$description = ''){
if (trim($theinput) != "") {
return true;
}else{
$this->errors[] = $description;
return false;
}
}

// Validate text only
function validateTextOnly($theinput,$description = ''){
$result = ereg ("^[A-Za-z0-9\ ]+$", $theinput );
if ($result){
return true;
}else{
$this->errors[] = $description;
return false;
}
}

// Validate text only, no spaces allowed
function validateTextOnlyNoSpaces($theinput,$description = ''){
$result = ereg ("^[A-Za-z0-9]+$", $theinput );
if ($result){
return true;
}else{
$this->errors[] = $description;
return false;
}
}

// Validate email address
function validateEmail($themail,$description = ''){
$result = ereg ("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $themail );
if ($result){
return true;
}else{
$this->errors[] = $description;
return false;
}

}

// Validate numbers only
function validateNumber($theinput,$description = ''){
if (is_numeric($theinput)) {
return true; // The value is numeric, return true
}else{
$this->errors[] = $description; // Value not numeric! Add error description to list of errors
return false; // Return false
}
}

// Validate date
function validateDate($thedate,$description = ''){

if (strtotime($thedate) === -1 || $thedate == '') {
$this->errors[] = $description;
return false;
}else{
return true;
}
}

// Check whether any errors have been found (i.e. validation has returned false)
// since the object was created
function foundErrors() {
if (count($this->errors) > 0){
return true;
}else{
return false;
}
}

// Return a string containing a list of errors found,
// Seperated by a given deliminator
function listErrors($delim = ' '){
return implode($delim,$this->errors);
}

// Manually add something to the list of errors
function addError($description){
$this->errors[] = $description;
}

}


Wednesday, December 29, 2004

.NET naming

Hi!

I was playing with C# a bit, but its variable naming is driving me insane - I have to use capital letters so much, for example, when I want get the value of some text field I have to write the following:



string someValue = someTextBox.Text;



Note the capital letter in 'Text', personally, I love Java accessor:


String someValue = someTextBox.getText();



But guy from Microsoft decided to make coders life 'easier', the invented their own properties that cause this naming confuse:


class Person {
private string name;
public string Name {
get {
return name;
}
set {
name = value;
}
}
}

Wednesday, December 15, 2004

Nice finding...

While going through the SitePoint forums I came across the thing - phpBeans.

I assume you can guess what it is by just looking at their URL, so I don't have to explains that it's yet another attempt to make PHP closer to .....of course, Java.

phpBeans is being discussed here.

Monday, October 25, 2004

PHPlet - a PHP approach To Java Servlet

I was looking thought this thread and found a link that led to the PHPlet project that is a PHP implementation of Java servlet.

Sunday, October 24, 2004

PHP Is Going To Be Different

It looks like PHP isn’t going to be that PHP we’re used to seeing it. I think it’s going to adopt some technology; it will be similar to ASP.NET or Servlet/JSP.

It’s getting closer to ASP.NET owing to such project as WACT and Prado.

As for Servlet/JSP, I think something is going happen here, for example as a language PHP is very close to Java, the only exception is dynamic types of PHP. People use MVC pattern that came from java, they also make DAO components that are very similar to EJB. Then I read this post; these guys want to build a servlet-like container for PHP.
What I think that PHP popularity can be a great advantage of creating some a new server-side technology that can comprises availability of PHP and power of Servlet/Java, I believe that PHP will go to the direction of Java and not .NET according to the next thoughts - .NET is a one platform thing (I don’t consider Mono, because it’s not an officially supported program), while PHP and Java are supported at nearly every platform, then Zend and Sun seem to be very good friends, just read the latest news to understand the fact, so I guess Sun will try to make something PHP based to expand their market of servers-side development tools.

Nice finding of the day...

I was just lurking around the SitePoint forums and I came across this post Any experiences with OpenCMS?, at the first moment I thought that it was apost about yet another *Nuke, but I clicked on the link and found out that it was a Servlet/JSP CMS that besides was open-source that is very catchy.

Got interested? Go here to find out more ;)

EJB? Hmmm......It's easy!

Don't you know what that buzzword mean?

Get to know EJB and its newest specification by reading this!

Saturday, October 23, 2004

NetBeans 4.1 Early Access Was Released Yesterday!

And now it supports EJB...more information

Thursday, October 21, 2004

SItePoint Launches A Java Blog

I've just visited SitePoint and got really surpised when I saw their Java/J2EE blog that was launched today. Seems like they are trying to bring more Java to SitePoint.

The blog is here...