Variable Usage: Span and Live Time

posted on 2004-11-12 at 23:36:06 by Joel Ross

I've been (slowly) reading Code Complete. Tonight, I started chapter 10: General Issues in Using Variables. In 10.4, Steve talks about two measurements that you want to try to minimize: average span and live time.

Span is the number of lines of code between between references to a variable. The average is a total of all of the spans, divided by the number of variable references minus 1. For example:

int a = 1;
int b = 2;
int c = a + b;

The variable a has a span of 1 - one line between it's initialization and it's next reference. The variable b has a span of 0. There are no lines between the two references. The gist of what the book says is that by keeping the uses of a variable close to each other, it will be easier to figure out what the value for a variable will be.

On the other hand, live time is the time a variable is in play. It is the number of lines from first reference to last reference. In the example, a has a live time of 3, while b has a live time of 2. The argument for a short live time is twofold. First, by declaring and initializing variables close to where they are used, you can ensure that the value of the variable isn't changed in other parts of the program. Second, if you limit the use of a local variable, it will be easier to refactor because you don't have to worry about references to the variable spread throughout the whole method. It's use will be contained.

The book says you should try to minimize both, but my question (and belief) is this. If you keep the average span low, does it really matter if the live time grows? Obviously you don't want to let your methods grow to be huge, but if you are utilizing the variable over and over, does the live time really matter? Or am I off base here?

The next section, which relates to the above is about variable scope. I've never done any testing, but I'm curious about one thing. In C#, if you declare a variable inside a loop, it's scope is local to that loop particular loop only. Is that more or less efficient than declaring a variable outside the loop and initializing it inside the loop?

You see, I need to know these things. I don't want my code ending up on The Daily WTF!

Categories: Development


 

Sagestone on MSDN

posted on 2004-11-12 at 08:07:41 by Joel Ross

It looks like a few people from Sagestone have put together an article, and got it published on MSDN. I saw a demo of VSTO from these guys, and it was very cool.

Congratulations to Kevin, Kevin, Pam, Aisha and Lionel. Great job guys!

Categories: Development


 

Using Google Desktop Search With Other File Types

posted on 2004-11-12 at 07:51:27 by Joel Ross

I downloaded Google Desktop a while ago, and was a little disappointed that you couldn't specify which file types to index. Specifically, wouldn't it be nice to index your source code? Then, when you have a problem, and you know you've done something like that before, you can search your local drive for it. To me, that would make it much more useful.

So that's why I was happy to see this site. With this, now you can specify which file types to search, and Google Desktop will index them.

One word of caution. It involves installing hacked versions of the desktop executables and registry editing. So if that bothers you, go ahead and skip this one.

Categories: Software


 

Images And Url Rewriting

posted on 2004-11-12 at 00:58:05 by Joel Ross

I read this post over a month ago, and knew it would come in handy sooner or later. Today it did. Before, all of our rewriting was from one folder deep to one folder deep. But today, we added a rewrite from two folders deep to one folder deep, and our images were broken.

So I dug up Scott's post, and he saved the day. And it didn't cost me $75! Actually, that's twice now. His original MSDN article is what I used to do our rewriting (well, sort of).

Categories: ASP.NET


 

.NET 2.0 Property Access Modifiers

posted on 2004-11-12 at 00:45:31 by Joel Ross

Rob over at the Robertson Research Institute is at Whidbey Ascend this week in Texas, and has been providing some good insights about Whidbey.

His latest though, is about properties. You can now have different access modifiers for set and get - so a get could be public, but a set could be protected. Very cool!

Categories: Development


 

Skype API In Action

posted on 11/12/04 at 12:37:59 am by Joel Ross

On my blog, I added a something new. It's my current Skype status. From it, you can click it to see my Q-Card, where you can leave me a message to call you, and I get an IM from Jyve telling me you want me to call you. You can send me a phone number, or your Skype ID. If you're interested, you can sign up for free (there are other features too), and get a 45 day trial of the Q-Card page. Go check it out.

Want to try the API out for yourself? Over at http://www.geocities.com/skypeapi/ someone posted a COM dll and some sample code that uses the Skype API. It's on geocities, so who knows how long it will be up (those pages tend to disappear quickly). I have the documentation, the library, and the VB.NET sample downloaded though, so if you can't get to the page, let me know. I'll send it your way. I tried out the sample app, and was able to change my Skype Status through the API. I didn't try too much else, but that was pretty cool.

This is getting exciting. I'm still waiting for a way to call a Skype user from a regular phone. Maybe Skype needs a phone number, and everyone gets an extension? 1-800-SkypeMe maybe?

Categories: Software


 

List Of Must Have VS.NET Add-Ins

posted on 2004-11-11 at 23:57:22 by Joel Ross

Scott Hanselman has a list of the ultimate VS.NET Add-ins. Of his list, I personally use the CodeSmith Explorer, CopySourceAsHtml, devMatrics, NUnitAddin, Reflector (although most of the time not as an add-in - not sure why though), WS Contract-First, and the VSCmdShell.

His list is pretty comprehensive, and provides links to each one. Go check it out.

Categories: Development


 

Week X NFL Picks

posted on 2004-11-11 at 23:49:23 by Joel Ross

It's crunch mode at work, so I'll make this short and sweet.

  • Baltimore (-1) vs. New York Jets: The Ravens are a solid defensive team who looks to be getting more and more comfortable as the season goes on. The Jets, with Pennington out, will have trouble getting Curtis Martin going, meaning they'll struggle offensively. Baltimore's offense isn't great, but it's enough to get some points on the board.
  • Pittsburgh (-4) vs. Cleveland: After taking out the top two teams in the league in back to back weeks, how can you pick against the Steelers. I can't.
  • Houston vs. Indianapolis (-9.5): This could be another shootout. Houston has a pretty good offense, and Indy's defense is pathetic. And it doesn't really matter how good the Texans are on defense - Manning doesn't care. He'll still put up three or four touchdowns on you.
  • Chicago vs. Tennessee (-5.5): Will McNair play? That's the big question, right? If he plays (and is healthy enough to play a good game), then Tennessee should roll. If not, this could be close. I'll still take Tennessee with the points though.
  • Tampa Bay vs. Atlanta (-4): Week 10. Even week. Atlanta rocks on even weeks. They'll win.
  • Detroit vs. Jacksonville (-3): Detroit on the road. Byron Leftwich out. A good combo for the Lions. Unless the crowd starts booing Harrington if he plays bad. But that won't happen on the road.
  • Seattle vs. St. Louis (PK): Seattle will be looking to avenge their earlier loss, which triggered a downward fall after that loss. Maybe beating them will help Seattle to regain their earlier swagger?
  • Kansas City (-4) vs. New Orleans: KC, despite losing to the Bucs last week, seems to be back on track. I'm not saying they'll make the playoffs, but they are definitely playing better. And the playoffs aren't out of reach, are they?
  • Cincinnati vs. Washington (-3): I'm not sold on Washington yet. Or the Bengals for that matter, but I think they'll pull off the upset here.
  • Minnesota vs. Green Bay (-4): Minnesota needs to get back on track, and regain focus. With Moss out, it will be difficult, but my gut says they'll win this one. And you know how good my gut has been!
  • New York Giants (-2.5) vs. Arizona: my PM asked me for a lock pick this week, and I hadn't even looked at the schedule yet. But I told him, "look at Arizona. Whoever they play, pick them." I couldn't not pick the Giants after that!
  • Carolina vs. San Francisco (PK): Wonderful match up! Combined record of 2-14! The only highlight is that one team will double their number of wins this week. And I think it'll be Carolina.
  • Buffalo vs. New England (-8): Eight points is a lot, especially considering Buffalo just beat the Jets. But I have confidence they can win by more than eight.
  • Philadelphia (-6) vs. Dallas: Not a bad MNF game, really. A divisional rivalry, and really, Dallas is only one game out of a playoff spot (despite being 3-5). Is this east coast bias? Woudn't Minnesota vs. Green Bay be a better game? Of course, Minnesota just played on Monday last week, so maybe that helped justify the decision. But what about Seattle vs. St. Louis? Anyway, Philly needs to prove they can handle losing, and come out and and take it to Dallas, which I think they will.

So there you have it. Probably starting next week, I'll start making some playoff predictions, or at least start looking at where teams are looking to line up.

Categories: Football


 

Visual Studio Web Projects, Without The Web Project

posted on 2004-11-11 at 00:37:24 by Joel Ross

Ever had problems with an ASP.NET web project and the source control integration? I have. Pretty much every time I've put a web project into source control. If it isn't the MyWeb_1 problems, it's a reference to third party components.

Obviously, others have had similar experiences. Plural Sight has a wiki dedicated to doing web projects without web projects. The next time I set up a web project, this will be how I do it!

Categories: ASP.NET


 

Skype API Is Official

posted on 2004-11-10 at 23:57:14 by Joel Ross

A couple of days ago, Skype officially announced their API. I find it ammusing that four links from the homepage, you can get to a PDF file (API documentation) that states on page one that says it "is considered to be strictly confidential." Wouldn't it be hard to have a confidential API? That defeats the purpose of having an API, doesn't it?

Anyway, the documentation looks very similar to the document I found a couple of weeks ago. There are two main ways to integrate with Skype. First, through a USB phone, you can make calls. And coincidentally, Siemens is offering a USB adapter that you can hook cordless phones to. This allows you to use a regular phone to make phone calls on the Skype network. Currently only in Europe, I'm sure it will make it's way across the Atlantic soon enough. So when I mentioned earlier that the only thing left was to call a computer from a real phone, this starts to get there. Granted, it's still a computer underneath.

The second part of the API is integrating applications with Skype. So now someone could write a tool for recording podcasts that utilizes Skype for making or receiving phone calls. Could we have a call-in podcasting show far behind? It looks like Qzoxy is the first company to release a toolkit utilizing the new Skype API, so it looks like some companies did get an early look at the API. With thier toolkit, "any Web designer can tackle the job of integrating Skype within their pages." They offer a Presense server - basically, is someone online right now?

With the new API, does this mean that help on websites will start to use Skype as a way to call support? That would be cool.

Thanks to Stuart Henshall for the information, who has a very interesting idea. How long until Presense is integrated into Outlook? Like MSN Messenger is now - see if they are online. Better yet, be able to make the call directly from Outlook. So now, I could send and receive blogs, send and receive emails, and make phone calls all from Outlook. A one stop communication stop!

Categories: Software


 

<< 1 ... 102 103 104 105 106 107 108 109 110 111 112 ... 124 >>