Architecture – In which layer I should implement file parsing

Architectureparsing

in a simple multi layer architecture, in which layer do I have to implement something like parsing file.
For example: I have a file and I have to extract specific information into an object.
I think that this stuff is data access, because the business layer need data. How and where the data come from is not the point. do you agree?

Best Answer

I would recommend to stop thinking in terms of "layers" and start thinking in terms of "modules". Right now, your Data Access layer contains only Database access module. So right next to it, you would put File Access module. This module would be in same layer as Database access module in terms of which modules it can reference and which modules can reference it. But it would probably be separate library, just like Database access module is it's own library (or I strongly hope so).

Even better case would be if you had an abstraction for saving and loading business data. The Data access layer (and its including modules) would then contain implementations of this abstraction. So you would have SaveDataInDatabase, SaveDataInFileX and SaveDataInFileY classes. The business code would then use this abstraction without knowing or caring how the data will be persisted.

Related Topic