Skip to content

Instantly share code, notes, and snippets.

@Tman22
Created May 12, 2016 18:03
Show Gist options
  • Save Tman22/53cef0f31296f8576807291cbc3de59b to your computer and use it in GitHub Desktop.
Save Tman22/53cef0f31296f8576807291cbc3de59b to your computer and use it in GitHub Desktop.
Which of Sandi's rules do you feel like might be the hardest to follow—why?
I believe the 'Only instantiate one object in the controller' would be the most difficult to follow right off the bat. The solution
they used, Facade Pattern, really made a clean controller and added some classes to describe what is going on. Though,
I do think this makes thing unclear for the programmer. If I'm looking in the view and went to the controller, it would
take me a second to realize what was going on. After further review, I decided that I think 'Five line methods' would be difficult
due to complex logic. I think it would start of long and then have to refactor into shorter methods to really get the idea down.
Hello World:
My code: http://exercism.io/submissions/4abfcbf22b1e49bebb2b178421eb32e0
1. http://exercism.io/submissions/3ec19978896d4c9e89f1129aa44669ef
- This responder took a more elegant take then I did. One line instead of the conditional statement I used with 5 lines of code.
Slightly disappointed after seeing how well he used (input || 'Hello'). Would use this in interation 2!
2. http://exercism.io/submissions/bc99897b4c984365bc8fc71c58afb635
- This responder took a similar take with using a conditional. Although he made a variable message inside the conditional
and returned it outside of it. Both very similar, but I lean towards what I did.
3. http://exercism.io/submissions/88edd005371044e8832527d4e7164135
- Responder three used a conditional instead but didn't use and else like 2 and I took. He assessed if(!input) which makes
a lot of sense and actually a very readible way of doing it. Although I still like number one I do prefer this method
over mine.
4. http://exercism.io/submissions/ac974d67de4645ef873b1f46314b5404
-This gent used a one line conditional using a condition ? true : false. Personally I also really like how he did this. It reads
well and does the same thing I did in 5 lines in 2.
5. http://exercism.io/submissions/e7dc41dd1c4244108042bd811896f6ec
-Responder 5 used the same conditional as 4 but used it on one line. Actually really elegant, it reads really well.
Infact this maybe my favorite compared to the first responder. This reads so well that I prefer this implementation.
Leap:
My code:http://exercism.io/submissions/8160d7ea10ff49bf99f4249608fcda41
1. http://exercism.io/submissions/c83ebe358c5e4481aa07c4df6f83a20b
- This responder used a more broken out way of what I did. It's possibly more readible, but I would be curious on the efficiency
between the two. Considering there is more conditionals I would think mine is slightly more efficient, yet less readable.
I guess either one really works because I would wager that is very close to the same.
2. http://exercism.io/submissions/f313e9c16af74eb89ca13f9171a01804
- This responder used a broken out version of what 1 did. I personally like what the first responder did because it was
so readable. This seems a little to broken out.
3. http://exercism.io/submissions/e2ff8b37056048e0b3cf9d94d1ee36a1
- This responder did basically what I did, but used ES6 by using a Class. It's actually pretty neat because I haven't
seen a class done in JS before yet. I really like how this is done, its easy to see that isLeap is a method of Year.
4. http://exercism.io/submissions/3c09e39f5f7b4cd79ac9cacf467688ba
- Eww. I hate what this person did, infact I don't think its readable. I understand that he is using function Year to use his method
but seriously the whole point of making a method is to write your code in there to clean up your function. Only the important
things should go into the function. I really don't like what he did here.
5. http://exercism.io/submissions/01f12cac8ce846b28e207d0ab4af0c67
- This responder nested his conditionals. I personally don't like this way, I have always tried to refrain from nesting.
It just doesn't seem super necessary. I personally like what responder 2 did instead. Maybe it doesn't read as well?
I prefer not to nest, end of that story.
Hamming:
My code: http://exercism.io/submissions/b07cb34bcf6f40529737d270c6e326e4
1. http://exercism.io/submissions/0c9ba900801f42fba6a90e3eb5b7da50
- This responder split arguments before hand? maybe to allow more options? I don't know why he needed to do that. He
also used an else after the possibly throwing the argument which he didn't need. He's already returning out of the function
so he didn't have to have an else statement.
2. http://exercism.io/submissions/fb5e6f8231604578b6971f4098aff0ac
- This person nested a conditional and a for loop which he did so he could have the option if nothing returned throw error.
He is already checking the length and if its not true it goes and throws the error. I think its more readible to check if the length
does not match and then throw the error right then and there.
3. http://exercism.io/submissions/00745cfdfc294a21b125464b0ce6d6c5
- This person wrote a interesting way of writing the method inside the function. Though if Hamming had more methods,
it would be easier to extract that code into a prototype instead of using this.compute which adds clutter to the initial
function.
4.http://exercism.io/submissions/b7b2c670dcb4453c82ae0eb0e8374514
- This responder used a While loop instead of a For, which most people have been using. I haven't used a while loop yet but
I personally like the For loop style. It seems a more readable and I set the index in the beginning.
5. http://exercism.io/submissions/084144eae26d4f6e8c486934926c7845
- This person added another method computePair though it seems like its almost unnecessary? Only because the compute method
will be able to answer that for you. Otherwise he did exactly what I did which I like, though he stated var i = 0 which makes it
global, I did not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment