The rule of thumb that most people stick with when doing OOP is duplicate code is bad.
The goal is to find data that needs to be grouped, and group it. Find functions that only use that grouped data, and stick them in classes.
For example a query can be an object. I.E.: A database connection (in java)
public class DBconnect
{
private connection Con = null;
public DBconnect(String Ip, int port)
{
this.connection = mkConnection(ip, port);
}
public Object query(String query)
{
return this.connection.ExecQuery(query);
}
}
Then you query specific pre-processing code can be added directly into the query. public String query(String query, String regex)
{
return this.connection.ExecQuery(query).replaceAll(regex, "");
}
Which results in code like DBConnect db = new DBConnect(127.0.0.1, 150);
String[] quereies = { "yada", "yada", yada"};
for(String str: queries)
{
String result = db.query(str, "\\s+");
doDataScience(result);
}
I don't know if this helps. But its a suggestion.P.S.: I've been spending my free nights the past 2 weeks trying to throw together a javascript based data processing engine in java. It should be mostly workable by the weekend. I could throw it on a ShowHN if you'd be interested.