Thursday, January 30, 2014

TDD and Static Methods

Static methods present a problem in TDD. Interfaces do not support static methods. This can put a damper on fluent interfaces, unless the fluent interface is first developed in a TDD-ish manner and under test, then a fluent interface is put on top of the functionality.  This is usually how it is done anyway.

Especially in TDD avoid static methods unless you have a "good" reason to use them.  Trying to reduce two lines of code down to one for invoking a class, is not a good reason (in object oriented programming.)

Monday, January 20, 2014

NorfolkJs

The very first NorfolkJs meetup tonight. Great group, even had a pair of Google glasses starring at me.

Kevin had good suggestion, next time show filters on repeat.

Also note to self, if it has been a month since doing ng-class. .. brush up before presentation lol.

Presentation was on angularjs.

Went over data binding, controllers, ng-filter, ng-class, karma test runner, jasmine, testing, and a plug for egghead.io for training.

Sunday, January 19, 2014

TDD simple definition

Stating that TDD is just red, green, refactor, is like stating all you need to know to perform an appendectomy is make a cut and remove the appendix.

Monday, January 6, 2014

MOQ and out parameters

MOQ does not support out or ref parameters.  This bring up the debate about how testing tools can limit the developers creativity.  In the end testing is important.  There are other ways to accomplish the same goal.  The out parameter is nice but, testing is nicer.

public bool hasPermissions(string context, out List<string> allPermissions);

restructured to 
public bool hasPermissions(string context, List<string> allPermissions);

Not much of a change, but I do blow out all the data passed in.

Friday, October 11, 2013

Amazon Tech bookstore

Just saw that Amazon.com has a new tech book store.  Dino Esposito was right on the front page.  Cool!

Reading Code

I was asked to make a list of C# apps to learn coding style from. There are many good ones out there.  These are the first ones that came to mind this early in the morning.

Any app that is TDD is probably a good one to learn from.  TDD supports good development style.

https://github.com/ravendb/ravendb

https://github.com/markrendle/Simple.Data

Not C# but still good.
https://github.com/angular/angular.js




Saturday, September 21, 2013

icon approach of checkbox in angularJs

Using icons vs checkbox or  ng-check .
Select boxes are great for forms.

When saving the change to the server on a click...this works too.
The icons are from font awesome.

<div ng-repeat="item in items">
 <i 
    ng-class="{'true':'icon-check','false':'icon-check-empty'}[item.selected]" 
    ng-click="fooClick(item)"></i>
</div>

Explained:  The ng-class has a JavaScript object {...} with an item selector [item.selected].  All this happen inline to paint the proper icon.

The best part is you can see the icon choices in the html and do not have to look in the js files.  For larger lists I would not do it inline.

When user clicks, fooClick is invoked and I change the item in the database and change the var in the item.  Thanks to angularJs binding, the ui is updated.

My Controller code.

Note: I have boolean strings.
Like a good developer, I'm not 'boxing' item.selected by directly assigning it while operating on it. For more info on boxing click here.

$scope.fooClick = function (item) {
  var tf = (item.selected === 'true') ? 'false' : 'true';//watchout... boolean strings
  item.selected = tf;
  saveToDatabase(id,val);
}