Design Pattern – Composite

Let’s refactor further the previous code sample using the composite pattern. See the link(https://www.dofactory.com/net/composite-design-pattern) for the details of what is a composite pattern. Let’s bring back the last code here. var availableCommands = new ICommand[] { new UpdatePrice(_stockPriceManager, stocksToRead, _appSettings.DaysToReadFromWeb), new UpdateStats(_stockPriceManager, stocksToAnalyze), new SimulateCommand(_stockPriceManager, stocksToAnalyze, _marketWatchRepository, investDay, _tradeOption, _logger, _appSettings) }; if (runOption ==… Continue reading Design Pattern – Composite

C# Performance Improvement Experience

I have a personal code originally wriiten in 10 years ago when I was starting coding in University. The code is basically stock price analysis tool.  Recently I started to look at it again and found a few tips to improve the performance calculation and DB access heavy code. Actually, this shouldn’t be DB access… Continue reading C# Performance Improvement Experience

Functional Principles in C# – method should be honest

Below are the key ideas of how to apply functional principles in C# explained in Pluralsight course by Vladimir Khorikov. Immutable Architecture Separate domain logic, Infrastructure(Persister), Service logic. Make the domain logic immutable and functional(input -> output) so as to easily unit test it. Make the infrastructure and service logic as simple as possible. Exception Use return… Continue reading Functional Principles in C# – method should be honest