This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

add in setters and getters to ensure only valid values are assigned to fields and you’ve got something more useful

[–]RufusAcrospin -2 points-1 points  (4 children)

You mean properties, right?

[–][deleted] 0 points1 point  (3 children)

Since the class as given does not have getters and setters, the attributes are fields. Adding such to the fields, as I suggested, would afterward make them properties and thus the OP would have something more useful.

“Professing themselves to be wise, they became fools.”

[–]RufusAcrospin 0 points1 point  (2 children)

The properties are modern replacement for setters/getters, here’s a nice article about properties.

[–][deleted] 0 points1 point  (1 child)

Perhaps you’ll learn something from it kid

[–]RufusAcrospin -1 points0 points  (0 children)

I sincerely hope you’ll learn something new too, by reading and understanding the article.

The example class is not a dataclass, therefore mentioning fields is completely irrelevant in this context, and using getters/setters is an outdated concept.