Recommended Program Structure

As a beginner, I came up with some ideas, but I wanted to ask the community about the best way to implement the following program:

It decodes 8 different types of data files. They are all different, but most of them are similar (they contain many similar fields). In addition, there are 3 generations of systems that can generate these files. Each one is slightly different, but generates the same file types.

I need to make a visual application that can be read in any of them, capture the data in the table (using datagridview via datatable at the moment) before plotting the graph on the graph.

There is a bit more, but my question is about the basic structure.

I would like to learn more about how to make the best use of object-oriented methods, if that is good.

I use C # (unless there are recommendations), largely due to my lack of experience and fast development time.

I am currently using one class called "log" which knows what generates / writes the type of open file. It manages reading and exporting in datatable. Then the form can give it a path, wait for it to process the file and request for data display.

Any obvious improvements?

+3
source share
3 answers

As you understand, there is great potential in creating a very elegant OOP application.

- , , - :

1) ,

2) , ( ?),

3) ,

:

1a) Factory pattern: Factory ,

2a) : , , . . , , .

, , , ... , .

, .

, .

UPDATE

Factory - :

Factory f = new Factory();
ILogParser parser = f.GetParser(fileName); // pass the file name so that factory inspects the content and returns appropriate handler
CommonDataStructure data = parser.Parse(fileName); // parse the file and return CommonDataStructure. 
Visualiser v = new Visualiser(form1); // perhaps you want to pass the refernce of your form
v.Visualise(data); // draw pretty stuff now!
0

, - , . , .

, , , , , .

.NET 4.0 .

, ..

0

, , .. , , , , , , .

: http://msdn.microsoft.com/en-us/beginner/bb308750.aspx

, , - .

interface IDecoder
{
    void DecodeTypeA(param1, 2, 3 etc);
    void DecodeTypeB(param1, 2, 3 etc);
}

class FileDecoder : IDecoder
{
   void DecodeTypeA(param1, 2, 3 etc)
   {
      // Some Code Here
   }

   void DecodeTypeB(param1, 2, 3 etc)
   {
      // Some Code Here
   }

}
0

Source: https://habr.com/ru/post/1770887/


All Articles