Skip to main content
replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
Source Link

If you want to get it done and quickly, you can grab Ixrec's solutionIxrec's solution, who at least managed to eliminate the else if and else blocks, which, in my opinion, are even a tad worse than a plain if.

If you want to get it done and quickly, you can grab Ixrec's solution, who at least managed to eliminate the else if and else blocks, which, in my opinion, are even a tad worse than a plain if.

If you want to get it done and quickly, you can grab Ixrec's solution, who at least managed to eliminate the else if and else blocks, which, in my opinion, are even a tad worse than a plain if.

added 3 characters in body
Source Link
Andy
  • 10.4k
  • 4
  • 28
  • 51

In the end you end up with hundreds of little classes and interfaces, focused on very specific things. Which is not necessarily bad, but might not be the best solution for you if all you want is to do something as simple as adding two numbers.

Take into consideration this is my way of making good OO design. Coding to interfaces rather than implementations, this is how I have done it for the past few years and it is the approach I am the most comfortable with.

I personally like the if-less programming a lotmore and would much more appreciate the longer solution over the 5 lines of code, not only but also because it. It is the the way I am used to designing code and am very comfortable comfortable reading it it.

In the end you end up with hundreds of little classes and interfaces, focused on very specific things. Which is not necessarily bad, but might not be the best solution for you if all you want is to something as simple as adding two numbers.

Take into consideration this is my way of making good OO design. Coding to interfaces rather than implementations, this is how I have done it for the past few years and it is the approach I am the most comfortable with.

I personally like the if-less programming a lot and would much more appreciate the longer solution over the 5 lines of code, not only but also because it is the way I am designing code and am very comfortable reading it.

In the end you end up with hundreds of little classes and interfaces, focused on very specific things. Which is not necessarily bad, but might not be the best solution for you if all you want is to do something as simple as adding two numbers.

Take into consideration this is my way of making good OO design. Coding to interfaces rather than implementations, this is how I have done it for the past few years and it is the approach I am the most comfortable with.

I personally like the if-less programming more and would much more appreciate the longer solution over the 5 lines of code. It is the way I am used to designing code and am very comfortable reading it.

added 11 characters in body
Source Link
Andy
  • 10.4k
  • 4
  • 28
  • 51
  1. just get it done, in which case pretty much any solution will work for you
  2. be pedantic and design a solution which exploits the quirks of the language an its ideology (OO languages in this case - the use of polymorphism as a mean to provide the decision)

But what would happendhappen, if you chose to do it the pedantic way and actually solved the problem with design patterns, in the way you wanted it do?

Ideally, you would have unit tests testing the 4 adapter classes you created to make sure they work, you make your test pass. And if they pass, you can be pretty sure they will work no matter where you call them in your code.

  1. get it done, in case pretty much any solution will work for you
  2. be pedantic and design a solution which exploits the quirks of the language an its ideology (OO languages in this case - the use of polymorphism as a mean to provide the decision)

But what would happend, if you chose to do it the pedantic way and actually solved the problem with design patterns, in the way you wanted it do?

Ideally, you would have unit tests testing the 4 adapter classes you created to make sure they work, you make your test pass. And if they pass, you can be pretty they will work no matter where you call them in your code.

  1. just get it done, in which case pretty much any solution will work for you
  2. be pedantic and design a solution which exploits the quirks of the language an its ideology (OO languages in this case - the use of polymorphism as a mean to provide the decision)

But what would happen, if you chose to do it the pedantic way and actually solved the problem with design patterns, in the way you wanted it do?

Ideally, you would have unit tests testing the 4 adapter classes you created to make sure they work, you make your test pass. And if they pass, you can be pretty sure they will work no matter where you call them in your code.

rewording, edit
Source Link
Andy
  • 10.4k
  • 4
  • 28
  • 51
Loading
deleted 1 character in body
Source Link
Andy
  • 10.4k
  • 4
  • 28
  • 51
Loading
added 259 characters in body
Source Link
Andy
  • 10.4k
  • 4
  • 28
  • 51
Loading
deleted 2 characters in body
Source Link
Andy
  • 10.4k
  • 4
  • 28
  • 51
Loading
added 161 characters in body
Source Link
Andy
  • 10.4k
  • 4
  • 28
  • 51
Loading
Source Link
Andy
  • 10.4k
  • 4
  • 28
  • 51
Loading