| Tramp Variables Posted by: Jordan in Object Oriented Programming on Oct 05, 2008 |
I was reading an OOP design pattern book and it mentioned creating Tramp Variables. This was the first time I'd heard this particular term used to describe a function variable and it actually made me laugh. I did a search on google for "Tramp Variable" and couldn't find anything relating to what I'm fixing to write so this term must be relatively new, extremely old (and unused), or something the author of the book made up.
Anyway, we should start by defining a tramp. Wikipedia describes it as this:
Reading the definition above it is easy to deduce what a tramp variable is: a variable that is passed from function to function to function.

A tramp variable is not a good thing. You can avoid it using certain design patterns and if you find yourself creating a bunch of tramps, you may want to reconsider you code!
If you've heard this term before, post what you know!
Anyway, we should start by defining a tramp. Wikipedia describes it as this:
... a tramp is a long term homeless person who travels from place to place as an itinerant vagrant, traditionally walking or hiking all year round. They often left chalk signs on houses or at various points along their traditional routes. They also developed a slang language of their own.
Reading the definition above it is easy to deduce what a tramp variable is: a variable that is passed from function to function to function.

- function someFunc(int var) {
- // Some Code Here
- someFunc2(var);
- }
- function someFunc2(int var) {
- // some code.....
- }
- void main() {
- int myVar = 2;
- someFunc(myVar);
- }
function someFunc(int var) {
// Some Code Here
someFunc2(var);
}
function someFunc2(int var) {
// some code.....
}
void main() {
int myVar = 2;
someFunc(myVar);
}
// Some Code Here
someFunc2(var);
}
function someFunc2(int var) {
// some code.....
}
void main() {
int myVar = 2;
someFunc(myVar);
}
A tramp variable is not a good thing. You can avoid it using certain design patterns and if you find yourself creating a bunch of tramps, you may want to reconsider you code!
If you've heard this term before, post what you know!
Set as favorite
Bookmark
Email This
Hits: 221
Trackback(0)
Write comment
