Wednesday, April 26, 2006

Over Engineering/Under Engineering

Most of the software products are either over-engineered or under-engineered. The design of the solution is either overdone than what it has to be or its underdone so it is not up to the flexibility level required.

In most design discussions, anybody who knows some design patterns immediately peep up and relate the pattern they know to current problem. And suggest using them, even if your requirement is so simple. They say using design patterns will make your design extensible for future. Is this a healthy sign? Not really!

Maybe good when considering the developers in the team had learnt about the design patterns, which help them to make good design or even to implement a good design correctly. But putting the patterns up-front in the design phase often causes over engineering.

Avoid using patterns unless you really need them. KISS. Keeping things simple will help even a newbie to understand your code. If a person is not comfortable with your code, he will start modifying the code in isolation (i.e. modify only the parts he is comfortable to change, and add utility classes / separate functions to do his job, rather understanding the whole piece and adding the code at right place).

Throwing in design patterns early is a costly solution to a non-existent problem. By doing so you waste your resources to implement the pattern with complex code, than concentrating on you business requirement. As an XP practice, always remember don’t do more than what it requires. Don’t spend time in solving anticipated problems of future rather keep the code clean, so it can be implemented if required in future.

Are patterns to be avoided then? No. They have to be used with care and consideration. Similarly patterns examples shown in the books are just reference implementations, we should be comfortable to modify it as we need to keep the design simple at the same time keeping the grammar of the pattern unchanged (to avoid confusion in pattern vocabulary).

Some designers count the number of design patterns used to show the quality of their design! That’s the worst way to measure the quality of design. So beware, over-engineering is an equally dangerous as under-engineering.

Under-engineering is another problem with software development. This happens usually when the developer has no intent to organize his code, or to improve design. All he writes is code, which claims to work right, but still can’t be proven. Working with this code is a nightmare. Enhancement or even maintenance is almost impossible. 

No special knowledge or attention is needed to write this kind of code. It happens automatically as your program evolves. Under-engineering is most commonly seen in practice. This type of code finally becomes a Big Ball of Mud as described by Brain Foote.

Starting with simple design, and re-factoring continuously to improve design & readability of the code helps to achieve a best possible design for a given requirement.

Refactoring to Patterns is a good book to start learning about this paradigm. This book is specially published under signature series signed by Kent Beck, and Martin Fowler
Home Page of the Book: http://www.industriallogic.com/xp/refactoring/

Martin Fowlers link: http://www.martinfowler.com/books.html#r2p

Tuesday, April 25, 2006

Common Programmer Types

An interesting article discusses about the commonly found programmer personalities in software development.

http://www.hacknot.info/hacknot/action/showEntry?eid=81

Friday, April 14, 2006

Googling tips...

Manytimes searing in google is easier task. Sometimes we have to specific in search terms, so we get precisely we want. Google search engine support various options to specify wat you want more accurately.

Say you are looking for ebooks on Java. you can use 'inurl:e-book java' or 'inurl:ebook java', this inurl directive will lisst ony the websites that have the ebook as a part of their url to the page. This kind of hacking is needed when u search for more specific things.
inurl: url consists this word as part of their full url

intitle: words matching in title of pages

allinurl: more words matching in url

site:  example, site:http://www.sun.com will search only within the sun's website

http://www.docdroppers.org/wiki/index.php?title=Google_Hacking_For_Media

Dont use these hacks to download copyrighted material. 

Thursday, March 30, 2006

Rails 1.1

rubyonrails    Ruby on Rails framework update release 1.1 is here.

Refer http://weblog.rubyonrails.org/articles/2006/03/28/rails-1-1-rjs-active-record-respond_to-integration-tests-and-500-other-things
The biggest upgrade in Rails history has finally arrived. Rails 1.1 boasts more than 500 fixes, tweaks, and features from more than 100 contributors. Most of the updates just make everyday life a little smoother, a little rounder, and a little more joyful.

But of course we also have an impressive line of blockbuster features that will make you an even happier programmer. Especially if you’re into Ajax, web services, and strong domain models — and who isn’t these funky days?

The star of our one-one show is RJS: JavaScript written in Ruby. It’s the perfect antidote for your JavaScript blues. The way to get all Ajaxified without leaving the comfort of your beloved Ruby. It’s the brainchild of JavaScript and Ruby mastermind Sam Stephenson and an ode to the dynamic nature of Ruby.

Ruby has a very easy, humane language structure. So the support for writing javascript in ruby language is cool. Try it out yourself.

Wednesday, March 29, 2006

Code Kata

Sometime back I had read about code kata from the blog of Dave, the well-known author of the book "The Pragmatic Programmer Book" & its series. He introduces a set of practice exercises needed to improve our coding skill in any language or even our thinking about a problem in a business domain. They stretch your thinking and coding abilities. Here is an excerpt from his blog.




What’s a Code Kata?


As a group, software developers don’t practice enough. Most of our learning takes place on the job, which means that most of our mistakes get made there as well. Other creative professions practice: artists carry a sketchpad, musicians play technical pieces, poets constantly rewrite works. In karate, where the aim is to learn to spar or fight, most of a student’s time is spent learning and refining basic moves. The more formal of these exercises are called kata.

To help developers get the same benefits from practicing, we’re putting together a series of code kata: simple, artificial exercises which let us experiment and learn without the pressure of a production environment. Our suggestions for doing the kata are:

  • find a place and time where you won’t be interrupted

  • focus on the essential elements of the kata

  • remember to look for feedback for every major decision

  • if it helps, keep a journal of your progress

  • have discussion groups with other developers, but try to have completed the kata first


There are no right or wrong answers in these kata: the benefit comes from the process, not from the result.

Follow the original blog at http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Practices/Kata. So far he has added around 21 code kata.



If you want to discuss kata, there’s a mailing list here, and a wiki here. However, remember that the point of the kata is not arriving at a correct answer. The point is the stuff you learn along the way.

This is not just reading, so spare some time to spend & reap benefits! Also share any of your personal Code Kata with others.

Sunday, March 26, 2006

Minimal Servlet Container

Recently I wrote a demo java program which controls USB devices present in a system, by accepting options as command-line arguments (i.e. runs only in command prompt). I thought of writing a GUI, so the user can easily control it. The immediate option came to my mind, is to use a java swing client. But I am not really comfortable in swing/awt; also I had only limited time to finish it. I don’t want to spend time in aligning fields in UI, rather I thought of developing web-based interface, which I am most comfortable with. 

Okay, but now I have to deploy my war file in the client place to show a demo!

Will they have a tomcat installed in there machine?  How much instructions I have to provide them, so they can self-deploy the application? What I they have problem in deploying?

Wednesday, March 22, 2006

BarCamp @ Chennai

Are u a said to be an technology enthusiasist, wanna share things with the world.. or wanna learn from similar people like you? Attend BarCamp, happening at chennai on April 8th & 9th.

BarCamp Chennai

http://barcamp.org/BarCampChennai

Why named BarCamp? FUBAR is a common military name, often in many demo programs, the immediate class name any body will use, is foo or bar or foobar. That may be the reason for the name BarCamp. if you ask me if there is any FooCamp then? Yes, it has been, but it is expanded to Friends Of O'Reilly, not the one we dicussed above. It was said that O'Reilly invites limited number of geeks to yearly unconference at his place, for FooCamp, but the invite is limited. Some of them wanted to attend but not able to, because they haven't got an invite. Those people started themselves an unconference named BarCamp.

Tuesday, March 14, 2006

JavaScript & DOM

Any web developer must have knowledge of this. In earlier days html are hand-written and site had more java-script decorators. Slowly they were disregarded, the gimmickry effects are considered to be not-so useful, and mostly distracting the user. A plain site with clean navigation flow is considered more useful. Even for data-validation, the java-script which runs at the client is considered risk. So they moved them to server, and preferred server-side validations to client-side validations. Servlets & JSP reduced the developer to directly interact with core html, and often helped to generate dynamic html, and do server-side validations with controller components


A good understanding of DOM model is very much required for any web developer. With Web2.0, an over used term, often meaning to give power to the user, by providing interactive user interface; JavaScript is playing a role again.


JavaScript is most supported client side script, by the browsers. Even though JSP’s support various scripting language under the BSF model, JS is most commonly supported by all.


Where is JavaScript now -- Version 1.5


Upcoming JavaScript 2.0


http://www.quirksmode.org/js/support.html


FireFox1.5 supports JavaScript version 5, but still IE 7 beta just supports JavaScript 1.3, with many browsers in the market, we have to be careful to choose correct version of JS, to reach wider users.


DOM2 is recent specification released, by w3c, hopefully supported by common browsers soon. Best is to stick with DOM0 or DOM level1, based on the functionality you require.

Friday, February 10, 2006

Simplifying AJAX

AJAX: you agree or not it is back with new name. It’s nothing new, it’s the same JavaScript DOM model, and asynchronous request & responses traveling forth and back to update part of the tree. Even JSF is a component model, i.e. each component has a set of stages, in which they will update their part/some other part of components, i.e. a piece in overall is the DOM tree presented to the browser.


AJAX/JavaScript is very much needed to provide rich user interfaces, without having to load activex/applet plug-ins. JavaScript supported by most browsers, would be the light weight way of doing things than running any plug-in with browser.


It’s easy to use ajax in a wrong way causing, complexity in code [not able to trace what is happening where, for a maintenance developer], and un-expected user behavior.


Ajax’s Mistakes...
http://alexbosworth.backpackit.com/pub/67688


To reduce the complexity involved in coding an ajax applications, tools has to be introduced, which makes common utilities available. With JSF, you can create Faces Components which behind-the-scenes uses AJAX to make the components interactive. The ordinary UI developer/programmer can merely use those components, than coding directly with ajax. The hardness of dealing the XMLHttpRequest can be kept alone to components developer.


Dojo, gives you set of JavaScript utilities, which we may need to develop interactive applications, also has templating with support for widgets.


DWR - Direct Web Remoting, allows server side functions/objects to be exposed over for interaction from client-side JavaScript. This engine, acts transparently between the client and the server. It takes the burden of creating asynchronous requests, and getting responses. This seems to be simple, see the overview here. Also refer the java.net article. DWR is certainly worth to give a try.

Thursday, January 05, 2006

Simpler GUI for Jad, The Java Decompiler

Jad is the fastest java decompiler, available open source.. However it doesn’t come with a GUI. It is a command line tool. There are also GUI tools which internally use jad, and then decorate the code and show it in a graphical window.

Instead of going for a GUI tool, it is easier to write a dos-batch file, which will decompile the java class file, and opens them on your favorite text editor, say notepad/textpad.

Here is the script

===jadOpen.bat===
@echo off
jad -o -d%TEMP% %1
"C:\Program Files\TextPad 4\Textpad.exe" %TEMP%.\%~n1.jad
===============

Now associate class files, to open with this bat file by default, using windows program association. So now double clicking a class file will open in textpad with source code.

Thursday, December 08, 2005

Your GMail Account Space as HardDisk

http://www.pcmag.com/article2/0,1895,1854493,00.asp

Read this article, you can mount ur gmail account as a 2GB Hard Disk, and access it just like any other windows hard disk.

Transfer ur files to it, and download it from anywhere, mounting it as hard disk.

Download and install the utility from here.
http://www.viksoe.dk/code/gmail.htm

If u don’t want to mount as hard disk, but still want to use it, try this firefox plugin. (of course u need a firefox browser)
https://addons.mozilla.org/extensions/moreinfo.php?application=firefox&category=Newest&numpg=10&id=1593

Wednesday, November 30, 2005

Searching in vain !!!

I was thinking long to join with some local user communities, so I can learn and contribute. But to my disappointment I am not able to find a local group, i.e. which is based in Chennai, for java or either OOAD.

Through the index of user groups given in java.net site, I was able to find some groups, but still most of them are not-active or either dead already or either not focused on what I was looking for.

Found a user group on Linux, with Madras Institute of Technology (Chennai), luckily alive & kicking.

But still my search for local java user group continues….

Tuesday, November 29, 2005

Searching for UNIX utilities in Windows

UNIX utilities like wc, ps, top, awk, xargs, grep, find are proven to be handy for many data crunching purposes. It helps a lot to manipulate the text information; those who are used to UNIX/Linux environments may feel bad when they turn to windows. Even in my case, I used the telnet sessions to connect over remote UNIX machine, and I am very much used to these utilities to find and gather data. But when I want to do the same work in my windows desktop, I feel helpless.

Those who want to try the shell environment in their windows machine can try the Cygwin. Cygwin is powerful and very raw to handle. Only an UNIX user will be very comfortable with it. In the case you were just looking for the utilities (like ls, grep, top,awk, also little shell support), you can go for UnixUtils project from open source community Source Forge. This provides excellent support for general utilities.

Also try out Windows SFU (Services For UNIX) , the first place winner in Linux annual conference, from Microsoft. Moreover it’s free now! It provides excellent support for shell utilities, also for System management tools like NFS, telnet client/server.

Example:
The following command will examine all Java files located in the directory src and print the 10 files with the highest number of occurrences of a method call to substring:

find src -name ’*.java’ -print |
xargs fgrep -c .substring |
sort -t: -rn -k2 |
head -10

Also try tools from OutWit  [Outwit is a suite of tools based on the Unix tool design principles allowing the processing of Windows application data with sophisticated data manipulation pipelines. The outwit tools offer access to the Windows clipboard, the registry, the event log, relational databases, document properties, and shell links.]

I like the winclip tool, because in command prompt I can use a command like

  • winclip –p | grep ‘Spring’ | cut –d –f2


And I can change the clipboard content, and re-run the command simply, in the shell

Thursday, November 24, 2005

Ruby on Rails

Ruby on Rails


This framework/model is derived from the project of making the site “BaseCamp” in ruby. BaseCamp is project management site, well known to many. It also offers some other self management tools like, BackPack, Tada lists, and others.


Ruby is a framework, very good enough for applications which are basically CRUD. (Web-apps which are basically acts as an interface to Create/Retrieve/Update/Delete)
It is easier to create a site in minutes, and also easier to customize. Maintaining them is also easier.


See the video on
http://www.rubyonrails.com/media/video/rails_take2_with_sound.mov
Or
http://railsmirror.zottmann.org/rails_take2_with_sound.mov

Dynamic/Static Languages

Dynamic/Static Languages

Once it was felt that type-checking is proved to reduce the commonly occurring errors. But now-a-days it is more seen as a culprit for productivity.

Read this:
By Uncle Bob (Robert C Martin) =>  http://www.artima.com/weblogs/viewpost.jsp?thread=4639

But don’t think it will replace the static typing languages; it will better evolve, & static typing languages to co-exist with dynamic.

Virtual Machine supports dynamic languages?
Generally JVM are written for static type-checked languages, are worst at supporting the dynamic languages. We absolutely need a JVM which can support both kinds of languages for portability. ‘Parrot’ is Virtual Machine implementation for dynamic languages (as described, but its still in incubation). There is a long way to come. Meanwhile Sun also promises to include a new byte-code ‘invokedynamic’ in the JVM, for supporting these dynamic languages. Soon will be an environment that supports both of them.

References:

From JOT Magazine:
The (Re) Emergence of Agile Languages and Domain-Oriented Programming

Work At SUN => http://www.tbray.org/ongoing/When/200x/2004/12/08/DynamicJava

From & By Bruce Eckel =>   http://mindview.net/WebLog/log-0025

Friday, November 18, 2005

Rolling on with Ruby along Others

Ruby, the most talked about language in the recent times. What does it offer? I do tried out ruby. It has most of its syntax borrowed for PERL, only the good things form Perl. Handling with data in hashes, is the most toughest thing I tried with Perl, de-referencing and accessing the data types make me sick.

The reason why we come out of main stream language, and try out things in a scripting language is the rapid development times that it offers, the pre-built libraries it offers. The things which we develop in these scripting language are mostly effective tools, which aids in out work. Say in Perl, I tried out to write a script that performs, load test of an web application. All I have to do, is search for pre-built exhaustive libraries (posted by developers around the world), and use them to built it the script that virtually performs a click on a web page, and captures the result, matches with successful response, records the time taken. If have done the same in Java/C++ then the application may be extensible, generic, but it would have taken more time, which costs more than what we can afford for that task.

Python, a nearly same language as like Ruby, boasted as alternative to Perl some years ago. I have no experience with Python, so cant comment more on it. But what I see with Ruby is ease with which can build tools/applications. We should compare only it with similar languages like Perl, groovy, python. Don't compare it with Java, because in mean terms it would see like that Ruby positions itself better, but Java gives huge options to developer, if properly chosen the options, then that project would be success. The problem is more with not choosing right option. The kind of options/flexibility Java offers is required for any project which sees itself for re-use/longer life-cycle. Maintenance/extension would be easier in Java, remember only if properly designed/ used the features pragmatically. But the scripts we write in Perl, are mostly have small life-cycles, the context they serve is smaller. Or to tell in the other way, we write them that way, which solves our current problems, rather focusing on reusability. It is not that we wont be able to design re-usable things with them, but again the time we take to design it such a way, would add up the cost. That overshoots the need of the hour.

Why these much of languages? Take Groovy, Python, Tcl, Perl, Ruby... I feel all these languages fight in a category that they a life-savers boats, not a huge posh ship. Each serve their own purposes. Will Ruby replace java, this is the question that is asked since Ruby on Rails framework has been released. My sincere thoughts are they wont. Ruby eases writing small tools which serves the purpose of the hour, Ruby on Rails may ease development of small web-applications, but not what Java does. Java is like meeting all needs, only u have to choose what u need. Choose a framework suit ur needs, if u don't need EJB, use a alternative for it. Don't choose because it offers. This not true only for choosing the apis/frameworks/technology while building an Java application. It is even true when u decide what language to use, Java/Ruby?

Ruby is a really a great contender for the category of building need of the hour tools/ applications whose context is small. Competitor to Perl/Python.

References:

Dave thomas Interview on Code Genration: talks abt using ruby in code genartion taks.
http://www.codegeneration.net/tiki-read_article.php?articleId=9

Talks abt Context, helpful in understanding about them
http://www.jot.fm/issues/issue_2005_09/column4

Michael Yuan's Java Blog: "Is Ruby Replacing Java? – Not So Fast ...
http://www.enterprisej2me.com/blog/java/?postid=145

Recommended Blog Posts