I need help figuring this question out. I’ve tried searching and I think I might have found a solution using a Singleton Design pattern, but want to make sure.
I have a Windows forms app I am writing in Visual C#. I am writing a SerialPort class so it can be shared via all the forms (I don’t need multiple serial port instances). This is to separate the logic from the GUI. All forms can make various changes to SerialPort class such as baud rate, write, read, etc.
What is the best way to implement this solution? I’m new to OOP so any recommendations on readings would be great.
Alternative to @Luiggi’s solution, here’s one a bit more thread conscience:
Then, in practice:
More information on this Singleton pattern.