Archive for the ‘whatEver’ Category
Saya telah kena TaG?
Haha nampak gaya saya telah ditag oleh yuni. Tapi saya tak tag orang lain atas sebab2 tertentu. Maka dengan ini; ini adalah rupa terbaru penulis

penulis blog ini
java IOC for starters
I never thought wordpress will be kind enuff to provide syntax highlighting. So i can start posting all the source code that i use to learn new technologies here. I’m still new with this IOC kind of things, so expect only the basic usage of it in this posting. I assume u guys already knew how to setup a eclipse with the spring jar.
1) Create the test case. Because I’m more prone using TDD practices, so the test wil fail at 1st.
package spring;
import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import junit.framework.TestCase;
import log.SpringLog;
public class TestCharacter extends TestCase
{
private static Logger log;
private static ClassPathXmlApplicationContext applicationContext;
private ComicCharacter character;
@Override
protected void setUp() throws Exception
{
log = SpringLog.getLog();
if(applicationContext == null)
{
applicationContext = new ClassPathXmlApplicationContext("ioc.xml");
}
this.character = (ComicCharacter)applicationContext.getBean("comicCharacter");
log.debug(this.character.getName());
}
public void testAttribute()
{
assertNotNull(this.character);
assertEquals(999999, this.character.getHealthPoint());
}
public void testHikmat()
{
assertNotNull(this.character.getHikmat());
assertEquals("tinju maut pendekar laut", this.character.getHikmat().famousAttack());
}
}
This code will only not run but it also will throw a exception. Because we haven’t write any ioc.xml yet.
2) Write the ioc.xml .
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="comicCharacter" class="spring.ComicCharacter">
<property name="healthPoint">
<value>999999</value>
</property>
<property name="hikmat" ref="hikmatPenderkarLaut" />
</bean>
<bean id="hikmatPenderkarLaut" class="spring.HikmatPenderkarLaut">
<property name="famousAttack" value="tinju maut pendekar laut" />
</bean>
</beans>
The ioc.xml will tell the spring to initialize comicCharacter with its healthPoint attribute with value 999999. Then comicCharacter also have a attribute called hikmat (this is an interface actually). Using ioc, we wired this attribute to class HikmatPendekarLaut(this class implement hikmat interface).But when u run the test case, the result will also yield a fail situation(the good news no more spring exception). Because we haven’t write the concrete class for this test case.
3) Write the concreate class to make the test go green (success).
package spring;
public class ComicCharacter
{
private int healthPoint;
private String name;
private Hikmat hikmat;
public int getHealthPoint()
{
return healthPoint;
}
public void setHealthPoint(int healthPoint)
{
this.healthPoint = healthPoint;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Hikmat getHikmat()
{
return hikmat;
}
public void setHikmat(Hikmat hikmat)
{
this.hikmat = hikmat;
}
}
package spring;
public class HikmatPenderkarLaut implements Hikmat
{
private String famousAttack;
public String famousAttack()
{
return this.famousAttack;
}
public void setFamousAttack(String famousAttack)
{
this.famousAttack = famousAttack;
}
}
package spring;
public interface Hikmat
{
String famousAttack();
}
the test case should go green.
masa terluang..yippie
dengan banyak masa utk aku buang. Aku mengambil keputusan utk study balik benda2 basic dalam java. Semalam rasanya aku dah explore serba sedikit basic utk
- exception handling – coz selama nih aku tak effective. Takde letak meaningful message. Terlalu rely on stacktrace. Banyak lagi benda ko leh buat. And camner nak test dalam unit testing.
- Spring – main dengan ioc. Selama nih pun ader configure ioc and guna. Cuma kali nih nak try dari scratch on my own. Bila dah pakai nih macam2 idea datang nak refactor code pakai benda alah nih.
- Log4j – selama nih aku blur sikit pasal maksud logger, appender and layout. Tapi skang dah paham.
- properties file – carik cara menarik supaya properties file leh baca dengan mudah. Contoh cam getSystemResource, senang nak carik file.
compile everthing in ioc.xml
what ever class u declare in the ioc.xml, make sure all the file has been compiled and put it into ur classpath. period.
list dalam java
semalam boring lalu aku bukak buku study pasal syntax java. Maka aku temui beberapa benda menarik
- hanya terima reference sahaja utk disimpan. Maka secara logic aku pk benda yang extend object baru leh sumbat dalam collection
- kalo nak simpan primitive type dalam collection. Anda akan dipaksa menggunakan wrapper class.
- antara primitive dan wrapper class penggunaannya mudah. Operasi antara object dan primitive data type akan menghasilkan autoboxing.
Penah dengar pasal for each loop?? for each memerlukan collection tersebut implement iterator. Kalo tak takleh jalan.
java rebel…say no to restart
my development speed…super slow!!!!
i went back to school this week. Need to learn xhtml + css + javascript + DOM. Somewhat i just skip the css part coz i dun think it is really important. I mainly need to make the web page more responsive and interactive, so basic javascript and DOM was what i really need.
To be frank, i just hate doing coding with this all kind of tag. Its ugly..
pengenalan kepada web programming
ari nih aku start secara serius coding module lama sorang officemate aku. Agak penin kepala gak coz aku memang teruk when it comes to HTML + java script + css. Aku lebih minat pada functionality compare dengan design.
So aku pun bergelumang dengan code senior aku. Nampak laa benda2 pelik yang aku tak kenal selama nih. Nih baru 1st time aku bergelumang secara serius dalam web programming. Ni aper aku baru belajar
contohnya: html onSubmit attribute – biasanya orang akan buat untuk validation. Aku nengok contoh ini.
then kemudian: html onkeypress.
1 day wasted
On friday i already planned to do some TDD exercise, hopefully next week i be able to finish it. But not everything went as i planned. I got high fever yesterday. Spent the whole day just lying around and doing nothing. My body hurt especially my back. What a day..totally wasted.
great..just what i need
all the suddenly, my eclipse ( europa ) failed to start without a reason. Before this it just work. I wonder why.
I took a straightforward solution that was to reinstall it. Its not that troublesome. Just unzip and walaaaa…u got a ready to run ide.




