Agile Principles, Patterns, and Practices in C#

Author: Robert C. Martin, Micah Martin
All Stack Overflow 30
This Year Stack Overflow 3
This Month Stack Overflow 1


by anonymous   2017-08-20

Based on your examples, there's definitely an ISP and a SRP and probably a Law of Demeter (not SOLID but...) violation going on at the very least.

IMNSHO You're far better off reading articles on SOLID (or buying Agile Principles, Patterns, and Practices in C# by Robert C. Martin and Micah Martin which is excellent throughout and one of the most useful books I've read in recent years) than asking for piecemeal advice on the interwebs for this type of thing.

If you want a shortcut (you don't though - the books and PDFs have examples that explain things very well!), these Hanselminutes podcasts with Uncle Bob are very good:

edit: Nabbed the SRP from Jon Limjap and ppiotrowicz

by anonymous   2017-08-20

This is certainly a reasonable explanation:

I own this book: I'd recommend it for good coverage of many design principles, including IoC:

Agile Principles, Patterns and Practices in C#: Martin Fowler, Micah Fowler

You might also find these links helpful:

Two pithy "explanations":

  • IoC is sometimes known as the "Hollywood Principle": Don't call us, we'll call you

  • IoC = Marriage; IOC Container = Wife

by anonymous   2017-08-20

This sounds an integration test to me. Anyways, forget RhinoMock in this case because there's no other way to do it but to create your own test suite here. In our case we actually used HttpClient to call the controller/api and pass the url and argument needed for action and anticipate the result for validation.

public class ClientHandler
   private HttpClient _client;

   public ClientHander()
        // add handler if needed ex var handler = new HttpClientHandler()

        _client = new HttpClient(/*handler*/);

        // add default header if needed client.DefaultRequestHeaders

   public HttpResponseMessage Post(string path, HttpContent content)
      // You can async if you want
      return _client.Post(path, content).Result;

Now you can use it in your actual testing.

public class MyController
    public void TestMyControllerActionSaveData()
         var client = new ClientHandler();
         var content = new StringContent(dataHere, Encoding.UTF8, "application/json");
         var outPut = client.Post("http://server/action/here", content).Result;

         // validate expected output here

There are a lot of missing configuration and setup here but the gist is there.

Update : I really like what you are currently doing in the name of testing because this is a powerful tool as part of Continues Integration (CI). Just a minor comment the way to name your test method. I would suggest to rename the test method into an action you want to do and put those procedure inside the test like what Gherkin way of BDD or as described by Dan North .

public void Should_Save_If_Has_Data()

public void Should_Not_Save_If_No_Data()

If you can create a TestSuite like described above it will give you a lot of benefits in the long run and avoid repetition of code (DRY). Also those tests will serve as living documents as described by Robert C. Martin & Micah Martin. Special thanks to the team that Im involved and kudos is for them!

by anonymous   2017-08-20

I advise you to take note of a book Agile Principles, Patterns, and Practices in C# by Robert C. Martin and Micah Martin, there are many good examples where it is shown how to design a system by UML, and other similar methods. Specifically, it is shown why you should refactor your code, that can be stored in abstract classes and what is not. You can immediately see an example with a coffee maker Mark IV, where he developed a truly independent interface.

According to my feelings, the main principle of MVVM - is the independence of the data from its representations. I like trying to make separate modules, which implement separate logic, not knowing about the data. For example, SQL module, SMTP module, etc, which simply contain some methods like ConnectToDb() or SendEmail(), the main logic is in ViewModel, she combines these Work-modules with the data model.

Useful to draw a diagram before designing the system, but do not get involved too. The main thing is to see the main parts in the paper, and that the others would understand it as well as you know (or architect).

by anonymous   2017-08-20

First of all, it is this book:

Robert Martin - it is a person who introduced SOLID principles.

by Mark Brittingham   2017-08-20

You will want to learn more about the entire Agile Development movement. Agile is just what it says: able to quickly adapt.