Cleaner Code through Less Variables

by percent20 10/31/2007 6:03:00 PM
I am often times wondering how I can write cleaner better code that is effective, but not reeeeealy long. As a beginner this is something you wish you can do, but blow it off until you get better at programming feeling eventually you’ll “get it”.

Often times with beginners there might be code that looks like this.

public void Display(string s1, string s2)
{
    string sentence1 = s1;
    string sentence2 = s2;
    Console.WriteLine(sentence1 + ". " + sentence2);
}

While this may look odd there are plenty of examples of SIMILAR code in beginners. And as you have probably figured out an easy way to shorten the code would be to do this.

public void Display(string s1, string s2)
{
    Console.WriteLine(s1 + ". " + s2);
}

The code looks cleaner and slimmer and a little easier to understand. So I recommend to write cleaner looking code try to get rid of as many variables as you can, but be careful not to take away to many.

Again I just want to re-iterate my purpose for these types of posts is to help beginners in places I wanted/needed help on with I first started, and still need help on to some degree.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

10-31-07 Picture (Quicktrip)

by percent20 10/31/2007 5:43:00 PM
This place almost has a cult following.
Quicktrip

Currently rated 1.0 by 2 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Picture of the Day

10-30-07 Picture (My office)

by percent20 10/30/2007 5:40:00 PM
Buddy Lindsey's Desk

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Picture of the Day

The Problem newb Software Development Tutorials

by percent20 10/29/2007 6:09:00 PM
The Problem newb Software Development Tutorials

As a person that has spent a lot of time on my own to learn software development, and pretty much anything beyond school, I have often seen that there is a HUGE lack of resources for the beginners. While there is some it isn’t very good at all, sorry. I have spent the last couple of years trying to learn C# and ASP.NET and only through hand holding of teachers and long exhaustive talks with people that know A LOT more than I do, have I been able to learn.

This to me shows one of two things that trouble me.

    1) The people that write content for beginners don’t know how to write content for beginners.
    2) The learning curve is EXTREMELY high for programming.

Personally, I think it is a mix between both. As some people get more advanced as developers they tend to talk and meet with people that know as much or more than them as developers and they start to grow. When this happens people tend to forget what it is like to be a beginner and try to throw to much at them at once without any thorough explanation at all.

This brings me to the point of my post. I plan to start doing more “technical” blogging about subjects I am learning in programming, but my goal is to write it so those that are beginners, much like I still am, will understand what is going on. This means no one line code snippets, but full methods/functions to long detailed explanations. These I believe add value and make things easier. Here is an example of what I mean code wise.

Instead of comparing a string to null or “” just use the String.IsNullOrEmpty(stringVariable); method. ( I have seen this and dismissed it because I don’t get it )

This is what I would do for a post or an explanation

Acceptable code:

string var = null;

if(var == null || var == "")
     DoSomething();


Better code:

string var = null;

if(String.IsNullOrEmpty(var))
     DoSomething();

As you can see this will demonstrate through straight code what people usually do, then showing with full code what can be better to do. This however assumes you understand how you can use if statements with bools.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.NET

BlogEngine.NET Extension for Del.icio.us

by percent20 10/27/2007 1:39:00 PM

Today I wrote an extension for BlogEngine.NET. Basically what it does is when you publish a new post it add a link to it on your del.icio.us bookmarks. I consider this an v0.5 release because there are still a few things I need to do. A roadmap for now is

1) Better comments/documentation
2) cleanup the code a bit
3) add error handling
4) delete the bookmark if post is deleted
5) make sure it doesn’t add another bookmark when you hit save after editing a post.

Other possibilities
1) config file
2) Suggestions from others

Download BlogEngine.NET Extension for Del.icio.us

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

BlogEngine.NET | Awesome Stuff | Programming

Site News (Please read)

by percent20 10/25/2007 1:38:00 PM

For those subscribed to my feed, all 4 of you, I will be changing over to a new blog engine to make the migration easier please change your subscription feed to:

http://feeds.feedburner.com/Buddylindsey

By doing this when I convert over it doesn’t affect you at all.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Uncategorized

Scoble on short video’s

by percent20 10/21/2007 1:37:00 PM

I grabbed this link off of twitter.

http://www.seesmic.com/Standalone.html?video=q198zI6FYR

All i have to say is. RIGHT-ON

p.s. @Robert Scoble if you are reading this thanks for the add on twitter.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Uncategorized

Day 3 and 4 of 30

by percent20 10/2/2007 1:35:00 PM

So, I didn’t blog yesterday and I should have. I worked yesterday on my programming side and did some community service stuff with the Boy Scouts.

On programming side I wrote a tutorial having to do with OOP and XNA you can see it at Ziggyware.com. So I have done some good things in the programming area :D I have also thought of some interesting blog posts to make with regards to programming we will see if I can make anything of them.

That was yesterday. Today I worked a bit on the foreign language department since I spent i’d say around 30 minutes working on my Japanese skills. I think I have introductions down pretty well now and can move more into basic conversation, finally. It will take time, but I have confidence I’ll eventually be able to speak Japanese. Then I only have 3 other languages to learn at least.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Uncategorized

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen


My Flare

AddThis Feed Button

National Blog Posting Month

Eagle Scout

I'm Test Driven

[Reserved for MVP status I want to earn]

View Buddy Lindsey's profile on LinkedIn

Twitter



Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in