sweet syntactic sugar
consider the following chunk of code:
List<Person> people = db.GetAllPeople();
foreach (Person p in people){
console.writeLine(p.Name);
}
Day dreaming during a tech.ed lecture this morning, I thought:
Ah, but what if the syntax waz reversed?
What if the following code compiled to the same thing under the hood....
List<Person> people = db.GetAllPeople();
in (people visit Person p) {
console.writeLine(p.Name);
}
Okay... it mightn't change our lives... but it's a wacky thought none the less. Don't reject it too quickly. Drink it in. Suck it up. Chew on it. Swill it around before you spit it out.
When you type the words "in (people visit
..." the intellisense would have a chance to think:
people hey?? What type of objects are collected inside that? Person is...
You'd get a nice little intelliswiftness in there i thinks.
Nextly, whatif, instead of calling a Object.Method(), we allowed the syntax: Method Object, for example, instead of:
console.writeLine(p.Name);
Imagine you were allowed to say:
WriteLine Console (p.Name);
That's right!
Method First, Object Aft!
When you write the method name "Writeline" the intellisense then thinks to itself...
Writeline hey?? What objects do i have with that method? What static methods do i have with a method like that?
This is a different kind of intellismarts you're calling on -- it's about putting verbs before nouns, like that steveyegge article joel spolsky pointed to recently (you know the one). tink about it.
Next → ← PreviousMy book "Choose Your First Product" is available now.
It gives you 4 easy steps to find and validate a humble product idea.