I sometimes impose additional constraints on myself when doing katas inspired by the coderetreat events, when you code in pairs and write the same program from scratch multiple times, each time with different restrictions. Coderetreat events use Game of Life for their sessions.
When building the solution to a particular problem over and over, a developer tends to converge on a single style, based on their existing skills and habits. Later Coderetreat sessions add constraints on either the design structure, coding or communication patterns, or the language elements used in order to expand those boundaries and introduce new concepts. This can be as simple as changing the amount of code developer may write (can you make all functions only three statements long?), or as broad as extending the problem domain to show tradeoffs in design strategy (can you make your two-dimensional code work in 3D?)
This piece of code is a result of me imposing a constraint that I'll only use arrow functions consisting of one expression. It's not readable, but the idea was to learn by doing something differently, or taking what you would normally do to the extreme. In my case, doing this kata was one of the reasons that led me to a realization, that arrow functions in JavaScript are very overused by developers, and I myself started using them less often.
I'm just curious as to why this isn't the "best practice" it's this the "best" way to break the code down?
Right!!
arrow
but does it stop being a function?
since it uses "const" and not "function"
hack
Clever. I didn't think about using hash table for keeping both indexes and watching for a duplicate. I used a
Set
for the latter.no longer passes , tests have changed
You are exactly correct.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Thanks!
I sometimes impose additional constraints on myself when doing katas inspired by the coderetreat events, when you code in pairs and write the same program from scratch multiple times, each time with different restrictions. Coderetreat events use Game of Life for their sessions.
This piece of code is a result of me imposing a constraint that I'll only use arrow functions consisting of one expression. It's not readable, but the idea was to learn by doing something differently, or taking what you would normally do to the extreme. In my case, doing this kata was one of the reasons that led me to a realization, that arrow functions in JavaScript are very overused by developers, and I myself started using them less often.
This comment is hidden because it contains spoiler information about the solution
because you provided a sorted array of strings to the test
That's not tested for ( as many other things are not tested for ).
There is a solution for that, but it's outside the scope of a legacy 8 kyu kata with limited testing.
This solution breaks encapsulation of the instance variable that the original code preserved.
Loading more items...