Ask Your Question
2

What is the most recommended approach to limit the attributes of a class?

asked 2022-01-18 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-09-29 01:00:00 +0000

nofretete gravatar image

The most recommended approach to limit the attributes of a class is to use encapsulation by making the attributes private and providing access to them through getter and setter methods. This approach allows for controlled access to the attributes and enforces data integrity by restricting direct modification of the attributes. Additionally, it allows for easier maintenance and modifications as changes can be made to the internally managed attributes without affecting the external code that uses the getter and setter methods. Overall, encapsulation provides a more secure and maintainable design for classes.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-01-18 11:00:00 +0000

Seen: 12 times

Last updated: Sep 29 '22