Wednesday, June 11, 2008

Dev : What is an abstract class

Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.

Let's look at the following example: Each animal sure has some common actions can be defined in abstract class, but we implement uncommon actions to be implemented in sub class.

public abstract Animal
public void eat(Food food)
// do something with food....
public void sleep(int hours)
// 1000 milliseconds * 60 seconds * 60 minutes * hours
Thread.sleep ( 1000 * 60 * 60 * hours);
catch (InterruptedException ie) { /* ignore */ }
public abstract void makeNoise();

Let's look at a Dog and Cow subclass that extends the Animal class.

public Dog extends Animal
public void makeNoise() { System.out.println ("Bark! Bark!"); }
public Cow extends Animal
public void makeNoise() { System.out.println ("Moo! Moo!"); }

Now you may be wondering why not declare an abstract class as an interface, and have the Dog and Cow implement the interface. Sure you could - but you'd also need to implement the eat and sleep methods. By using abstract classes, you can inherit the implementation of other (non-abstract) methods. You can't do that with interfaces - an interface cannot provide any method implementations.

Sunday, June 01, 2008

Dev : Informix's Logical Log Files 2

I once wrote something on Informix's logical log file issue. After some research online and reading the manual, I can conclude that, for an Informix DBA, most importantly is to frequently monitor the database's logical log file.

As we do an "onstat -l", you might notice something like this:

8cd23475 U------ 1234 1:12345 1000 1000 100.00
8cd23476 U------ 1235 1:23423 1000 1000 100.00
8cd23477 U---C-L 1236 1:65434 1000 750 75.00
8cd23478 U-B---- 1237 1:15543 1000 1000 100.00
8cd23479 U-B---- 1238 1:12553 1000 1000 100.00

Some of the most important thing you might want to see is the "B", "C" and the last number column.

Remember this, the database will stop functioning when the next logical file is not backup. It does not concern whether the next is fill up or not, instead, backed up or not is more important. The last number column will stat the percentage of the logical file being used. So when it reaches 100%, it will move over to the subsequent file.

So, how to determine which logical log file is in use now? Noticed the "C"? It means the current logical log file is being written. For this case, it will continue to write the current, the next, and the next to the next's logical log file. When it reaches back to the 1st logical log file, the database will stop functioning. So, it is better to alway to backup the logical log file, "ontape -a", as often as possible. Maybe once a week?

"B" stands for backup-ed. So meaning that after a backup is being done, you will notice that all the logical log file will have a "B", except for the current logical logfile.

This is what I have understand after reading. I cannot assure that I am 100% correct, but then, hopefully it helps. Happy exploring!

Dev : Java Development Platform Environment

Java is considered as an platform independent development and application, or better known as WORA, which stand for Write Once, Run Anywhere. You can always develope your application on Windows, but run it on Linux, or maybe Solaris, or maybe AIX. As long as you have the correct version of JDK or JRE for that particular platform, any java application will run.

But yet, 1 basic rule for java development, never ever deploy to a platform that you never test your application on. In other words, if your production server is running on Linux, please test your application on Linux environment before moving into the production.

Why did I say so? Because, there are many different mechanism in different platform. For example, if you use your application to execute a Windows command, most probably you won't find that command in Linux. But the worse case is that you might not aware of that when writting the codes. Another fine example is the real path that you might use. You may use "\" in writting real path codes in Windows, but then, unix environment does not recognise this character as a path.

So, remember to test fully on the actual, or more to actual environment before planning moving into production.