News for hackers. Stuff that matters.
Re:Ask HN: I am a data analyst and my code is a mess by valarauca1 on Wednesday December 03, 2014 @10:01AM (#8694033)
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.

Re:Ask HN: I am a data analyst and my code is a mess by elliott34 on Wednesday December 03, 2014 @03:01PM (#8696009)
Sure! I'd love to take a look. I've actually written a mysqldb library in python that makes "data objects"

For example mydata=dataobject(query, connectionstring()) mydata.query() # get data mydata.data # pandas data frame mydata.write_to_db() # write to db method

etc.

Sounds similar to what youre doing here, although I don't know Java...