C#- Best Practices

1) Always prefer to use Properties than fields to embrace Encapsulation, high cohesion and loose coupling.
2) Prefer using readonly members to const members. readonly members values are assigned in runtime whereas const fields values are assigned at compile time.
3) if you can avoid explicit casting always prefer is and as operators. Not only is and as operators are more efficient than using exceptions, they also make code more readable.
4) Always override ToString() method and provide meaningful representation of your classes for their objects.
5)Always override Equals() method for comparing different instances of your class. You can also use Object class’ static ReferenceEquals() and Equals() methods to check reference equality.
6)Override GetHashCode() method when you are using the object as a Key in a collection such as Dictionary.
7) Build your logic with small method calls rather than long, computationally expensive methods on order to take advantage of JIT optimizations.

Php – Recursively scan directories

$path,
‘name’ => end($subdirectories),
‘kind’ => ‘directory’,
‘content’ => scan_directory_recursively($path, $filter));
}elseif(is_file($path))
{
$extension = end(explode(‘.’,end($subdirectories)));
if($filter === FALSE || $filter == $extension)
{
$directory_tree[] = array(
‘path’ => $path,
‘name’ => end($subdirectories),
‘extension’ => $extension,
‘size’ => filesize($path),
‘kind’ => ‘file’);
}
}
}
}
}
closedir($directory_list);
return $directory_tree;
}else{
return FALSE;
}
}

?>