Given a simple implementation of string calculator, refactoring based on SOLID principles. Implemented in Java and Swift by Jorge Sánchez (Xurxodev)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
C#
Java
Swift
.gitattributes
.gitignore
README.md

README.md

Refactoring-StringCalculator-Kata

Given a simple implementation of string calculator, how would you refactor this, based on SOLID principles?

Kata Description

  1. Create a simple String calculator with a method int Add(string numbers)
  2. The method can take 0, 1 or N numbers, and will return their sum (for an empty string it will return 0) for example “” or “1” or “1,2” or “1,2,3,4,5”
  3. Allow the Add method to handle an unknown amount of numbers
  4. Calling Add with a negative number will throw an exception “negatives not allowed”
  5. Numbers bigger than 1000 should be ignored, so adding 2 + 1001 = 2

Problem Description

Given a simple implementation of string calculator.

Refactor string calculator based in SOLID Principles.

All Test must pass

The code should be flexible for receive different separators or validations on the future

Developed By

  • Jorge Sánchez Fernández aka xurxodev

License

Copyright 2016 Jorge Sánchez Fernández

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.