-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify S1104: Migrate To LayC - avoid public field (#3238)
- Loading branch information
1 parent
55e10f0
commit 873ad08
Showing
7 changed files
with
110 additions
and
69 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Public class variable fields do not respect the encapsulation principle and has three main disadvantages: | ||
Public fields in public classes do not respect the encapsulation principle and have three main disadvantages: | ||
|
||
|
||
* Additional behavior such as validation cannot be added. | ||
* The internal representation is exposed, and cannot be changed afterwards. | ||
* Member values are subject to change from anywhere in the code and may not meet the programmer's assumptions. | ||
By using private attributes and accessor methods (set and get), unauthorized modifications are prevented. | ||
To prevent unauthorized modifications, private attributes and accessor methods (set and get) should be used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
=== What is the potential impact? | ||
|
||
Public fields can be modified by any part of the code and this can lead to unexpected changes and hard-to-trace bugs. | ||
|
||
Public fields don't hide the implementation details. As a consequence, it is no longer possible to change how the data is stored internally without impacting the client code of the class. | ||
|
||
The code is harder to maintain. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.