Been reading a bit on TDD recently and for some reason it has caught my attention. This is not something i have done ever in my kind of short carrier in IT :). But its a new concept for me and i kind of like how it looks at software developement. Hence it got my attetion.
What TDD specifies is you write your unit test class first. You define the classes you may need. Of course at first your test will throwa Class not found exception when you run the test. But this is what TDD is all about. You write the minimal code required to get the test parsing. So what you do first afte running the test is you go create the implimentation class so that the test will compile and pass. And so and so forth you add functionality little by little and improve your design as you go foward. You always only implement the functionality you need to pass your test so it will help you save time and get a much cleaner code because you will be refactoring your code as you do your development and test it as well in the process. Not only will you end up with a nice looking code base, but it will be a well tested code base with much more code coverage.
Ofcourse we know that most of the times we are dealing with database code within our codebase. But not to worry. EasyMock to the rescue. This framwork (http://easymock.org/) is able to mimick your database depenedent code, more specifically you DAO classes and is able to mock it so you do not need to create database connections within your test classes(which is a bad practice by it sef becaus then you will leave your database in an inconsistent state after running your tests). But one change or more over if your developing a component from scratch to note is you need to implement a setter method or constructor to swap in your DAO implementations at runtime so that we can swap in our mock implementation as we run the test to tell the code base to use our mock implementation at the time of running the JUnit tests. More info on how to configure EasyMock can be found in the below locations;
http://www.ibm.com/developerworks/java/library/j-easymock.html
http://www.michaelminella.com/testing/unit-testing-with-junit-and-easymock.html
http://www.realsolve.co.uk/site/tech/easymock.php
TDD is pretty cool IMHO. Im gonna be trying it in my future development and see how it scales. If any of your are already using this methedlogy please share your comments. Would like to know all your views.
Until my next post its adios from me again!!!!
Cheers
Saturday, September 5, 2009
Thursday, September 3, 2009
Terminator. A must have tool for developers on linux
Pretty awesome tool which is able to open multiple command lines in one terminal. It increases productivity at least in a very small way and if you are running multiple servers at the same time this is a must have tool.
http://www.ubuntugeek.com/terminator-multiple-gnome-terminals-in-one-window.html
http://www.ubuntugeek.com/terminator-multiple-gnome-terminals-in-one-window.html
Linux Permissions
In linux the way we usually give permissions is by providing the command chmod 777 yourfile. This gives everyone read,write and execution privileges. But there is a better way to give permissions. Its as follows;
chmod u=rx file (Give the owner rx permissions, not w)
chmod go-rwx file (Deny rwx permission for group, others)
chmod g+w file (Give write permission to the group)
chmod a+x file1 file2 (Give execute permission to everybody)
chmod g+rx,o+x file (OK to combine like this with a comma)
Thanks Sanjeewa for the permission related info. One more thing he added was not to use the "cat"
command but to use "less" to view files because when you use "cat" linux puts it in a memory
buffer before displaying it on the screen.
chmod u=rx file (Give the owner rx permissions, not w)
chmod go-rwx file (Deny rwx permission for group, others)
chmod g+w file (Give write permission to the group)
chmod a+x file1 file2 (Give execute permission to everybody)
chmod g+rx,o+x file (OK to combine like this with a comma)
Thanks Sanjeewa for the permission related info. One more thing he added was not to use the "cat"
command but to use "less" to view files because when you use "cat" linux puts it in a memory
buffer before displaying it on the screen.
Singlish Converter
Pretty cool tool to convert English to Sinhala. Have fun;
http://www.ucsc.cmb.ac.lk/ltrl/services/feconverter/t1.html
http://www.ucsc.cmb.ac.lk/ltrl/services/feconverter/t1.html
Connect to other Linux machines with SSH and no password
Check out this link which explains how you can ssh into a machine withouth providing the password.
http://www.go2linux.org/ssh-login-using-no-password
http://www.go2linux.org/ssh-login-using-no-password
A JS Framework for application development
Found a really nice JS Framework to support application development. Can be found at
http://cappuccino.org
Its under LGPL as well. One important note in their site is abt JQuery.
"Cappuccino is not designed for building web sites, or making existing sites more "dynamic". We think these goals are too far removed from those of application development to be served well by a single framework. Projects like Prototype and jQuery are excellent at those tasks, but they are forced by their nature to make compromises which render them ineffective at application development."
http://cappuccino.org
Its under LGPL as well. One important note in their site is abt JQuery.
"Cappuccino is not designed for building web sites, or making existing sites more "dynamic". We think these goals are too far removed from those of application development to be served well by a single framework. Projects like Prototype and jQuery are excellent at those tasks, but they are forced by their nature to make compromises which render them ineffective at application development."
Wednesday, September 2, 2009
Some useful Eclipse Templates
Found an aritcle describing some useful eclipse code templates. One thing which i found pretty useful was putting the isDebugEnabled check when doing debug level logging. The link can be found below;
http://eclipse.dzone.com/articles/useful-eclipse-code-templates
http://eclipse.dzone.com/articles/useful-eclipse-code-templates
Subscribe to:
Posts (Atom)