Tuesday, November 15, 2016

I'm done with blogging for a while.

To set up dual monitor displays at Windows 10, right-click in the taskbar, pick "Properties" and then click "Customize..." and then from the "System" box that appears go to "Display" and start by changing "Multiple displays" to: "Extend desktop to this display" ...you know, I've kept this blog for 5+ years and only now am I using an operating system at work that is newer than the blog itself. (not Windows 7)

Monday, November 7, 2016

abstraction: the fourth pillar

I thought there were three pillars to OOO as suggested here. In Googling it some, it kinda seems like some lists include abstraction as a fourth pillar. In many ways this is a lot like encapsulation in that in both cases you are trying to expose what is important and marginally hide that which is merely necessary that should draw the eye less sort of like the distinction between the "Wizard" of Oz and the man behind the curtain. (We want to keep him behind a curtain.) However, that said, encapsulation is something in particular, very particular, and has to do with how gunk is kept in a class itself. Abstraction will have you pulling stuff out of a class to another class.

Use the ES6 fat arrow for simple function substitution.

var x = y => alert(y+y);
x("hi");

 
 

...which is gonna tell you "hihi" is bascially the same as...

var x = function(y){
   alert(y+y);
};
x("hi");

There is a way to "autoseek" dependencies in web forms with StructureMap as one does in MVC where they may now auto-hydrate at controller constructors.

I spoke to someone who has done it before over a phone screen just now. It's nasty. You have to inject something into the HTTP model to catch a page before it complies code but after it's baked and inject stuff. Is ObjectFactory that evil that I should want to go there?

closures in JavaScript

What I suggest here is probably really wrong. Instead if you just Google against this topic you'll find stuff like this giving a different explanation. Alright, consider this:

var myClosure = function() {
   counter++;
   alert(counter);
};
myClosure();
myClosure();
myClosure();

 
 

It's gonna fail, right? You can't do plus plus on something undefined, right? Well, what if counter did correspond to a number in a backing store, someplace where state could be kept? It can. You can have this:

var myClosure = (function() {
   var counter = 0;
   return function() {
      counter++;
      alert(counter);
   }
})();
myClosure();
myClosure();
myClosure();

 
 

This code will not break and will moreover throw up three alerts, one after the other, with 1, 2, and 3, in them. We have made counter a privately-scoped variable really only approachable by myClosure and we are using it as a backing store for state. After initial assignment, myClosure behaves in the code immediately above just as it does in the code at the very top of this blog posting. The only difference is that now counter means something.

Saturday, November 5, 2016

yet more RANDOM notes from trying to find a job

a lot of this is shamelessly stolen from other stuff I found online...

  • var x = y.OrderByDescending(z =>
          z.Date).ThenByDescending(z => z.Name).Skip(5).Take(8);

          ...is an example of .ThenByDescending/.Take/.Skip in a Lambdaland.
  • cookies are a long-standing way of maintaining state at the browser while sessionStorage and localStorage are new to HTML5. localStorage lasts until you get rid of it, cookies may be set to last X number of days or minutes, and sessionStorage only lasts until the browser closes
  • data- attributes in HTML! You may invent your own "legitimate" inline parameter at an HTML tag to make it easy to latch onto the tag in JavaScript or communicate things in JavaScript.
  • The Discovery web service is a tool used to determine the organizations that a user is a member of in Microsoft Dynamics CRM.
  • Use both yield return and yield break TOGETHER...
    while (true)
    {
       if (i < 5)
       {
          yield return i;
       }
       else
       {
          yield break;
       }
       i++;
    }

super-simple example of using a directive at a custom tag in an AngularJS 1.5.8 application

Assuming the HTML at the top of this, let's place a new tag just inside the first div tag with the ng-app on it like so:

<add-Intro></add-Intro>

 
 

Alright, our directive itself looks like so:

app.directive("addIntro", function () {
   return {
      template: "Books by George R. Martin:"
   };
});

 
 

Notice that the names don't match up one for one. You will have a directive name in camelCase and when you call to it with a tag in the markup then the names get hyphens between the words. Whatever. The copy in the template ends up painted to the screen at the tag's locale. Yippee! Anyways, if this seems like a pretty weak blog posting, it really is a wrap-up of a series of other blog postings. This is the sixth of six blog postings in which I build out an AngularJS app. I worked with Angular for like two weeks at @hand three years ago and of course I've forgotten it all so I've been trying to refresh myself. If you follow the following postings you could build out an app yourself!

I think it's neat that the first eight Roman numeral numbers come in alphabetic order, though I suppose that's off topic, eh? Anyways, I recommend just pulling Angular 1.5.8 from NuGet in Visual Studio and building out inside of the first web page your application surfaces when you run it. Add script tags for angular.min.js and angular-route.min.js. Hmmmm... I'm not sure I needed angular-route.min.js.