I took notes on a great TechEd presentation about the S.O.L.I.D. principles. I highly recommend this talk for all developers. Single Responsibility Principle There can be only one requirement that, when changed, will cause a class to change simple easy classes easy to switch out Open/Closed principle once a class is done, it is done! don't modify it no need to change tests Meyer vs. Polymorphic min 20 Meyer class implementation to inherit from - how much virtual? DocumentStorage with virtual method ......
If any of you don't know about the concept of Technical Debt in your projects, this is a good presentation about it and how to handle it. Some would say any code that doesn't have tests written for them is debt. Also the broken window analogy from the Pragmatic Programmer, where if you have bad code the whole thing can start to fall apart is a good one. Or if you have to do something quickly, and can't design or re-factor and much as you want, you might take on that debt with intentions of "paying ......
I needed a C# Dictionary like data structure in JavaScript and then a way to find that object by a key. I had forgotten how to do this, so did some searching and talked to a colleague and came up with this JsFiddle. See the code in my jsFiddle or below: var processingProgressTimeoutIds = []; var file = { name: 'test', timeId: 1 }; var file2 = { name: 'test2', timeId: 2 }; var file3 = { name: 'test3', timeId: 3 }; processingProgressTimeoutId... name: file.name, timerId: file.id }); processingProgressTimeoutId... ......
Jasmine has a clock mocking feature, but I was unable to make it work in a function that I’m calling and want to test. The example only shows using clock for a setTimeout in the spec tests and I couldn’t find a good example. Here is my current and slightly limited approach. If we have a method we want to test: var test = function(){ var self = this; self.timeoutWasCalled = false; self.testWithTimeout = function(){ window.setTimeout(function(){ self.timeoutWasCalled = true; }, 6000); }; }; Here’s ......
1. Add a BeforeBuild in your csproj file. Edit the xml with a text editor. <Target Name="BeforeBuild"> <Exec Condition="'$(Configuration)' == 'Release'" Command="script-optimize.bat" /> </Target> 2. Create the script-optimize.batREM "%~dp0" maps to the directory where this file exists cd %~dp0\..\YourProjectFolder call npm uninstall grunt call npm uninstall grunt call npm install --cache-min 604800 -g grunt-cli call npm install --cache-min 604800 grunt typescript requirejs copy ......
I had a module dependency, that I’m pulling down with RequireJS that I needed to use and write tests against. In this case, I don’t care about the actual implementation of the module (it’s simple enough that I’m just avoiding some AJAX calls). EDIT: make sure you look at the bottom example after the edit before using the config.map approach. I found that there is an easier way. I did not want to change the constructor of the consumer as I had a chain of changes that would have to be made and that ......
I recently had the following requirements in an MVC application: Given a new user that still has the default password When they first login Then the user must change their password and optionally provide contact information I found that I can override the OnActionExecuting method in a BaseController class.public class BaseController : Controller { [Inject] public ISessionManager SessionManager { get; set; } protected override void OnActionExecuting(ActionExe... filterContext) { // call ......