frankcollins3 / fcc-mcsft-cSharp

FreeCodeCamp & Microsoft C# course:
1 stars 0 forks source link

best practices ? [11:26am] #39

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: IP address method that validates range of 0 - 255 for each set of numbers.

error: not an error more of a question about approach and best practices.

microsoft's provided example is a void function, which appears to toggle a globally declared boolean to true for evaluation Screen Shot 2023-09-11 at 11 27 12 AM

my example uses a bool function to evaluate truthiness based on return value of 1 for a locally scoped variable. Screen Shot 2023-09-11 at 11 34 21 AM

I believe somewhere along these learning modules, we encounter an introduction about the following concept: "minding variables so that your security and logical footprint is small". Technically the footprint of using a locally scoped variable is smaller when considering: you can get away with same eval functionality while having the function ONLY have access to that variable.

while the globally defined boolean could be seen as taking up more space than it needs?

proposed approach: keep either use case in your mind as they both work?

frankcollins3 commented 1 year ago

for right now, locally scoped variable it is. check the truthiness based on return value not globally defined flag. Screen Shot 2023-09-11 at 11 42 26 AM [11:43am]