This is my submission for the GSFS developer evaluation.
I found that this challenge has a few "code smell" issues.
CalculateOhmValue
returns 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.
bandDColor
argument will not be used in the method body.
- By all appearances,
CalculateOhmValue
should be a static, pure function. But, static classes can't implement interfaces and interfaces can't define static methods. - The existance of
ICalculateOhmValues
is 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.
GetSubItemSummary
doesn't do what it says it does. It returns multiple summaries. In fact, there could be multipleSubItemSummary
objects returned for each sub-item.TransformSubItems
uses the level three items (sub-items of the sub-items) to produce theSubItemSummary
. So theSubItemSummary
contains information from the next level down. DoesTransformSubItems
call 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. TransformSubItems
is 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 callGetSubItems
insideTransformSubItem
? - The parameter
itemNumber
is a string. Since it is not a number, a better name may bekey
orid
. GetSubItemSummary
method could be a static, pure function. Or it could be a method on theItem
object.
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 test
oryarn 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: