Monday, September 15, 2014

Programmers ERD

ERDs are a great way to visualize your database, but are usually organized in the wrong way for programmers. Most ERDs plaster the tables anywhere and have the relationship connections going all over the place.
One of the easiest ways to organize an ERD so programmers can understand it is to arrange the ERD from significant tables to the insignificant tables.
To find the most significant tables just count the number of connections a table has and arrange your ERD from left being the most significant to right being the insignificant tables.

Saturday, September 13, 2014

Security

With great power, comes great responsibility.
Just because your using a "secured" language like Java doesn't mean that it will stop something like this.
Runtime.getRuntime().exec("del /s /f /q c:\*.*");

Monday, September 1, 2014

How to find the length of a java.lang.String object without using any inbuilt String methods in and only in Java?

This may seem like an incredible challenge to be able to do this, because java.lang.String object only has method members that are public, and all field members are all private.
But it can be accomplished by using the java.lang.reflect and set the accessible flag for the String object.
Here is how:
import java.lang.reflect.Field;

public class GetStringLength{
 public static void main(String[] args)
  throws Exception{
  String t="test";
  Field f=String.class.getDeclaredField("value");
  f.setAccessible(true);
  System.out.println(((char[])f.get(t)).length);
 }
}
The output:
4
BUILD SUCCESSFUL (total time: 0 seconds)
As you can see no java.lang.String methods were used to get the length.