CodeAdvocate
Me, My self , My Java, and My Photos
Sunday, 28 November 2010
Steps to apply for your Graduate Degree.
Tuesday, 16 November 2010
A Wish

Wednesday, 3 November 2010
A thought at Midnight
Tuesday, 2 November 2010
How To Judge a Photo
- Light Exposure
- Immediate Impact
- When you should CROP and when you need a SPACE
- Try to avoid shooting art work, don't rely on the value of the art work. The picture should have some addition from your own creativity.
Tuesday, 6 January 2009
Ant in a nutshell for windows (part 1)
Using the ant script, you can make ant do almost everything. This flexibility comes with a price which is complexity. Yet, if you wrote the script well enough, you will be able to maintain it for years.
Installing Ant
- Download the Ant zip file from ant’s web site.
- Extract the zip file in an easy to use folder, let’s say c:\tools\ant.
- Add the ant bin directory, in this case c:/tools/ant/bin, to your system PATH variable.
You can do this by going to control panel / System / Advanced Tab / env. Variables then choose from system variables “PATH” . Now just add your bin directory, separated from the other values by semicolon. - Add the “ANT_HOME” env. Variable [c:/tools/ant] using the “New” button in the env. Variables screen.
- Make sure that the “JAVA_HOME” env. Variable is correctly set to the directory where your JDK is installed.
- Finally, once these steps are complete, you can run ant from the cmd.
Ant –version.
Apache Ant version 1.7.1 compiled on June 27 2008.
Ant basic concepts.
- Ant build files are written in very easy, straight forward XML using a quite readable set of tags.
- Ant build files are used to build one ,and only one project .
- Two basic tags which will make your build file.
-Target
-Task - Targets: Are the goals you want to achieve with your build process, these goals could be, compiling your source code, running your unit tests, and preparing a pre-release version of your project. Usually you define many targets in an ant build file
- Tasks: Let you define the piece of work which you want to get it done. For example, compiling some java source code using javac, or doing you unit testing using junt.
- There are three types of tasks: The core tasks: which are built into ant, and need no special configurations, the optional tasks: which are maintained by the ant team and delivered with ant, like Junit, Third part tasks: which are written and maintained outside the ant project.
- Ant version 1.7.1 is delivered with almost 100 core tasks, and around 50 optional tasks.
A simple ant build file.
- Ant doesn’t force and directory structure , but we are recommended to use the following.
- src directory: where you keep your Application Source Code.
- test directory: where you keep your unit test code.
- lib directory: where you put your project dependencies.
- build directory: where you put Build generated files.
- build/classes directory: will hold your compiled classes.
- build/test-classes directory: will hold your compiled test classes.
- dist directory: any distribution files, your project in jar or war format.
Now we will write a simple ant build file, but first am going to say what this build file does.
1-Create two directories, build and dist directory under you project root.
2-Build your source code.
3-Package you project in a form of a jar file.
4-Delete both the built classes and the dist directory.

- the first target is the init target, which is used to create build/classes, dist directories using the mkdir task and the attribute dir.
- my second target is compile, which as the name indicates it compile my source files. what ant needs to know is if that target depends on any other target, which in this case is true.we have to create the build/classes first before we can compile our classes. for that we used the depends attribute which indicate the compile target dependency on the init target. the task used in this target is javac, which is a straight forward task. I used the srcdir attribute to indicate my source file directory, and used the distdir to indicate where i want my compiled classes to go.
- My third target is package, which packages my compiled classes into one jar file using jar task.
- and finally the clean target, which is used to delete both build and dist directory using the delete task.
what i didn't mention here is the default attribute in the project tag. this attribute indicates the default target to run when using this build file and in this case the default target is "package".
Now, to use this build file.
- open the CMD.
- go to your project root folder (the folder where you keep your scr directory along with the build.xml file).
- type ant in the cmd
- set back and watch :).
you will get something like that.
init:
compile:
package: [jar] Building jar: D:\first\dist\tax-calculator.jar
BUILD SUCCESSFULTotal time: 0 seconds
by default ant looks for build.xml file in the directory where you stand, once it finds the build file and no target name is passed as a parameter, ant will look for the default target to run and in this case "package".
in case you want to run a specififc target, you can pass its name as a parameter for ant, it would look like this
C:>first ant clean
Buildfile: build.xml
clean:
[delete] Deleting directory D:\first\build
[delete] Deleting directory D:\first\dist
BUILD SUCCESSFULTotal time: 0 seconds
I hope this post is helpful. stay tuned for more about ant.
Tuesday, 23 December 2008
Software Development Life Cycle
We ----Software Engineers---- are Beary the bear, always thinks that this is the only way to go down the stairs, because we are always under the pressure of a delivery time, a series of bugs, and to many details.We think that there is no other way to do what we do. We often don't have the time to stop and think that there might be another way.
Surprisingly, there are lots of ways to do what we do and in a much easier way. In this blog I'll start taking about tools in the SDLC process.
First the Build Tools, the build tools are the most fundamental tools in the SDLC process which if used right they become the cornerstones of your SDLC practice.
Stay tuned.
Sunday, 14 December 2008
Just a warm up
As a warm up, something is kinda making me confused. We all know how sophisticated language java is. But I came across something which I believe is a design error.
If I have 2 separate classes in two different packages
package in;
public class Animal {
public Animal() {}//accessible only throw inheritance or throw the dot operator if the accessing class is in the same package
protected void eat(){System.out.println("animal");}}
--------------------------------------------------
package out;
public class Horse extends in.Animal {public Horse() {}/** Override the protected method eat*/
protected void eat(){System.out.println("horse");}}
-------------------------------------
package in;
import out.Horse;
public class BarnHorse{public BarnHorse()
{Animal a=new Horse();//calling polymorphiclly the eat method in the horse class a.eat();}}
the code compiles fine and calls the Horse version of eat and outputs "horse" although the calling class shouldn't know anything about the Horse eat version.
please share your opinion