Timeline for C# Nested If Statements in TDD and Code Metrics
Current License: CC BY-SA 3.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 6, 2013 at 20:10 | vote | accept | Bassam Alugili | ||
| Sep 6, 2013 at 19:28 | comment | added | King King |
This approach is in fact some kind of implicit implementation of enumeration, you should use different added constants, we have to calculate those constants so that any combination (the sum) of the constants is not duplicated with any particular constant.
|
|
| Sep 6, 2013 at 19:22 | comment | added | Sparky | AntP, it is not bad code, it simply encourages encapsulation of the AccessGrantLevel() into a function, rather than a series of individual function calls. The code above focused on determining the parameter and let's the function do the work. I would not suggest it for more complex condition sets, but for small sets like described, it is a reasonable approach.. | |
| Sep 6, 2013 at 19:18 | comment | added | Bassam Alugili | @AntP I will redesign the classes I think this will be best Approach! Thanks this Approach is really not open for extenation | |
| Sep 6, 2013 at 19:17 | comment | added | Ant P | Why would you knowingly post bad code as a suggested resolution to a problem? | |
| Sep 6, 2013 at 19:16 | comment | added | Sparky | I agree, this is an example of one approach, but I put it together more to demonstrate, not to provide actual. | |
| Sep 6, 2013 at 19:12 | comment | added | Ant P | @BassamAlugili It really isn't. This method makes no sense. It works for this particular instance but is totally unmaintainable and unscalable. This is a hack. | |
| Sep 6, 2013 at 19:10 | comment | added | Bassam Alugili | Ant P Enum with a switch is not a bad idea but this will hide the function complexity @Sparky idea is really good! | |
| Sep 6, 2013 at 19:04 | comment | added | Ant P | This methodology has the potential to suddenly break completely if the access level system gets any more complicated. What's wrong with simply mapping levels to an enum and passing that in? | |
| Sep 6, 2013 at 19:00 | comment | added | Bassam Alugili | @ScottChamberlain i will modfiy the code I just want the concept! | |
| Sep 6, 2013 at 19:00 | comment | added | Bassam Alugili | Looking very good open closed principle thanks a lot! | |
| Sep 6, 2013 at 18:59 | comment | added | Scott Chamberlain | That is not good, as someone who is under 18 but is registered will have the same user level as someone who is over 18 but not registered. | |
| Sep 6, 2013 at 18:59 | vote | accept | Bassam Alugili | ||
| Sep 6, 2013 at 19:16 | |||||
| Sep 6, 2013 at 18:57 | history | answered | Sparky | CC BY-SA 3.0 |