2009年4月23日星期四

good practice for extend a open source item

In wikipedia, there is a language named "Simple English". Also, a productive program should be written in simple ways.
i want to dump database tables into csv files. i found scriptella etl. you should told it table names and column names in each tables, and it will do the left things for you.
but my csv files should seperated by comma, and no quots. csv with quot will make size *1.3, which is not good. if a comma appears in the content, the format will be broken. so i'd like to replace comma with `. it cannot meet my needs in obviuse ways. so i find it opensource, i should customize it.
csv output is about a "driver" named "csv". since the driver is found in the way of "String fullName = "scriptella.driver."+driverName+".Driver";" there is no config file needed. this is simple and smart. the foolish way is a config file and more foolish ones writes it in xml like what spring guys will do. so i forked a package using csv and make the changes.
And null items shows up as $column_name defaultly, i also forked a PropertiesSubstitutor.java to make it output a empty string. what i found is easy to do than dealing with other open source projects. and the reason should be,
*always public and donnt seal package. if you want be in simple smart way, forget the least permission priciple which fools invented.
* less interface or such things. maybe someone think himself consider problem in high abstraction. but in fact it will always be less abstracted in time of extension work.
* less dependency. it means less forking copy work.
after that, i export the new package into a jar file. and just copy it into lib dir. it works. because the bat file use:"for %%i in (*.jar) do set _SCRIPTELLA_CP=!_SCRIPTELLA_CP!;%%~fi" to include all jar insight.
i donnt know if it is a good way to solve the dump task. but the hack expierence is smooth because of its simply tone of programming.

没有评论:

博客归档

neoedmund's shared items

我的简介

ZIP Code File