jump to navigation

jsRazor – New Way of Rendering Json That Is Pure Genius May 9, 2013

Posted by ActiveEngine Sensei in ActiveEngine, Ajax, jQuery, JSON.Net, KnockoutJS, Open Source, Problem Solving.
Tags: , , , , ,
add a comment

DClick this link immediately, and you’ll see wonderful things! Sensei has said many times that simple is better, and rgubarenko of MakeItSoft has a brand spanking new template engine that is so simple it makes you speechless.  His premise:  every possible rendering task can be accomplished as a random combination of two functional primitives:

repeat – repeats fragment of HTML code for each object in array
toggle – shows or hides fragment of HTML depending on boolean flag

Here is an example taken from the github site.  To get the output display below:

jsRazor Example Output

from a Json data set that looks like this:

var data_Themes = [ { name: "Dreaming Theme", colors: ["#2A1910", "#9E7064", "#B0967C", "#E7435E", "#6D4F3F"] },

{ name: "Moth Theme", colors: ["#30382D", "#565539", "#78765F", "#403F2B"] },

{ name: "5 Dark Theme", colors: ["#000000", "#280705", "#2E0500", "#3B0000", "#3C1100"] },

{ name: "Blue Volcano Theme", colors: ["#5077FF", "#8A84FF", "#81C1FF"] } ];

You will have a template that looks like this:

<pre><div id="example">
      <div class="name">{name} ({CountColors} colors)</div>
      <div class="wrap">
        <div class="color" style="background-color:{item};">
          <span style="color:white">{item}</span>
          <span style="color:black">{item}</span>
        <div class="rgb">({R},{G},{B})</div>

The controller that creates the final result is as follows:

<pre>// get initial template
var tmp = document.getElementById("example").innerHTML; 
// repeat theme objects (pass array of themes to repeat functional)
tmp = $.jsrazor.repeat(tmp, "themes", data_Themes, function (tmp, idx, item)
  // repeat inner color objects (pass array of colors of the current theme item)
  tmp = $.jsrazor.repeat(tmp, "colors", item.colors, function (tmp, idx, item)
    // use toggle to show dark or light color text (to be contrast with background)
    tmp = $.jsrazor.toggle(tmp, "dark", hex2rgb(item).mid <= 128);
    tmp = $.jsrazor.toggle(tmp, "light", hex2rgb(item).mid > 128);
    // output RGB representation of the color as custom value
    tmp = tmp
      .replace("{R}", hex2rgb(item).r)  // red
      .replace("{G}", hex2rgb(item).g)  // green
      .replace("{B}", hex2rgb(item).b); // blue
    // return processed template for current INNER item
    return tmp;
  // color counter is not a part of JSON, so we output it as custom value
  tmp = tmp.replace("{CountColors}", item.colors.length);
  // return processed template for current item
  return tmp;
// put processed output back
document.getElementById("example").innerHTML = tmp;</pre>

This looks very promising.  In fact, this could be a very cool way of writing reports in jQuery!  Think about it – with a tool like jLinq for filtering data sets and jsRazor, you could replace SQL Server Reports.

Simplify Your Thoughts For Uninterrupted Flow April 24, 2013

Posted by ActiveEngine Sensei in ActiveEngine, Agile, Coaching, New Techniques, Open Source, Personal Development, Problem Solving.
Tags: , , , ,
add a comment

Sensei recently gave up FogBugz. This was not because of FogBuz, as it is a great product. But Sensei realized that it was not meeting his needs. It was too much. When on the hunt, you can’t be slowed down, and sometimes you have to jettison the extra weight. To be fair, the context here is a prototyping project, where errors / foibles / new features need to be captured. FogBugz is great a teams, but it does require, well, too many clicks. You should always ask yourself this question: which James Bond do I want to be?

doctor-no1_lg bond_large_verge_medium_landscape



Which Bond gets the babe? Pretty easy choice. The unfettered thinker makes them swoon. The guy with the helmet …not so much.

Keeping It Real By Keeping It Simple

Yep – Sensei sounds like a whiny Apple-simplify-your-life-and-wear-a-black-turtle-neck Zen iPad fan boy. Well, that’s not right either. There’s just the right tools for the the right job. So when in the fight with the development environment, brain firing on all cylinders, Seseni uses Workflowy. You can quickly categorize your lists / sentences / thoughts as you go. Just typing, no modal dialog boxes, no creating an item, waiting for it to save, clicking, scrolling, more dialog boxes.

Before you attack, Sensei is not saying this will work for teams, for bug resolution, and other endeavors that FogBugz does very well. But it’s all about eliminating the tactics that get in the way of you achieving your goals. This is critical. And when prototyping you need as much room in your head as possible so you solve the bugs, but not spend more time tracking the bugs. Below is a sample. Issues and features, pretty easy. Click it to see the details.


So What? Well, How About Taking It a Step Further

Sensei hopes that the enterprising readers out there can take this idea and run with it: Why not create system that parses the format shown above? When you edit, each line gets a Guid. Then, start at the top level. Each item at that level is story or a deliverable, maybe broken down by screen or function. A child of each story will have an Issues or Features item, and the child items of Issues naturally belongs to Issues. All else would be ignored when converting to a database record, yet retained in your notes.

bond_01_slide-9f8039ebe14dba26b56314bd850026a107423d9c-s6-c10 - CopyThis would be your starting pointing. Because each of these items has an identifier, later you could parse them into a database format, assign people, etc. The point is that the starting point is easier, is more productive because you just type. That way your work gets done, and you feel more like him.

DataTables.Net and Twitter Bootstrap Provides Nice, Clean Layout January 7, 2012

Posted by ActiveEngine Sensei in ActiveEngine.
Tags: , , , ,
add a comment

Been a while since we’ve talked about DataTebles and it’s epic awesomeness. Allan is amazing and has picked up more momentum.

Jump to his blog post about combining DataTables with Twitter Bootstrap CSS.

Moncai – A Cloud Service for Mono and .Net December 2, 2010

Posted by ActiveEngine Sensei in .Net, ActiveEngine, Linux, Mono, New Techniques, Open Source.
Tags: , , , , , , ,
add a comment

If you have read these tomes of insanity posted by yours truly, you know that Sensei likes to stretch when it comes to finding solutions.  Aspiring to be an action hero in the everyday field of software development means you have to work like a dog, hunt like a tiger and crouch like a cricket.  This also means that you have to be flexible and willing to try new things.

Moncai, a service that will deploy your .Net / Mono app to the cloud via Git or Mercurial, looks very promising for those who want to try their hand at running their .Net application in the Linux realm.  As opposed to Azure, Moncai will offer POSIX distros for you to use.  The man behind the scenes, Dale Ragan, recently talked about Moncai in a HerdingCode podcast.  What he describes is a tiered approach to levels of service that you can have.  Dale wants to offer the hobbyist or midnight blogger a chance to experiment for free / low cost, and the services levels increase depending on your needs.  Dale even takes the time to communicate you via email when your first sign up, a real nice touch.  Go check it out and spread the word.

Getting to 11 February 13, 2010

Posted by ActiveEngine Sensei in ActiveEngine, Fluent, New Techniques, Problem Solving, software economics.
Tags: , , , , , , ,
add a comment

In the past Sensei has written insane tomes regarding time travel and how your best intentions really get you no where. The story today is about getting to 11, which as Nigel says is one more than ten, putting you over the top.  Consider for a moment the times that you really think you’re like this guy to the right.  Yep, you think you have a Martin Fowler sized audience when you are coding.  The scientists of the future will study my code and say “Here, this is the start of the great insight.  How interesting.”  In reality you are like Spinal Tap, unaware of how absurd you can be.  Code too complex, but it goes to 11!   Most blokes keep it at 10, but then you need to put it over the top take it up a notch.  That extra notch.  That’s 11.

Here’s a thought – what about 6?  Is it viable?  Can you be flexible by doing a 6, just good enough to not paint yourself into a corner?  “Perfection is a process, viable is an end state.”  As a developer you may not be able to judge what 6 is.  If you’re in tune with your fan base you’ll know but that can only come from wisdom born out of great mistakes.   For those of you who study Budo you may recall the concept of short and long and how relative scale can shift your advantage.  Your opponent may have a sword and you only a dagger.  Short and long makes a big difference, but you can alter that equation with small maneuver.  Once you’re inside and beyond the sword’s curring range you have the advantage, as your dagger is now long enough to finish the skirmish.  Change the scale.

Years back Sensei was given the task of reducing shelf space utilized by paper by 25%.  The CFO arrived at this goal via scientific method.  It was scientific since at Sensei’s company if you don’t do what the CFO said it is axiomatic that you were in deep doo-doo.  Laws of hierarchy and all.  Now imagine rooms filled with documents related to contractors, account-receiveables, human resources, legal contracts, project management etc.  Yah, DISPARATE is the word.  Not meta data, just a meta-mess.

Now in the best of all worlds where you need to get to 11, you would have time to survey all document types and refine each attribute set before you design your system for document categorization.  This foundation becomes your data model in a database and many would claim that you should a create data table per document type to house the varying number of attributes. But you have 2 million sheets of paper to scan and in 12 months re-construction at your offices begin so you need to be able to walk into a room and quickly categorize all documents, throw them into boxes, scan them, and automatically assign the meta data to the document and store the thing.  Oh, and if you miss a document type or need more attributes you don’t want to go back to your database, add or modify a table, re-gen your data access layer, add the attribute to your screen all before your adjust your categorization.  And remember, you need to ship out 80 to 100 boxes every 2 weeks so you need to keep the data entry flowing.  Finally, you are told that some projects can have up to 50 different types of documents, but no one is sure to what degree the project documentation is complete so the number of document types per project is not known and NOBODY HAS THE TIME TO GO THROUGH THE SHELVES AND CREATE DOCUMENT TYPES BEFORE ANY DATA ENTRY IS POSSIBLE!

Play the song, ’cause it adds to the excitement!!

Several key decisions solved this mess, and the solution was simple enough that temps could walk into a room categorize and pack documents into boxes for scanning.  The error rate ranged between 1 – 5% per department.  These were not solutions cranked up to 11, they were 6’s:

  • No change to database schema or screens will be made, ever.  A document was modeled with four tables with a base Document table, Document- Type table, Document-Attribute table that contained all attributes per Document-Type and finally a Document-Attribute-Value table where the meta data was stored.  This way each Document-Type could be be created with simple data entry.  One data entry screen that could create data controls on the fly per attribute type developed.
  • Each document shall have a bar-coded coversheet.  Nothing gets scanned without meta data.  EVV-ARR.
  • Import data from existing systems. The meta data for your documents resides in many of your accounting, job cost, and budget systems.  Once document types are known, dumping data from accounts receivable and / or accounts payable allows your to assemble thousands of cover-sheets for all invoices.  Quite literally you create a stack of paper for all possible types of invoices for all accounts, walk into a room, pull documents of the shelf, attach coversheets, and keep the sheets you didn’t use.  Now, since the unused sheets have a bar-code, run these through you bar-code reader and create delete records for what you didn’t use.  Now you have a complete accurate manifest of what was on the shelf and what was packed away.  When the scanned images come back you can inspect them against the manifest.
  • People can work better with paper.  As stated in the last bullet point, creating all possible types of document coversheets per account or project and printing them allows you to quickly categorize all documents.  With minimal or no data entry and a stack of coversheets, anyone now can go through shelves and associate the coversheets with the appropriate documents.  In other words, the subject matter experts have a tangible, traceable system that they can hand off and supervise someone who can do the grunt work.  Not sure where you finished with your categorization?  Just look at your stack of coversheets.  Want to inspect accuracy, grab a document and compare it to the categories printed on the coversheet.

What?  Process management with paper ?  That sucks!  No it really doesn’t.  You see, a 6 to you really is an eleventy-one for your user community who is really busy.  Yep, you have to be smart with your database design by focusing on one key area and that’s it.  The rest  of the effort is imports with SSIS packages, CSV files, and printed coversheets.  But it’s easy for the users to use paper, and that keeps a flow going.  2 million sheets of paper scanned in a year.  Maybe a 6 isn’t all that bad after all.

Chang-chang-a-ching-changa-langa-langa: Why Your User Community is Fluent in English and You Are Not the King February 6, 2010

Posted by ActiveEngine Sensei in .Net, ActiveEngine, Business Processes, Coaching, Fluent, Problem Solving, software economics.
Tags: , , , , , ,
1 comment so far

Get ready for the sound of one hand clapping, but first, fire off the song as it get’s your head straight.

Some of you want to be Elvis too much.  Sensei’s going to tell you a story so you know what he’s talking about.  You see, users of your apps  are waaaay smarter than you, and spend more time in their fields than you ever hope to do.   You need a little love.  It’s called fluent interaction.  Fluent. Interaction.  Lord have mercy.

Process mapping helps, but in the end that takes you to overly scientific abstractions, and while user stories help some they, too, stray with you as the sole author.  You in the chair, just the important details from the user, but mostly you.  Should you consider yourself not Mort but an Elvis, you may want to ask yourself what Elvis you want to be:

Kick-ass Karate Elvis
Drug Ridden Elvis Wanna Be

Back to the story.  Last episode, in a spate of productivity and a dose of SQL-NoSQL fever, Sensei created a slim document management solution that can be quickly applied to an existing framework with minimal impact to database schema and code base.  Sitting around the conference room table the comment arose from Annie, the project lead from the Sales group:

“Why do I have to save a commission record first before I can attach a document?  That interrupts my flow.  I want to put in everything that I want and save, period.  No dialog box thingy prompting to save first, come back and do something else.  Why can’t we just do it”

Long silence.  The sound of one hand clapping.

One of Sensei’s report-to’s jumped in:  “Because in order to associate the document to the commission you have to save that commission first in the database, then take the id from the record and associate it document.  This allows you to retrieve it later on.”

Annie:  So.  Can’t that just happen behind the scenes?  If it’s two steps the sales gal won’t do it.  She’s got calls to make.

Ssensei drifted out in research land, or as normal people call it, he spaced out for a bit.  NetFlix sprang to mind, iPhone too, where you delete, it does it, but you can bring it back.  Take the confirmation response out of the equation.  Give the user a chance to undo their mess, but don’t get in their way.  It’s fun to pretend to be the King, but what a wake up slap.  The technology was right, but the user was seeing the benefit because “putting the stuff in was too clunky”.  Sensei went and did want Annie wanted.  Annie thinks its great.  Good technology made better by the user, not the King.

Fluent.  Interaction.  Lord have mercy.  You see, Annie’s right and user stories, UML and other brain death would never capture the essense of her perspective, particularly after she used the software.  Yeah, soft deletes are great theory, but you are not thinking like a user.  In order to be a better King, you gotta give the concert they want to hear.  You have to know that the fans have created you, have shaped your persona.  You have to know your fans, almost be them.

Elvis had a come back concert in 1968 but it almost didn’t happen as there was a huge fight with NBC.  The network insisted that the show would be like a Bing Crosby special given that the air date was during the Christmas holiday season.  Elvis wanted an intimate environment where he could perform up close, live with his fans.  He thrived off of close contact with his fans.  Know your audience.  Elvis was right, and it helped re-launch his singing career and revive his legend.  It was one of his best performances.  For the fans.

You need to listen to your users.  Spend the time to hone your craft, but work even harder to make them fans.  What do they need?  Is the concert for them or for you?  Are you learning just to be smart or for their benefit?  Fluent solutions require interaction with the fans.  Thank you.  Thank you very much.

Fluent Thinking – C# Plus SQL Equals CouchDB. Maybe. January 23, 2010

Posted by ActiveEngine Sensei in .Net, ActiveEngine, C#, New Techniques, Open Source, Problem Solving.
Tags: , , , , , , ,

I’ve gone too far to turn around
It’s hard to reach for you
When I’m lying face down
I can’t relieve my soul
I’m lost in a moment
Lying face down

Saving Abel

There are moments when life brings too much possiblilty to your attention and your mind catapults into overload.  Take the great potential that CouchDB has, as an example.  Elegant, simple.  Damien Katz has ignited a real fire storm with his work and may have single handedly given rise to the not-a-RDBMS movement.  Sometimes developing under the gun, Sensei has to admit that the 3rd normal form restrictions can be a little inhibiting.   Really, a collection of value pairs will do quite nicely, and XML, when it doesn’t run on for more that 1 page can be quite descriptive, it still is not quite the solution for quick configuration solutions.  JSON is just about right, easy to manipulate, and this is why Damien chose this as the structure for a document in CouchDB.

“But Sensei, I have SQL Server.  We aren’t allowed to say the L-word!”

“You mean Linux, right?  Just checking.”

There may be constraints imposed by the  environment you have at your disposal.And if you have a current system in production you might have a hard justifying to the powers that be that you should download a LAMP server from JumpBox just so you can introduce doucment managment into your current production system. Or perhaps you have an extensive data model and are concerned that that the meta data would too complex to store with the documents.

Here’s a simple yet effective way to introduce a “CouchDB lite” version to a current database platform that is applicable to SQL Server, Oracle, MySql and provides a flexible way to store meta data for quick retrieval.   It’s not badass like Sam Jackson, but it’s not ridiculous like the beast picture next to him either.

The goal stated succinctly:

  • Provide the abilty to associate a document to a record in an existing DBMS
  • Provide the abilty to store the meta data related to a specific record or a document type.
  • Ensure that future meta data and document types will not a change in the cardinality of the database schema nor require the addition of additional database attributes.
  • Provide a object oriented framework that adheres to the Open-Closed principal; that is, open to extension but closed to modification.

Previously Sensei has opined regarding fluency, and this solution adheres to those prinicipals.  For existing RDBMS a single table can introduce the simplicity and clarity you seek.  All document meta data can be stored in a table aptly named Document:

CREATE TABLE [dbo].[Document](
	[DocumentId] [int] IDENTITY(1,1) NOT NULL,
	[UserId] [int] NOT NULL,
	[Name] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[PostedDate] [datetime] NOT NULL,
	[DocumentHash] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Attributes] [varchar](8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[DocumentId] ASC

REFERENCES [dbo].[User] ([UserId])

In brief, this table stores an identity key for each document, the name of the document, a foreign key that represents the user / person who saved the document, and the date when the document was posted.  The attribute DocumentHash is a hashkey comprised of the DocumentId, the UserId, the Name of the document, and the PostedDate.  The DocumentHash value is prepended to the document name to create a unique document.  Consider it a way to associate the document with a specific record in the database.  In other words, you should be able to re-create a haskey from the data attributes that matches the value pre-pended to the file name of the document.  Another nice by-product is that you can version documents quite easily.

Focus next on the column named Attributes, as this is where the magic happens.  The meta data for each document is stored here as JSON.  This takes the following form:


This JSON serilization of an array of Key/Value pairs is a format that allows you store whatever meta data you wish. Notice the first line named “Owners”. This allows you to store the user id’s of all users who have the ability to delete or edit the document.  You can set security based on this attribute, and implement a document centric security framework that can exist in addition to security place on the share where the document is stored.

As stated earlier, any type of data can be stored in the Attributes column.  If you notice line 2 that reads “BonusId” you see that keys to other tables in your database schema that can saved with the document record.  This feature allows you to maintain the relationship of a document back to a particular record or set or records.

You may be asking yourself why the Key Value nomenclature in the JSON string.  The attributes can be deserialized to an object of type List<KVPair> where KVPair  has the following structure:

namespace BusObj
    public class KVPair<TKey, TValue>
        public TKey Key { get; set; }
        public TValue Value { get; set; }

        public KVPair(TKey k, TValue v)
            Key = k;
            Value = v;

        public KVPair() { }

The Key Value pair lends itself to simple querying.  Since the attributes can vary from document to document, the meta data can include identity keys to records in your existing database schema, information regarding folder structure where the documents can be stored, and what ever other piece of important information of you need to retain.  Once the JSON is deserialized to List<KVPair> you can use lambdas to query your documents.  Consider the following code that is used to determine document ownership where the owners are represented as

public bool IsDocumentOwner(int userId)
                                                "Document.IsDocumentOwner - parameter userId can not be null");
            //  No attributes?
            if(this.DocumentAttributes.Count == 0)
                return false;

            return DocumentAttributes.Find(x => x.Key == "Owners")
                                                    .Select(s => int.Parse(s)).ToList()

As you can see, multiple users can be designated as an owner of a document. Any operation that is to be performed on a document can be quickly validated against the owner list, so actions such as deleting or displaying document can be quickly validated.  Since the attributes are stored as JSON, you can easily augment existing documents.

The possiblities here are quite exciting. Perhaps you are looking for a quick an easy way to store configuration of objects but XML would prove to be too complicated to maintain. You could create an entry in the Document table with the attributes you wished to store and retrieve quite easily.  Or, you can easily create a categorization system for documents that sit out on shares and you need to correlate these documents to records in a accounting package.  There are numerous things you could do to make your life easier.

Full source code will be posted soon where an in depth discussion of the implementation will continue.

The Economics of Authority – Windows Workflow and Why You Should Cash In Before Rolling the Dice January 18, 2010

Posted by ActiveEngine Sensei in ActiveEngine.
Tags: , , , ,

Although many measure their success by their salaries, bonuses and bank accounts, this report card can be a limiting factor when starting a new endeavor. If you follow this train of thought too closely your creative muscles will atrophy and very likely you will be unable to capitalize on opportunities as they arise. Or worse yet, you will be unable to recognize the need for you to break out of mold.


Sometimes you can obtain a payment of a different kind from struggling with a new idea: authority, recognition, reputation, knowledge, and maybe skill. For those of you who are feeling limited by your development environments , flexing your creative muscles can be an even greater challenge. There is also a danger for a great many of those who are too comfortable, as they are so accustomed to their current development frameworks they don’t know that they are “out of shape”.

It is too easy to become a subject matter expert, drink the cool aid and parrot every podcast that you hear that technology X is the leading edge solution. Going to the next client offers a new opportunity to build a solution based on the gibberish that was misconstrued as leading edge. If it’s new enough then there is a chance that few others will be able to actually challenge the new silver bullet’s validity as a viable solution. In software we do this all the time. It is a form of lying. While in the short term it may appear that you are enhancing your authority by bringing new solutions to a client, in reality you are diminishing your authority.

2635045177_ab5d39ee34Getting out the big guns for a fight, Sensei is taking a stand as he recently repudiated the recommendation to use Windows Workflow Foundation.


The Economics of Developing iPhone Apps August 6, 2009

Posted by ActiveEngine Sensei in ActiveEngine, software economics.
Tags: , , , ,

Sensei has an iPhone and it is indeed a great technological achievement.  It just works.  Another attractive aspect to the iPhone is the lowe priced software available from the App Store.  We have all heard of the stories of the kid who made $40K by creating an app and selling it.   At Coding Horror, Jeff Atwood posted his thoughts regarding the effect of lowering the cost of a software product and how that can create a jump in sales.  In short, the lower priced software makes up for the loss with volume.  starwars-iphone

There are other considerations to be kept in mind before diverting your talent to iPhone application development.  The economics of surviving in that envirnoment are hazardous.   (more…)

The Economics of Protecting the Red Shirts July 29, 2009

Posted by ActiveEngine Sensei in .Net Development, ActiveEngine, Business Processes, Coaching, Design Patterns, Mythology, Personal Development, Problem Solving, software economics.
Tags: , , , , ,

Recently I came across this post from a fellow lamenting the lack of interest on the part of .Net developers in architecture solutions such as IoC, Dependency Injection, ORMs, and the like.  800px-KirkSlapsSelfThis stood out in stark contrast to Java developers who this person interviewed, who either were conversant with the technology or were interested enough to pursue informing themselves further.  Some call this the result of Drag -n -Drop design as laid out in a post  by Greg Young, a Microsoft MVP and .Net developer who has specialized in high performance applications.  Greg maintains in his post Java vs. .Net Developers that drag and drop is mis applied and there needs to be an greater effort the isolate the cases where it is mis used.  This practice has arisen, he maintains, from poor training and lack of awareness of other development platforms. (more…)

%d bloggers like this: