Wednesday, November 29, 2006

Vindication is best eaten cold....

An article sort of backing up what I was saying about not needing to learn C, and highlighting the bad points about C that I was alluding to. I guess my point was that we shouldn't need to worry about these things in 2006.

Tuesday, November 28, 2006

Build your own bit of history

The Altair kit helped kick start the computer revolution in the 70's. You can buy one and live(or if you're old enough relive) a bit of history.

Altair Kit

Monday, November 27, 2006

Why should you learn C?

Ok my previous post was not very constructive.

So I started off with the intention of posting a counter to my original argument. I was going to list the reasons why a programmer in 2006 should learn C. I was going to suggest that to be a C programmer you need to understand principles such as memory allocation and deallocation, pointers, creating string handling routines - basically all the things we dont need to worry about with languages like C# and Java.

Then I thought, why? Unless you intend to do embedded programming, really you DON'T need to know C. Even then you could probably use C# or Java, depending on the platform. C still has a place sure, but it's becoming like COBOL these days. Was great in the day, but has been superseded by newer, frankly easier to use languages.

Someone in the previous post suggested my arguments don't have enough substance, so I thought I would post some code examples of two basic programming functions in C and the equivalent in C# to highlight my issue with C. (My C is a little rusty so apologies if I have the function names wrong etc)

String Concatenation
C:

char * ReturnStringProduct(char * str1, char * str 2)
{
if (str1 == null !! str2 == null)
return null;
char * product;
product = (char *)malloc((strlen(str1) + strlen(str2) + 1) * sizeof(char));
strcpy(str3, str1);
strcat(str3, str2);
return product;
}

C#

private string ReturnStringProduct(string str1, string str2)
{
return str1 + str2;
}

Converting Int to a String
C:


There is a function called itoa, but I believe that it isn't in the ANSI standard so found a routine that did this on the net

void strreverse(char* begin, char* end) {
char aux;
while(end>begin)
aux=*end, *end--=*begin, *begin++=aux;

}

void itoa(int value, char* str, int base) {

static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz";

char* wstr=str;

int sign;

div_t res;

// Validate base

if (base<2 || base>35){ *wstr='\0'; return; }
// Take care of sign

if ((sign=value) < 0) value = -value;

// Conversion. Number is reversed.

do {
res = div(value,base);
*wstr++ = num[res.rem];
}while(value=res.quot);
if(sign<0) *wstr++='-';
*wstr='\0';
// Reverse string

strreverse(str,wstr-1);
}

C#
intVariable.ToString();

Should All Programmers Learn C? I don't think so.

This list looks like it has been written by a 12 year old.

To say *every* programmer should learn C is complete idiocy. I can't think of a single reason why *every* programmer should learn C in 2006. In fact the only reason I can think of to use C would be for Device Drivers. I know probably 200 developers. How many write device drivers - none.

Even things like Micro-controllers have embedded JVM's these days.

A counter argument would be that things like JVM's, databases, Operating Systems are written in C. This may be true, but again how many people actually write these? Maybe 5-10% of all programmers.

Oh hold on. Games. They are predominately written in C++. Some could argue that is C, although comparing C++ with C is like comparing C# with C. Sure they may *look* the same but they are about as similar as a Daewoo and a Ferrari.

Anyway here is the list with my rebuttals:

1) C is lower level then other programming languages (C++, Java). Programming at a lower level allows you to further your understanding of computers, as a whole.

Bit of a hoary old chestnut that one. Sure you have to allocate/deallocate your own memory, and string handling is a bit ugly but other than pointers (and C++ has those too) C is not really that different.

2) Device drivers and operating systems are written exclusively in C. Now, you may never write a device driver or an operating system, but what if you are ever required to modify one?

That is completely false I'm afraid. Device drivers are written in C++ these days (remember C++ is no closer to C than C#). There is an OS (singularity) with the Kernel, OS and device drivers all written in C#. I have to concede that some parts are written in C.

3) What if you ever want to get a job programming microcontrollers? They are programmed in C. Are you going to limit your possible list of jobs because you didn't want to learn a new language?

Again a lot of microcontrollers are Java based so this argument falls down. The other part to the argument is non nonsensical. Just because you know C, doesn't mean you know anything about microcontrollers. Also I don't know how to fly a plane either. Am I limiting my possible list of jobs?

4) C programs are smaller and faster then any other program created in a different language. Sometimes your program needs that speed boost that only C can give it.

A complete fallacy. A program is as fast as its bottleneck and in most circumstances this is the person in front of the keyboard. Also this argument is like saying an Indy car can go 400km/h and an F1 car can only go 360km/h. Therefore an Indy car is faster....

5) If you have learned C, you can learn any modern programming language. The reason behind this is that all modern programming languages are based on C (Java, C++, C#, etc).

Most modern languages are far more than the syntax. .NET and Java have huge frameworks you need to learn that have nothing to do with the fact the a for loop looks the same in C, Java and C#

6) Because C has been around for many years, it has a large community and collective code base. This allows you to quickly and efficiently implement new algorithms or functions that have been programmed before.

Um have you not heard of google? I can't remember the last time I couldn't find a solution to a particular programming problem I have had. I program using C#, Delphi and C++

7) C is the language of the Open Source community. The Open Source poster child, Linux, was coded in C. If you know C, you can participate in and contribute to numerous Open Source communities like Source Forge.

Can't argue with that. Also the poster couldn't argue with the fact that there are just as many Java, or C# or Delphi open source projects

8) C is the only language that teaches you what pointers really are. C# and Java skip the subject completely. It is pointers that give C its power.

And it's pointers that give C it's largest problem. I'd rather let Gurus write a compiler or Framework for me that takes away the need to worry about the nuts and bolts, and lets me get on with writing the application.

9) C is still the most commonly required language for programming jobs. It is well worth your time to get C under your belt.

Well this is arguable too. There is estimated to be more COBOL code in the world. Does that mean we should all learn COBOL too?

10) Anything that has a microprocessor in it has support for C. From your microwave to your cell phone, C powers technology.

Yip and there are usually other options too. I can program my Cellphone in Visual Basic if I want to....

Dont get me wrong. In certain circumstances C is the best fit, and I cut my teeth in the late 80's with C. But to say that every programmer should learn it is a little overstating things IMHO.

Friday, November 24, 2006

Building the Perfect Beast

This is a great article. I agree completely with Joel (usually do). I think this completely sums up the difference between programmers, developers, software engineers (geeks) and designers. A designer would have an off button, and we as developers tend to completely over engineer things and have every possible option we can think of.

I have being recently working with designers building websites. They think differently. It's a fact. And it's a good thing I think. Designers don't understand the short comings of CSS and HTML, and really that doesn't matter. We as programmers should find ways to implement their design where absolutely possible.

This should definitely apply to Software Applications too. UI should be fun and importantly, easy to use. It hardly ever is though. Why? Because most software UI is designed by the guy who writes it and never uses it. I hear users complain the software they use being useless. Usually it's not, but the UI and ease of use suck, so the user equates that to the software as a whole.

The other thing we need to do is to stop developing applications with the expert in mind. Most of the applications I use show all the options available to all users. Most users don't care about 80% of the stuff you can do in Word for example, when all they want to do is write a letter, so why should they see it. The ribbon bar is going some way I guess but we are a long way off building the perfect beast.

I think plugin schemes should be used more. Software shouldn't be all things to all people out of the box. I use Excel a lot but only for doing basic number crunching. Why can't I get Excel Basic, and if the day ever arose when I needed Graphs, I could purchase the Excel Charting plugin. You could charge $99 for Excel base and then say $50 for plugins. Not only could it potentially lower the bloat of modern software, but it could stop Piracy as users would have no reason not to pay.

Sometimes simpler is better....

Thursday, November 23, 2006

Debugging Compact Framework Apps on Vista

My trials and tribulations developing on Vista continues. As you may or may not know, Vista has a standard applet called "Windows Mobile Device Center" (another great name from the MS marketing department who get paid per word), instead of Active Sync.

This is great for Joe Schmuck who wants to plug in their Pocket PC or whatever. However if you are a developer like me it is a PITA. Visual Studio 2005 expects to see Active Sync, so when you try to debug/deploy it cant find AS so it throws a wobbly. A 30 minute intensive trawl on Google found the solution so here goes:

Basically because VS wants Active Sync, we must trick it into thinking it is still there. So open RegEdit and go to "HKLM | SOFTWARE | Microsoft | Windows CE Services".

If there is a key in there called MajorVersion, change it to 4 (mine was 6) and MinorVersion to 0. If they aren't there add them - they are DWORDS.

Restart VS and Roberts your mothers brother you should be able to deploy/debug to your PPC device.

Monday, November 20, 2006

What is your bloglebrity status?

I am a D-List blogger, but only miss out on being C-List by one link. Go on someone link me and let me move up the list ;-)

Article here

Vista Debugging IIS 7.0

Vista is a bit of a PITA for developing on. Because programs aren't run as admin by default, things like remote debugging and attach to process don't have the required permissions.

If you are opening an existing site in VS2005 and trying to debug by attaching to a process, you need to do the following: Tip/Trick here

Vista and SQL Express

For those of you using Vista and SQL Express you should read this
Blog post

Basically Vista doesn' give full admin rights to your user, and SQL Express kinda assumes you are. The post explains well.

Downloading SP2 of SQLExpress will also fix, but it is only CTP at the moment.

Sunday, November 19, 2006

Woohoo

I have finally made it into the top 10 list on On Blog list! Thanks to those that have helped me get me to where I am today, and above all else, thanks to the Office floor for all it's support. Virtual choccie fish to anyone who can answer where that rather obscure quote originated from.

Hint, you would need to have played 8bit games in the 80's.....

Saturday, November 18, 2006

Vista first Impressions

I downloaded Vista Ultimate off MSDN yesterday. I have just finished installing now and have been playing with it for the last 20 minutes or so. I couldn't get the Betas to work for me, so I am a Vista noob.

I upgraded from XP, rather than starting fresh. It installed/upgraded without a hiccup on my Dell Inspiron 9400 Lappie. I only have the Intel onboard graphics, so things could be a little better there, but I have 2Gb Ram and 2Ghz Duo Core, so no shortage of grunt to run things. It runs about as fast as XP. Somethings take a little longer to load, some take less. Internet seems a little faster, although it is getting pretty late (12am) so that is probably as much a factor.

The warnings when trying to run Sysadmin type apps are a little annoying. The sidebar gadgets are great and have downloaded a few extra's. Once either yahoo messenger or Gaim becomes available as a gadget that will be even better.

I guess the major change is the Aero interface. I must say I like it a lot. Seeing as I have fairly lowly graphics, my system is probably not doing it justice. Having said that it is still (IMHO) more of a programmers take on how good UI should be, rather than a designers idea. KDE and OSX are still better, with XGL on KDE showing genuine ingenuity. One thing I wish MS would "borrow" from X Windows is the virtual desktop system. It is the main thing missing.

Overall though I think Vista is a worthy successor to XP and I rate it so far as a 7/10. Well worth upgrading to.

Tuesday, November 14, 2006

ICT WTF?

<rantMode>
I get NZ Computer World delivered weekly. It's a so so industry rag to be honest. It has very little local content, with most of the articles coming from the US sister publication. It's a little disappointing to me they don't use more local writers to produce articles. There is a strong I.T. community in NZ and many of these people produce blogs and are good writers whom could do as good a job as a US expert.

These sort of weekly publications are becoming less and less relevant in the age of the blog, but hey it's a tax right off and some of the articles are good.

Anyway, I have noticed that in the last few weeks they have been pushing the phrase I.C.T. like crazy. It stands for Information and Communications Technology apparently, instead of just Information Technology which is the current standard. Call me old fashioned but isn't "Information and Communications" a redundant statement? What is communication without information? Waffle perhaps? Hmmmm. Journalists. Waffle. Yeah I guess I shouldn't be surprised. (Those who can: do. Those who can't: write (Yes I do see the irony there)).

BTW anyone who is really involved with "IT" would rather die than call themselves ICT professionals. I much prefer any of Techie, Developer, Geek or even Computer Guy. ICT sounds like something a politician invented.</rantMode>

Sunday, November 12, 2006

Box Model Hack

I used to be blissfully unaware of things such as the Box Model Hack.

As primarily a Windows App developer, and sometimes ASP.NET developer I didn't need to know about the intricacies of CSS and standards compliant XHTML. I have been doing a lot more Web Apps/Sites of late and have unfortunately come across the "wonders" of IE's interpretation of how HTML should be rendered. I now understand the hate and vitriol web coders have for IE. All I can say is download FireFox and use it. The more people using Firefox the better in my opinion.

Two reasons:
1 - it's a better more secure browser
2- it renders HTML the way it should be rendered

I'll get back to my CSS file now and try and get the site I'm coding to look the same in all browsers. That aint easy ;-(

Wednesday, November 01, 2006

(C#) Interview Questions

Seems to be the trend at the moment to post some interview questions on your blog. So not being one to buck a trend, I thought I would do the same.

Some of the questions I have seen are more pop quiz types questions. For example: Name 5 C# data types?
To me these questions like this are stupid. I don't care if someone can recite the entire class library word for word, I care about how much of an understanding of actual programming someone has. My questions are more aimed at creating an insight into how someone thinks, and perhaps starting a discussion. I prefer open ended, no one right answer questions.

Without further ado, here are my questions...

1. What are you thoughts on the following?:

try
{
...
}
catch (Exception ex)
{
...
}

The answer should create an insight into how deeply the developer thinks. I think catch all exceptions are the devils spawn, but would be interested in learning justification someone might have for using

2. Name your favourite feature of .NET 2.0? Why?

Just a matter of interest. Should get the person talking.

3. Explain the difference between an Interface, and an Abstract class.

If the person knows the difference then it shows they have created bases classes or at least know about OO programming.

4. In your opinion, when should you use each?

Just to try and see if they have an understanding of the difference, not just know what each is.

5. How do you define the n-tier model?

Again it should be reasonably clear from the answer if the person has actually don e n-tier design/programming

6. When passing data between tiers, do you prefer passing a custom class, or something else such as a Dataset? Why?

Always interesting to hear peoples approach to this. Also it demonstrates what level the person has. I.E a junior - intermediate may not have had to worry about this before.

7. Who is Anders Hjelsberg?

I would want people who take an interest in the language they use. If they do then they will know who Anders is, or at least heard of him

8. Explain the terms Pascal Casing and Camel Casing.

Most people should know what these mean, although not a show stopper if not

9. Explain your coding standards for: a member variable, a parameter, a method, a class an interface and a local variable.

This question just shows if people have thought about standards or not. Any good developer should have a fixed standard they stick to. It is good to discuss their reasonings for using a particular standard. For example I use m_(camelCase) for member variables because I feel it is easier to read and harder to transpose the variable by mistake.

10. What is your understanding of a business layer?

Everyone has a different idea about what a Business Layer should be and do.

Coding Tasks

Here are some coding tasks that could be given at an interview. Obviously not enough time to do them all....

1. You are creating a basic accounting application. Create a business layer stub which would allow the application handle Creditors, Debtors and Invoices. Just create any classes needed, the variables needed and the method headers. In each method, just add a comment as to what the method will do. As a starting point, the database has been created where the business data will be persisted to.

I think this would be an interesting task to give. It shows the interviewee's ability to take a problem and apply their skills to it. We're not really that interested in the actual coding, just the design and thinking behind it. I would expect most people to either create custom classes based on the database, or create an approach based on datasets which will be passed between layers. I am a student of the Rocky Lhotka approach to business layers where the business classes shouldn't just replicate the table design, it should define a behaviour, and can include data from several tables.

2. Create a simple Webservice that given two numbers, returns the sum of these two numbers.

3. Create a console application that consumes the Webservice created above.

Fairly simple task that anyone worth hiring should handle in 30 minutes or so.

4. Give them an application with a number of bugs, some compile time, some runtime and get them to fix as many as possible in a given time.

5. Explain to the interviewee that they can use any datastore they like - have MS Access, SQL Express, SQL Server installed on the test machine - create a simple application to store contact details.

Give no hints on what you are after, give them a set time (60-90 minutes) and then let them loose. Good developers should work out what is important given the time constraints. I would prefer a well engineered solution that wasn't finished, than a slap happy finished product. Above all else it should show how people think about design and give an indication about their ability. Afterwards, let them explain why they did X and give justifications for that approach.

Comments welcome....