dimanche 30 octobre 2016

Redesigning a C# client app which communicates through a serial port with a control unit

I'm writing a c# app which communicates with a control unit over a serial port, and showing data about hardware units(which connected to the control unit) on a windows forms. the app changes their settings, and can record data recieved from them.

the app has many design problems, because I wrote it without much experience. almost all the code is located under the main form, and I'm barely using Object Oriented principles and design patterns. All the code that deals with serial communication, parsing commands, sending commands and a graph that shows data from the hardware units is located inside this form. I even did not make yet a object for the hardware units, im just storing the data on the windows forms controllers(numeric up-down, etc..).

after learning OOP course in the university, I clearly see this app is poorly designed, and I need to redesign it.

The problem is, I have no idea how to sort the code out, because its the first time I deal with this kind of app. Unfortunately, I haven't learned yet how to do a good design for systems. For start, I thought about splitting the serial communication from the main form, so the main form would not have to deal with the communication.

But, this is not sufficient. the app needs to be robust, and well coded. The app is required to:

With those requirements, what design patterns and class hierarchy would you guys recommend for an app like this?

the app needs to:

*communicate with the control unit using an explicit communication protocol, so there is a part that needs to parse the answers from the control unit and understand what to do. it sends requests and wait for response from the control unit. -where should this part be in the hierarchy and with what parts of the system should it interact?

*manage data about some hardware units, show it on the main form, while the data and the settings of the units is received by request from the control unit. -where should the hardware unit objects to be stored? within the main form? singleton class which holds them?

I would be really grateful if you could suggest some good solutions and design ideas that will help me with fixing this application. Even links to the right places with the right information will do much for me.

with much thanks, David

Aucun commentaire:

Enregistrer un commentaire