DEV Community

Omar Muhtaseb
Omar Muhtaseb

Posted on

Java Code Review - CSV4J

CSV4J

Hey guys, So I've just finished implementing a new lightweight, dynamic CSV Java library as an opensource project. So I was wondering if anyone here can do me a favor and take a look at this pull request

https://github.com/OmarMuhtaseb/csv4j/pull/1

to review the code and to compare it to the best practices of Java development.
I'm really open to every kind of comments that anyone wanna add, whether it's about documentation or about another perspective how things can be done.

Giving me such reviews and comments will be extremely beneficial for me to help me write better code.

Top comments (3)

Collapse
 
bertilmuth profile image
Bertil Muth

Hi Omar.

I had a look at the README and several things weren't clear to me.

  • Why do you need an CSV ID and CSV values?
  • What are the values in the map defined by @CJMap?

It seems as if you want to implement a CSV writer for a very specific purpose, which I don't know. Why don't you implement a generic one? Have you looked at the solutions out there, or is this a side project for fun? Maybe you can explain a little bit what you want to achieve.
From my understanding of CSVs, I would have expected abstractions like Row or Column instead.

Hope that helps a bit. Maybe there is just a need for further clarification what you want to achieve.

Collapse
 
omarmuhtaseb profile image
Omar Muhtaseb

Thank you very much for checking it out.
So the main reason why we needed this at my last job, is that we came across cases where we didn't know what is the exact structure of the CSV file.

That's because of two main reasons. First, there are known columns they needed to be removed from the CSV file in case they where all null. Second, there are some columns that will be defined in the runtime and we don't know what are their names neither their count.

We did check the popular Java CSV libraries, but we failed to find one that is easy to use and satisfies our needs. That's why I decided to write this lightweight library that I hope it will facilitate the process.

Collapse
 
bertilmuth profile image
Bertil Muth

Hi Omar. I found the root of my confusion. There are some annotations/classes that are provided by your library (e.g. CJIgnore). There are also some classes that are part of the example and need to be provided by the library user (like CJModel).

So you chose pretty abstract and similar names. It would be much more understandable if you picked completely different names for the example, that people can relate to.

For example, you could start like: „Say you‘ve got a list of products, and you want to export them to a CSV file. Each product is exported as a row.“ ...

Then you show the Product class with the the CJ... annotations. Currently, you don’t describe all the annotations- that could be improved as well.

The exported table example should match the code. Currently, you‘ve got one CJModel in the code, but to rows in the table.

Maybe there’s a better example then Product...