Skip to content

Commit

Permalink
Merge 4f7e2ed into 9a73fe5
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Oct 13, 2021
2 parents 9a73fe5 + 4f7e2ed commit 416b81b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
/// </summary>
/// <why>
/// VBA parameters are implicitly ByRef, which differs from modern VB (VB.NET) and most other programming languages which are implicitly ByVal.
/// So, explicitly identifing VBA parameter mechanisms (the ByRef and ByVal modifiers) can help surface potentially unexpected language results.
/// So, explicitly identifying VBA parameter mechanisms (the ByRef and ByVal modifiers) can help surface potentially unexpected language results.
/// The inspection does not flag an implicit parameter mechanism for the last parameter of Property mutators (Let or Set).
/// VBA applies a ByVal parameter mechanism to the last parameter in the absence (or presence!) of a modifier.
/// Exception: UserDefinedType parameters must always be passed as ByRef.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
/// Flags MSForms controls being accessed from outside the UserForm that contains them.
/// </summary>
/// <why>
/// MSForms exposes UserForm controls as public fields; accessing these fields outside the UserForm class breaks encapsulation and needlessly couples code with specific form controls.
/// Consider encapsulating the desired values into their own 'model' class, making event handlers in the form manipulate these 'model' properties, and then the calling code can query this encapsulated state instead of querying form controls.
/// MSForms exposes UserForm controls as public fields; accessing these fields outside the UserForm class breaks encapsulation and couples
/// the application logic with specific form controls rather than the data they hold.
/// For a more object-oriented approach and code that can be unit-tested, consider encapsulating the desired values into their own 'model' class,
/// making event handlers in the form manipulate these 'model' properties, then have the code that displayed the form query this encapsulated state as needed.
/// </why>
/// <example hasResult="true">
/// <module name="Module1" type="Standard Module">
Expand All @@ -28,6 +30,7 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
/// End Sub
/// ]]>
/// </module>
/// </example>
/// <example hasResult="false">
/// <module name="Module1" type="Standard Module">
/// <![CDATA[
Expand All @@ -45,9 +48,9 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
/// </module>
/// <module name="UserForm1" type="UserForm Module">
/// <![CDATA[
/// ' simple solution: embed the model in the form itself, and expose getters for each desired property.
/// ' > pros: simple to implement.
/// ' > cons: view vs model responsibilities are fuzzy.
/// ' simple solution: embed the model in the form itself, expose a getter procedure for each desired property.
/// ' > pros: simple to implement, silences the inspection!
/// ' > cons: view vs model responsibilities are fuzzy, intellisense get bloated, business logic is still coupled with the UI.
/// Option Explicit
///
/// Public Property Get ExportPath() As String
Expand All @@ -60,7 +63,6 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
/// ]]>
/// </module>
/// </example>
/// </example>
/// <example hasResult="false">
/// <module name="Module1" type="Standard Module">
/// <![CDATA[
Expand All @@ -79,7 +81,7 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
/// End Sub
/// ]]>
/// </module>
/// <module name="TestMmodel" type="Class Module">
/// <module name="TestModel" type="Class Module">
/// <![CDATA[
/// Option Explicit
/// Private Type TModel
Expand Down Expand Up @@ -107,15 +109,16 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
/// </module>
/// <module name="UserForm1" type="UserForm Module">
/// <![CDATA[
/// ' thorough solution: encapsulate the model data into its own data type.
/// ' > pros: easily extended, cleanly separates data from presentation concerns.
/// ' > cons: model-view-presenter architecture requires more modules and can feel "overkill" for simpler scenarios.
/// ' MVP solution: encapsulate the model data into its own data type.
/// ' > pros: easily extended, cleanly separates data from presentation concerns; application logic can be tested independently of the form.
/// ' > cons: Model-View-Presenter architecture requires more modules and can feel/be "overkill" for simpler scenarios.
/// Option Explicit
/// Private Type TView
/// Model As TestModel
/// End Type
/// Private This As TView
///
/// '@Description "Gets or sets Model object for this instance."
/// Public Property Get Model() As TestModel
/// Set Model = This.Model
/// End Property
Expand All @@ -125,12 +128,16 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
/// End Property
///
/// Private Sub ExportPathBox_Change()
/// ' the export path has changed; update the model accordingly
/// Model.ExportPath = ExportPathBox.Text
/// End Sub
///
/// Private Sub FileNameBox_Change()
/// ' the file name has changed; update the model accordingly
/// Model.FileName = FileNameBox.Text
/// End Sub
///
/// '...
/// ]]>
/// </module>
/// </example>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
&lt;CodeInspection Name="ExcelUdfNameIsValidCellReferenceInspection" Severity="Warning" InspectionType="CodeQualityIssues" /&gt;
&lt;CodeInspection Name="EmptyMethodInspection" Severity="Warning" InspectionType="CodeQualityIssues" /&gt;
&lt;CodeInspection Name="ImplementedInterfaceMemberInspection" Severity="Suggestion" InspectionType="CodeQualityIssues" /&gt;
&lt;CodeInspection Name="PublicControlFieldAccessInspection" Severity="Hint" InspectionType="CodeQualityIssues" /&gt;
&lt;CodeInspection Name="PublicControlFieldAccessInspection" Severity="Hint" InspectionType="LanguageOpportunities" /&gt;
&lt;/CodeInspections&gt;
&lt;WhitelistedIdentifiers /&gt;
&lt;RunInspectionsOnSuccessfulParse&gt;true&lt;/RunInspectionsOnSuccessfulParse&gt;
Expand Down
2 changes: 2 additions & 0 deletions Rubberduck.CodeAnalysis/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@
InspectionType="CodeQualityIssues" />
<CodeInspection Name="ImplementedInterfaceMemberInspection" Severity="Suggestion"
InspectionType="CodeQualityIssues" />
<CodeInspection Name="PublicControlFieldAccessInspection" Severity="Hint"
InspectionType="LanguageOpportunities" />
</CodeInspections>
<WhitelistedIdentifiers />
<RunInspectionsOnSuccessfulParse>true</RunInspectionsOnSuccessfulParse>
Expand Down

0 comments on commit 416b81b

Please sign in to comment.