Functional Programming and its concepts are becoming more important to software industry and data driven applications. But for us to be able to benefit from functional programming we don’t have to use a strictly functional language like Haskell for example. We can follow the principles and patterns of functional programming even in object oriented languages …
C#
C# in parameter modifier
In version 7.2 of C# language, now we can pass an argument into a method without allowing the method to mutate the value. But the main reason this keyword is added to the language is not mutability. It was added for optimization and the need to pass a value type in a method by reference …
Moq: What’s Wrong With Using VerifyAll
There are some features in the isolation framework (Mocking framework) Moq which I see is used blindly. Most of the time it can which reduce test readability and maintainability. One of the worst offender in this regards is VerifyAll. In this post I’m going to elaborate why this method is so pernicious to readability and …
Stop Using Repository Pattern With an ORM
There a tendency in software developers to want to follow a specific formula. Whether it is adhering to a methodology like agile or using a specific design pattern. This happens so often that we have a specific term for it in our field called Cargo cult programming. In these situation a programmer don’t ask themselves …
TPL Dataflow Blocks: Post vs SendAsync
I was reading an excellent series of articles about TPL Dataflow from Jack Vanlightly the other day. He draw my attention to the difference between Post and SendAsync when we want to post something to a block. I wasn’t thinking about it much at the time. But as I progressed through my readings, I saw …
xUnit BeforeAfterTestAttribute: How to Run Code Before And After Test
Sometimes we need to run a piece of custom code before and after a test and set of tests. One example of this might be when we want to change the thread culture. In this case we change it before test start to run and restore it to its original after test is finished. One …
More Robust Asynchrony and Parallelism With TPL Dataflow ActionBlock
.In my previous post, I explained what TPL Dataflow is and when we should and shouldn’t use it. But I haven’t got into much detail about how it can help us solve real world scenarios. Since my last post, thanks to a comment on my previous post, I went though different Stackoverflow questions. I saw …
xUnit: Control the Test Execution Order
Sometime in our tests, we need to control the test execution order. This mostly happens in our integration test and not as often as our unit tests. Some people might even argue that controlling the execution order of unit test is bad practice. You can read more about it here. The main reason to not …
What is TPL Dataflow in .Net and When Should We Use It
There are various ways to write a concurrent or parallel program in .Net but they’re often don’t have the flexibility and robustness needed. That’s where TPL Dataflow comes in, it helps us build a more robust concurrent program and it can helps us reduce a lot of complexity. For example when we use other paradigms …
xUnit: Share an SUT Instance Between Two Class Using Collection
In my previous post I talked about how we can Share Expensive Object Between Tests By Using IClassFixture. My previous post is about situations when we want to share a class instance between all test methods. Because a test class is created once per test method so its constructor is executed per test methods. But …