This is my submission for the GSFS developer evaluation.
I found that this challenge has a few "code smell" issues.
CalculateOhmValuereturns anint, so neither the tolerance nor a fractional component values can be returned. Therefore:- There are valid inputs for the first 3 bands which which will produce invalid output.
bandDColorargument will not be used in the method body.
- By all appearances,
CalculateOhmValueshould be a static, pure function. But, static classes can't implement interfaces and interfaces can't define static methods. - The existance of
ICalculateOhmValuesis suspect.- I would not expect multiple implementations of the interface. There is only a single way to calculate the color codes. Multiple implementations would only increase the chance of errors.
- I can't see building a service that satified the interface (ala Dependency Injection). That service would not have a need for state. A simple utlity library would be much better.
So for this challenge, I created a utility library for calculating resistor value (ohms) from the color bands. I included a class that implements ICalculateOhmValues using the library.
- Open ElectronicColorCode\ElectronicColorCode.sln in VS2019
- Build and Run either ElectronicColorCode.Sample or ElectronicColorCode.Test
This is included in the solution with Challenge One.
- Open ElectronicColorCode\ElectronicColorCode.sln in VS2019
- Build and Run ElectronicColorCode.Test
I found that this challenge also has several "code smell" issues. Those issue plus a lack of context made it difficult to understand how this method might fit in a larger application or even be certain what it's supposed to return.
GetSubItemSummarydoesn't do what it says it does. It returns multiple summaries. In fact, there could be multipleSubItemSummaryobjects returned for each sub-item.TransformSubItemsuses the level three items (sub-items of the sub-items) to produce theSubItemSummary. So theSubItemSummarycontains information from the next level down. DoesTransformSubItemscall itself recursively?- There are two methods named
GetSubItems. One on this class and another on the Item class. These almost certainly do the same thing. TransformSubItemsis not a good name. How does it transfor the SubItems? A more descriptive name would be better.- What's the purpose of the second argument on
TransformSubItems? Would it not be better to callGetSubItemsinsideTransformSubItem? - The parameter
itemNumberis a string. Since it is not a number, a better name may bekeyorid. GetSubItemSummarymethod could be a static, pure function. Or it could be a method on theItemobject.
So, I guess that that GetItemSummary returns a flattened array of SubItemSummary objects from a hiearchy of Item objects. The name SubItemSummary implies that TransformSubItems returns a summary the item passed.
Based on this interpretation, my aternative implemenation attempts to be more clear and self-documenting.
- Open SubItemSummary\SubItemSummary.sln in VS2019
- Build and Run SubItemSummary
- Ensure Node.JS 14 or later is installed
- Open a console to SimpleParser\
- Execute either
npm testoryarn test
My best work is proprietary. I can demostration some of it confidentially over Zoom. Here are a few of my most notable public items.
hash-anything is an npm library for object caching and comparisons.
https://github.com/ben-page/hash-anything
And here are two of my most notable Stack Overflow answers: