Basic question: How can I avoid getters and setters?

I have a class CreateDxf that writes DXF entity codes (line, circle etc) to a text file. Now I want to add dimension entity also.

The dimension entity shall have many parameters, so I want to make it a separate class. Then in my main code, I will create new Dimension objects and store them in a vector. I will provide this vector to the CreateDxf Class function that will output the codes to the text file.

Now I want to know the best method by which this CreateDxf class function can access Dimension class members. I have heard that the use of public methods like getters and setters is not considered a good practise as it violates the principle of encapsulation.

Is there any good way in which I can achieve the above?

Thanks!
Last edited on
I searched the net and got this link. http://stackoverflow.com/questions/9416245/how-to-avoid-getters-and-setters

Apparently it is not evil to use getters and setters. So I think for my purpose I will choose not to provide a setter, but only a getter method.
Last edited on
Topic archived. No new replies allowed.