Monday, November 26, 2018

[Advice] Simple design decisions

This is a simple scenario but I think it could be a good indication on how different people think and different approaches to a simple problem.

I need to prefix a string with my machine name for all "create" methods and I'm unsure on the best approach, as there's a few options.

Basically I have been trying to follow design patterns as much as possible and try to get into habits. So for this scenario I'm not sure on which would be the best/most common approach. It's a simple problem and my instant solution would be option 4 as it's quick, easy and simple to use with Dependency Injection.

Options:

  1. just use a private method - it's quick, easy and does the job (but I know I will be putting the same code into another class when it's done in this first one).
  2. Create a static helper class - e.g. NamingHelper(string name) which returns the new string.
  3. Create a simple factory class - typical simple factory that has a "make" method or something named more appropriate, which returns an interface so future naming conventions can be easily added.
  4. Use a simple service class - e.g. NamingService. This will have a method on it much like the factory would, except this service class would just return an object and not an interface. (I use "services" but this could be called a handler or manager or one of those many names that exist which all sort of mean the same thing)
  5. Something else that is more more simple than I'm thinking :)

Interested in peoples opinions and appreciate any responses! Thanks!

[Advice] Simple design decisions Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team