I found that I can either pass 8 arguments to a class constructor or just pass the form variable instead.
However, since I am not using everything on the form it seems like it may be bad design?
Also, the objects I do access I would need to provide accessors for.
Does it violate the principles of OOP?
It depends – if you’re using the form as that specific type of form, and “logically” it makes sense that you’re working with the form, then by all means, pass a reference to the form.
It’s just like any other class – If I was going to be accessing elements of an “employee”, I’d write:
Instead of:
The first is very clean and obvious.
However, if the data you’re using is unrelated to the form, it’d be better to encapsulate it into its own class usable by both the form and your class.
If this is the case, I suspect that having a class encapsulating the data is likely a better design… The form could expose a property or method that returns an instance of that class, and pass it into your second class.