7 kyu
Refactored Greeting
5,754 of 11,687jhoffner
Description:
The following code could use a bit of object-oriented artistry. While it's a simple method and works just fine as it is, in a larger system it's best to organize methods into classes/objects. (Or, at least, something similar depending on your language)
Refactor the following code so that it belongs to a Person class/object. Each Person instance will have a greet method. The Person instance should be instantiated with a name so that it no longer has to be passed into each greet method call.
Here is how the final refactored code would be used:
var joe = new Person('Joe');
joe.greet('Kate'); // should return 'Hello Kate, my name is Joe'
joe.name // should == 'Joe'
Object-oriented Programming
Refactoring
Similar Kata:
Stats:
Created | Feb 17, 2013 |
Published | Apr 13, 2013 |
Warriors Trained | 17036 |
Total Skips | 1106 |
Total Code Submissions | 39201 |
Total Times Completed | 11687 |
JavaScript Completions | 5754 |
CoffeeScript Completions | 473 |
Ruby Completions | 2458 |
Python Completions | 3310 |
Rust Completions | 127 |
Scala Completions | 6 |
Total Stars | 110 |
% of votes with a positive feedback rating | 91% of 1017 |
Total "Very Satisfied" Votes | 863 |
Total "Somewhat Satisfied" Votes | 130 |
Total "Not Satisfied" Votes | 24 |