Friday, February 28, 2014

NoProgramming

Can we survive the onslaught of frameworks that makes our job easier and could potentially make our jobs obsolete?

First, there's No Software, then there's NoSQL, now No Programming is needed when making an application. Ok I exaggerated a bit, in this stage of technology we can now learn to make applications with almost no programming background required.

You got a complete list (no paging) of data a user wanted to filter, it would be overkill to re-fetch the data from the server as all the data being used on filtering are already at the client-side. We can use some jQuery skills or some good ol' DOM manipulation skills to do that task. But who would do that when the No technologies are all the rage now?

Here's one of the many ways to do no programming with AngularJS, enjoy! Active filtering: http://docs.angularjs.org/api/ng/filter/filter

Programming required to fit the filter requirement of clicking the search button first: almost no programming required http://fiddle.jshell.net/G8z9Q/

Thursday, February 13, 2014

Sparrow Framework newbie: Run is not available on project


Run is not available on Scaffold project:




Switch to Scaffold project:

When DEFAULT doesn't default

I almost gave a wrong code review to a colleague:


It's better to use NOT NULL:

ALTER TABLE dbo.blah
ADD IsTransferred BIT NULL DEFAULT (0);

Is there a business or technical reason why IsTransferred should be nullable?

On the above DDL for IsTransferred, nullable or not nullable, IsTransferred defaults to 0, hence this is a superfluous code:

-- initialize new column, i.e., NULL columns, to "not transferred"
UPDATE dbo.blah
SET IsTransferred = 0
WHERE IsTransferred IS NULL ;


Further read: http://sqlblog.com/blogs/hugo_kornelis/archive/2007/07/06/null-ndash-the-database-rsquo-s-black-hole.aspx

The code could be shortened and optimized but I'm not inclined to advise it; this query is just a one-time thing, no need to micro-optimize. The code is good enough


Spotted the wrong thing on the above advice? The above advice is correct if we are using PostgreSQL. However we are using SQL Server, the newly-added IsTransferred field will default to null if the field is nullable regardless of the above DDL indicating a default value of false(0).


So the UPDATE above is not a superfluous code, at least on SQL Server, the UPDATE is still needed despite the DEFAULT 0 clause. PostgreSQL (and other RDBMSes for that matter) is intuitive in this regard, it honors the DEFAULT clause regardless of the field is nullable or not.


Further read: http://sqlblog.com/blogs/hugo_kornelis/archive/2007/07/06/null-ndash-the-database-rsquo-s-black-hole.aspx


PostgreSQL-related news: https://twitter.com/spolsky/status/433323487961178113



Happy Coding! ツ