Is mode "rw" ok? Some use "rwd"? Any advantage?
Q2: If i plan to open raf only when file is updated, is the end of constructor the right place to close the raf as code above?
Q2b: Does raf need to be set to null after raf.close()
Q3: Is the writeRecordToFile ok? Instantiating raf again at the beginning and closing it and setting to null when finish.
[Jay]:Your constructor and writeRecordToFile look fairly reasonable. One thing you may want to do is put your file access in a try...finally block with the close and setting to null in the finally block. This way if there is an exception while reading the file, then the file still gets closed.
[Andrew]:You have implied that you want your Data class to be a Singleton, but your implementation has a public constructor. Therefore it is not a Singleton. Personally I think it is better to leave it open like this - that way you could instantiate another instance of Data class for another database table if you needed to. But I would not go calling it a Singleton in your design documentation
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton