Sunday, November 2, 2008

Let that boy copy paste (with SQL2005 and Excel)

I heard Papa tell Mama
Let that boy copy paste from SQLServer2005 to Excel
It's in him
And it got to come out

John Lee Hooker - Boogie Chillen (1948)

Being a software engineer - I pretty much hate messing with DBs.

Nonetheless, more often than not, even the brightest designers - such as myself - are called to get their hands dirty with some SQL or moving some data around when the team's DB guy (usually indian) is badly sick at home.

I remember how painful it was the first time I had to understand with SQL2000 how to export to excel a simple resultset from a select - must have wasted a full afternoon of frustration trying to do that a few years back. 

A couple of months ago I was shocked in discovering that with SQL2005 you can just select all and copy/paste a resultset to excel. This means that if you have to import/export some records you don't need to mess with import/export wizards and all that comes after. Shrinking to 3 clicks (select all - copy - paste) a 5 minutes painful procedure. 

Forget about TRY CATCH, CLR support, and all that fancy stuff, copy/paste to/from excel is my favourite SQL2005 new feature (ok - this sounds something like 3 years late, but it's not what this post is about).

DB purists might not like it but copy/paste is "de way 2 go".  


kick it on DotNetKicks.com

Saturday, October 25, 2008

[Blogger] How to dinamically change Blog Title

You can dinamically change your Blogger Blog title to whatever you want (in this case you're changin it into 'NEW KICK-ASS TITLE') using the following Javascript snippet:


var myKickAssScript = "document.getElementById('header-inner').getElementsByTagName('h1')[0].innerHTML = 'NEW KICK-ASS TITLE'";
setTimeout(myKickAssScript, 2000);



We have to set a timeout in order to wait for the title element to be injected by the blogger engine. You can put this js code in the script element that's in the head section of the markup (you can edit it from 'edit HTML' section on your blog settings). 
If you put the snippet (passed as string to the timeOut function above) at the bottom of the page (or as event handler for the onLoad event) you obviously don't need to set up a timer.


It'll work as long as they decide to keep the page markup as it is now.

P.S. check-out my NEW KICK-ASS TITLE

Friday, October 24, 2008

[C++] convert std::string to const char * (and back)

Kind of a lousy-ass post but Straight to the point (with UNICODE on):

#include <string>
using namespace std;

//..

//from std::string to const char*
string originalStr("Bunny Colvin Kicks Ass");
const char* cnstCharPtr = str.c_str();

//the other way around
string convertedStr(cnstCharPtr); //as simple as this
 
I found myself googlin' this up a number of times and I always forgot everything soon enough since I don't use it often. I decided to post it as a reference for myself and to increase chances to find an answer for anyone else who might be looking for it.

Cheers

Wednesday, October 22, 2008

The Unmentionable NECRONOMICON of WinApps (BAD Code is Language Independent)

I am working on a MFC app internally referred as the unmentionable NECRONOMICON of WinApps. This thing is a dying beast composed by an indefinite number of dlls: it seems put together as an ad-hoc example of the so-called DLL HELL. It compiles and builds by magic and by magic only. The thing is so scary no-one ever attempted touching it for 7 years or so. There are stories about the last guy who tried to fix a few bugs: he went crazy and left the company with no reason (OK, he just left the company). 

Anyway, most of this thing is coded in C++ and MFCs (except a bunch of cryptic COM components in VB6 and stuff which hopefully I'll never have to touch).  After having a thorough look at the code I can say that YES, the app is way far from being mainteinable, but - surprise - it's not because of C++. Same stuff written in C# would scare eggs out of (SCRUM) chickens.

Loads of people seems to hate C++, because it's error-prone (...), verbose, kinda cranky and not that cool anymore. Most of them probably don't even know about copy-constructors and destructors otherwise they'd hate C++ even more. I agree with most of this complaints and no-one would ever dream of developing a brand new WinApp today using MFCs. We got away from that and now we can focus on making cool apps, not just "working" ones.

Getting to the point, the fact that C++ apps do not write themselves seems to be ignored - people tend to forget one of the basic laws of programming: BAD code is language independent.

P.S. Wish me luck, I need it

Sunday, October 19, 2008

Software Development Methodologies Zoo


[Waterfall - 1970]
The waterfall model is a sequential software development process (...) in which development is seen as flowing steadily downwards (like a waterfall) through the phases of requirements analysis, design, implementation, testing (validation), integration, and maintenance.
You can't stop a waterfall - meaning that if you're in the middle of a project and requirements change ... well ... let's say you're in troubles.


[V-Model - late '80s]
The V-model is a software development process which can be presumed to be the extension of the waterfall model. Instead of moving down in a linear way, the process steps are bent upwards after the coding phase, to form the typical V shape. The V-Model demonstrates the relationships between each phase of the development life cycle and its associated phase of testing.



This is a zombie model, it's dead but plenty of ISO and CMM fanatics out there think V-Model is still pretty cool. V-Model is indeed a very good methodology for high-ceremony organizations for its ability to give management a sense of false security.


[Cowboy Coding - wild west]
Cowboy Coding is a term used to describe software development where the developers have autonomy over the development process. This includes control of the project's schedule, algorithms, tools, and coding style.

In an ideal world, this would be my favourite. Whenever I start my own company I am pretty sure I'll adopt and formalize Cowboy Coding [yippy kayay!].

[SCRUM - early '90s]
Scrum is an iterative incremental process of software development commonly used with agile software development. (...)
Scrum is a process skeleton that includes a set of practices and predefined roles. The main roles in Scrum are the ScrumMaster who maintains the processes and works similar to a project manager, the Product Owner who represents the stakeholders, and the Team which includes the developers [chicken and pigs!].
During each sprint, a 15-30 day period (length decided by the team), the team creates an increment of potential shippable (usable) software. The set of features that go into each sprint come from the product backlog, which is a prioritized set of high level requirements of work to be done.


Conceptually born in early '90s, SCRUM started being widely adopted 10 years later. It's like the model farm of AGILE software development with ScrumMaster to coordinate chicken and pigs. All you need to know is pigs do all the work.

[ICONIX - late '90s]
ICONIX is a software development methodology which predates both the Rational Unified Process (RUP), Extreme Programming(XP) and Agile software development. Like RUP, the ICONIX process is UML Use Case driven but more lightweight than RUP. Unlike the XP and Agile approaches, ICONIX provides sufficient requirement and design documentation, but without analysis paralysis. The ICONIX Process uses only four UML based diagrams in a four step process that turns use case text into working code.
A principle distinction of ICONIX is its use of robustness analysis (...). This process makes the use cases much easier to design, test and estimate.

ICONIX basically combines an AGILE approach with a robustness oriented low-ceremony design. This Process carries the strictly necessary amount of weight to still ride fast. This is the process I use at the moment, you can read more about it on this post.

[Extreme Programming - XP]
Extreme Programming (XP) is a software engineering methodology prescribing a set of daily stakeholder practices that embody and encourage particular XP values. Proponents believe that exercising these practices—traditional software engineering practices taken to so-called "extreme" levels—leads to a development process that is more responsive to customer needs ("agile") than traditional methods, while creating software of better quality.
Proponents of Extreme Programming and agile methodologies in general regard ongoing changes to requirements as a natural, inescapable and desirable aspect of software development projects; they believe that adaptability to changing requirements at any point during the project life is a more realistic and better approach than attempting to define all requirements at the beginning of a project and then expending effort to control changes to the requirements.
XP is all about speed, and we all like speed if it means no documentation. Biggest drawbacks of this approach may be problems like feature creep and scope creep - moslty due to lack of persistent reference.