PASSING OBJECTS PARAMS AS BY VAL INSTEAD OF BY REF MIGHT MAKE YOUR APPLICATION LIKE A MESS??

HI GUYS

I'm checking out a web application developped by an outsorcing company.. well that proyect doesn't work fine for many reasons . It's writting in vb.net and suddenly I realized that they pass ALL Objects by val (let's say that an object is a List of 10000 objects , where every object is a query record) . I remember the times when I read from the first (Visual Basic 5) about passing parameters that you've got to pass objects as ref and primitive variables as by value.. but now I see this .... and all methods pass objects as byval.. there might be about 200 methods in that proyect

Can anyone tell me that I'm not that crazy
edwbear1976aAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
Hi edwbear1976a,

ByVal it's the way dy default. You can use ByVal or ByRef. Check in here the diferences http://msdn2.microsoft.com/en-us/library/ddck1z30(vs.71).aspx

jpaulino
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andrewneelyCommented:
From my understanding, .net differs from c++ in that byref in C++ passes only a reference (read:  pointer) to the object, and .net passes a copy of the object.  The copy is destroyed on completion of the funciton call if passed byval and copied back if passed byref.  That's why byref is slower than byval.
0
Snarf0001Commented:
You don't really need to be worried.

.NET has 2 different "types" of variables / data, value types and reference types.
value types are basic values (int, float, double, etc..), and references are classes, objects, or basically anything more complex.

When you declare a reference type (ie a list), you actually only get a pointer or "reference" to the object, and not the object itself.  So when you pass a list into a function as byval, the "value" you're passing in is still just a pointer to the list, and not the data in the list itself.
You can still modify / add / remove items from the list, and the changes will affect the original object.

THe only time you need to specify byref for reference types, is if you're going to actually change the object itself, and not just it's contents.  For example, if you passed in a null list, and set it to "new List()" inside the function, then those changes will not propogate.
0
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

edwbear1976aAuthor Commented:
Hi you guys and thanx for the comments
well I'm worried for things that I always knew and andrewneely says : -- That's why byref is slower than byval--. well I'm trying to improove that web application performance . I also now that There are 2 types of object no matter if you pass it it by val or by reference (Arrays,Classes : byRef) simple variables (Int32, Int64).. well what I have always understood is that when you pass by Ref and Object "byRef type" you store  in the stack a reference or "pointer" to the heap, but when you pass an object byVal  the value of that object is copied in the stack (Int32:640,char: "A" and so) so I've got to understand that no matter I pass an object (type by ref) as by val or by ref its behavior will be the same.
The Fact is that the proyect I'm checking out has got a lot of methods and they only pass objects byVal...I have to face that now things are different with .NET FRAMEWORK  and maybe for the best.
0
Jorge PaulinoIT Pro/DeveloperCommented:
I think that the most important here is not the performance that you will achive changing one thing to another. The most important is, like as you can read in the posts, what you can do with a method and another. The most important thing regarding with performance are the database handling over the web page.
0
andrewneelyCommented:
It is one thing to be aware of the trade-offs in a programming language as it pertains to performance.  It's quite another to try to refactor code to be faster when it's "fast enough" already.  jpaulino is right to say "The most important thing regarding with performance are the database handling over the web page"

There are a few areas where optimizaton for speed is critical.  DB access, routines that need to deal with real world events as they happen, and inside of loops that have hunderds or thousands of iterations.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.