Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Saturday, May 9, 2009

pass the variable, please


One property that has tremendous bearing on any programming language is how variables are passed. There are generally two methods, passing by reference and passing by value.

Passing by reference takes the memory location of the variable or pointer and passes that into the function that takes the parameter. In short, this means that any work or changes done to the object or primitive is changed for good.

The other method is passing by value. This copies the reference to the object or variable and passes it in to the function. This allows for manipulation with the data from the variable or object without changing the actual contents of the data.

Both of these methods are valuable, and in my opinion the languages that can do both (like C#) are especially useful. In fact, this is one of the differences between Java and C#, Java only passes by value, C# allows passing by reference (through the ref keyword.) Without being able to pass by reference, Java becomes a more strongly-typed langauge, you have to go further to manipulate actual data. However, this also makes a simple program like swapping two string variables inordinately complicated compared to languages that pass by reference.

Knowing which technique the language you are using implements is of primary importance, failure to recognize whether a language passes by reference or by value will cause hours of frustration in seemingly inexplicable errors and unexpected return values.

Sunday, April 26, 2009

5 Ways to Become a Better Programmer

Here are five easy ways to become a better programmer. Think of these more as a mindset, rather than a checklist of things to do. If you follow these steps and make them attitudes, you will grow in programming by leaps and bounds.

1. Write Programs - Ok, I know this sounds like a no-brainer. Really though, it all starts by typing code. Often starting here can help you ask the right questions, and really help you with some of the things further down the list. Check out my post on tips and resources for coming up with programs to write.
2. Spend Time on Forums - Forums can be a great place to ask questions and learn about all kinds of programming topics. Don't worry if some of it (or a lot of it) goes over your head. Keep browsing and interact when you can. As long as you ask questions in the right manner (most programming forums have a sticky about this: READ IT!) forum-goers are generally a helpful lot. This is also a good place to do number 3...
3. Look at Other's Code - This can be a great help when you are looking for programs to write, if you are stuck in a program, or just want to learn something new. Looking at other's code can help you find shortcuts in syntax and show you quicker ways of doing things. Also, reading another person's code is an invaluable skill: Get good at it!
4. Look Up What You Don't Know - This is probably the most important one of the bunch. It works along with all of the other steps. If something goes over your head, or you can't seem to work something out, ask and research. There is so much information in the computer world it is impossible to have a handle on even half of it. Asking questions and researching any piece of information can help you learn much quicker. This is a life concept I try to implement every day. From acronyms to programming concepts, to words - If you stop to look things up, you will gain in knowledge very quickly then if you just gloss over things.

And now for some shameless promoting...
5. Read This Blog - Surfing the web in general for Programming info is a great idea. I try to point you to the good stuff to make your search a little easier and provide little tidbits of knowledge on various topics. I hope you find this blog useful.

So there you have it, five ways to becoming a better programmer. More to come in the future I am sure, but these are some concepts I have found invaluable. Happy learning...

Monday, April 20, 2009

Regular Geek

This is an excerpt from another blog, I think it has some nice insights:




  • Creation - Some people really enjoy the ability to create something. You start with a blank canvas, or an empty file, and you write code. Eventually that code gets compiled, packaged or whatever and becomes an executable thing. For something like a web site, you actually get to see and interact with your creation.

  • Instant Feedback - Right on the heels of creation is the instant feedback. This is true when you are programming in languages like C++ and Java as well as “really instant” changes like web sites. For programming, you get the code-compile-test cycle giving you the feedback. For web sites, you can change some basic feature and just reload the page in order to see your new results.

  • Puzzles and Problem Solving - Some people, like myself, just love to solve puzzles or various problems. In many cases, this is almost an addiction. These same people probably love to complete puzzles like Sudoku or crosswords. In “modern” terms, you can consider this a “House-complex” (after the fantastic TV show) where solving the problem is the only thing that matters.

  • People - Do you get to meet fascinating people in the software development industry? Yes, absolutely. However, many people get into software development because they do not like people. In product development companies, the programmers can all be “in the back room” and not deal with business people, customers or users. They get their needed (and limited) human interaction by dealing with other programmers.

  • See a Need, Fill a Need - Some people get into programming completely by accident. They may work in drug development research as a scientist, but they need someone to gather data and run complex analysis or simulations. In many cases, there is no funding in the budget for a new hire so that person learns to program. Eventually, they either become too valuable as a programmer or they “fall in love” with software development and they have a new career. This probably happens more often than you think, as there are a lot of programmers who do not have a formal computer science education. This is also good for the industry as it brings a different perspective into development, instead of all the people learning all of the same theories.

  • Money - There are plenty of people who start a career in software development because they want to make a lot of money. In reality, you can make a very good salary in software development, but that can not be the only reason for joining the field. If one of the previous items is not true in your case, you will hate programming within two years. Also, some people see how much money startups can make and figure they just need to learn to program a little to get there. Well, most startups fail to make any money and most programmers do not work at startups.

  • robdiana in Programming, Regular Geek, Mar 2009


For me the 1st and 3rd reasons are it. They are absolutely my bread and butter. Number two just makes life easier. What about you?

Revamping Old Code



remember that program you had to write for your C++ class... Rewriting your old code can be a great way of learning another language. By rewriting something that you already know in a different way, you can quickly pick up new syntax.

This isn't just a great way to learn a new language; It is also a great way to improve your programming skills. Go back and look at some of your old programs. Chances are, you will find ways to improve their implementation, either in speed or amount of code.

For example, I recently took an old piggybank program I had to write in C++ and converted it to Python. All this simple program did was asked for a dollar amount and turned it into the least amount of change. Back when I wrote it for the first time, I used all if statements. While I was re-writing it in Python, I discovered that I could create a better implementation using modulus arithmetic.

Isn't it great how you can learn new material on your old material. Any other suggestions on re-using old code to teach yourself?

Sunday, April 19, 2009

Programming to Program



To learn to program you must program. This is a concept that a lot of time flies over beginners. They get excited about coding, but instead of grinding out some code, they read tutorial after tutorial, or search through the web looking for something that isn't there.

But, once you realize this concept, what do you do about it? It can be pretty tough to think up a program to write yourself. One of the things that I have learned is that often, if you aren't in a class or some environment that forces you to learn, i.e. gives you tasks or assignments, it can be difficult to push yourself.

Probably the best learning tool that can be found on the internet is programming challenges. These appear in books and forums. Someone gives a list of programming quandaries as a challenge to other programmers to solve. These can greatly help you learn to program faster, sharper, and more efficiently.

A great place to find these are forum threads. Right now Programming Forums has some great challenges out there. There is also an e-book that has challenges in it, with robotic judges as well.
These challenges are your best friend, they invite you to program, and even give you what to program. You can't help but learn. Great Stuff!! If you have any sites that you have found, or have made yourself, post them below!