Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Sunday, June 28, 2009

No If No else Only OOP ;)

While going through the Dzone links , i was happy and amazed to found Anti-IF Campaign . The overall aim of the campaign is to promote OOP usage in place of procedural If's and other conditional programming constructs.This would make you agile and keep complexity under control.

In my current and many of past project , i have seen lots and lots of this happening as this is an easy way for a developer at any level to rationalize behavior using this constructs.But the maintenance hell you get with such crap is huge, even when you are still in System Integration or UAT stage of your project.

To start with applying OOP in your cases ,try to get the abstractions right.This may take some time as this will involve understanding a bit about the domain ,if you already have not.
Another of the best way to get into this mode is refactoring your current code with strong tests under your belt. As i am currently reading Refactoring by Martin Fowler,there is one complete chapter dedicated to removing such rote ,repeating and tangled constructs with delegation and polymorphism .There are other refactorings that talk about putting behaviors in proper classes which again makes this If-else clutter go away and distributes responsibility uniformly across classes.

Hurry!!! Join the Campaign and involve your team.Feel free to share your experiences and thoughts of aligning with Anti-IF Campaign.

Read more...

Sunday, February 01, 2009

Want to begin TDD?

i have joined the Test-driven development yahoo mailing group.Its a great place to see all levels of TDD practitioners out there and their innovative ideas.
One of the thread there mentioned a resource which may help you kickstart the TDD.


TDD Problems
This present programmer with problems that will help them learn and improve their TDD skills.The problem categorization is huge and divided into games,Web related,and many more.
This is worth a check for any TDD practitioners .This will help beginners improvise their skills whereas advanced user to guide their colleagues to follow TDD.

Read more...

Tuesday, October 21, 2008

Loading Jars Dynamically

Post after really long time..from now on ..i ''ll be frequently updating this with random but interesting java posts.
Earlier this week i had a requirement to dynamically load some classes in the current JVM's classpath from some external Jar files.
The way to load classes dynamically from any particular location is to use a java.net.URLClassLoader.
Lets see some code.

//Here u specify the URL for a jar on the file system
String filePath = "jar:file:///" + sysfilePath + "!/";
//Make a URL out of It.
URL url = new URL(filePath);
//Use the ClassLoder to Load that Jar
//You can pass in as many URL you want to the classloader
URLClassLoader clazzLoader = new URLClassLoader(new URL[]{url});


I am thinking to build a fluent interface on this classloader which will allow me to dynamically load more jars as the application goes along.

While researching and googling for this, i upon this JCL.Worth a try.

Do you have any recommendations or alternative approaches?Do comment below.

Read more...

Sociofluid