Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.

Donate Bitcoins

Programming and Learning from SD August 2014 Entries
Notes from a TechEd talk on SOLID principles
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 ......

Posted On Thursday, August 28, 2014 10:33 AM

Technical Debt
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 ......

Posted On Tuesday, August 26, 2014 3:09 PM

Find an element in a JavaScript array
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:, timerId: }); processingProgressTimeoutId... ......

Posted On Friday, August 22, 2014 6:27 PM

Mock the window.setTimeout in a Jasmine test to avoid waiting
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 ......

Posted On Thursday, August 21, 2014 4:42 PM

Run Grunt task in Visual Studio Release Build with a bat file
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 ......

Posted On Tuesday, August 19, 2014 1:21 PM

Mock RequireJS define dependencies with
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 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 ......

Posted On Monday, August 18, 2014 4:53 PM

MVC OnActionExecuting to Redirect
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 ......

Posted On Tuesday, August 12, 2014 3:59 PM

Copyright © Aligned | Powered by: | Join free