C# vs. VB

Does coding in these languages make you understand the .NET framework better or worse? I would argue that it just confuses and muddy’s up any significant cognitive comprehension of the vast framework we now know as .NET. It really confuses the pillars of OO like abstract inheritance and interface implementation, by swash-buckling in a sea of keywords and syntax that just confuse things. My feeling is that it really is an impediment to truly “flowing” in the .NET framework. My personal preference is C#, it has terse syntax, but yet not impossible to comprehend and pickup. And the moment you believe you will dedicate yourself to just one language, you end up getting challenged in the other. And as programmers, it’s hard to resist challenges. It’s all about the Flow, whats your Flow? C# or VB?

Posted in Uncategorized | Leave a comment

Paradigm Shift taking hold

The functional hype is starting to make sense. I have been reading up on Functional programming, and am beginning to see the light. I am also learning up on TDD with Mocks. Trying to figure out how I can converge these two strong streams into a synthetic whole. I have been learning JMocks before I move on to .NET Mocking Frameworks. Along with being a Remote DBA, it is a pretty scattered landscape for me. Always learning, never knowing

Posted in Uncategorized | Tagged | Leave a comment

namespace manager required

using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;

namespace consAppXpath1
{
class Program
{
static void Main(string[] args)
{
//load xml
Byte[] content = System.Text.Encoding.ASCII.GetBytes(Properties.Resources.TestConfigInNamespace);
MemoryStream memoryStream = new MemoryStream(content);
XPathDocument doc = new XPathDocument(memoryStream);

//setup xpath processing
XPathNavigator nav = doc.CreateNavigator();

NameTable nt = new NameTable();
XmlNamespaceManager xnmgr1 = new XmlNamespaceManager(nt);
XmlNamespaceManager xnmgr2 = new XmlNamespaceManager(nt);

xnmgr1.AddNamespace("x", nav.NamespaceURI);
xnmgr2.AddNamespace("a", "http://www.adatum.com");

XPathNodeIterator ni = nav.Select("/a:Tests/a:Test/a:CommandLine", xnmgr2);
string result = (ni.Count > 0) ? "selection exists" : "no selection";
Console.WriteLine(result);

foreach (var item in ni)
{
Console.WriteLine("command line is {0}", item);
}

Console.ReadKey();
}
}
}

So, when processing XML in .NET, you must address the namespace question, whether it is default or null or even multiple namespaces within one xml document, otherwise, you will fall short of getting what you are after. Whether that be XPath or even LINQ to XML, so get familiar with the XmlNameSpaceManager object, you will be glad you did.

Posted in Code-ing, Uncategorized | Leave a comment

I like AOP

by Mathew D. Groves… “Whatever tool you decide to use, AOP will help you do your job more
effectively. You’ll spend less time copying and pasting the same boilerplate code
or fixing the same bug in that boilerplate 100 times. In abstract terms, this helps
you adhere to the single responsibility principle and use the open/closed principle
effectively, without repetition. In real-world terms, it will allow you to spend more
time adding value and less time doing mindless, tedious work. It will get you to
happy hour faster; whether happy hour is a literal happy hour at your local pub, or
your son’s baseball game, AOP is going to help you get there.”

Posted in Uncategorized | Tagged | Leave a comment

Learning Node.js

Learning Node.js from the Beginner’s tutorial…
var http = require("http");
var url = require("url");

function start() {
function onRequest(request, response) {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname + " received.");

response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World-9");
response.end();
}

http.createServer(onRequest).listen(8888);
console.log("Server has started.");
}

exports.start = start;

Posted in Uncategorized | Leave a comment

Crockford-The Good Parts

There are four patterns of invocation in JS:

  • the method invocation pattern,
  • the function invocation pattern,
  • the constructor invocation pattern and
  • the apply invocation pattern.

The patterns differ in how the bonus parameter [[this]] is initialized

Posted in Uncategorized | Leave a comment

Anonymous functions in JavaScript

If you need recursion, then name a function, but if you don’t, un-naming a function is fine … in other words, anonymous functions will do just fine when you don’t need recursion

var add = function(a,b) {
 return a+b;
};
Posted in Uncategorized | Leave a comment