Skip to content

xurxodev/Refactoring-StringCalculator-Kata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Given a simple implementation of string calculator, refactoring based on SOLID principles. Implemented in Java and Swift by Jorge Sánchez (Xurxodev)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published