|
-
May 19th, 2004, 01:54 PM
#1
Thread Starter
PowerPoster
OMG, information overload!
Everyone,
The MS Patterns and Practices team has put together something just truely amazing. It is a lot to read, but there is some great knowledge in there if you are a .Net developer. Check out this little sample tip I picked up:
Know the Cost of Accessing a Property
A property looks like a field, but it is not, and it can have hidden costs. You can expose class-level member variables by using public fields or public properties. The use of properties represents good object-oriented programming practice because it allows you to encapsulate validation and security checks and to ensure that they are executed when the property is accessed, but their field-like appearance can cause them to be misused.
You need to be aware that if you access a property, additional code, such as validation logic, might be executed. This means that accessing a property might be slower than directly accessing a field. However, the additional code is generally there for good reason; for example, to ensure that only valid data is accepted.
For simple properties that contain no additional code (other than directly setting or getting a private member variable), there is no performance difference compared to accessing a public field because the compiler can inline the property code. However, things can easily become more complicated; for example, virtual properties cannot be inlined.
If your object is designed for remote access, you should use methods with multiple parameters instead of requiring the client to set multiple properties or fields. This reduces round trips.
It is extremely bad form to use properties to hide complex business rules or other costly operations, because there is a strong expectation by callers that properties are inexpensive. Design your classes accordingly.
Just plain awesome if you ask me. Here is the link:
http://msdn.microsoft.com/netframewo...l/scalenet.asp
-
May 30th, 2004, 05:52 PM
#2
Frenzied Member
Truly amazing! Thanks m8! Wonder when I will find time to read all this... wish I had a data port connected to my brain.. just a matter of uploading and compiling
.net architecture rulez!
kind regards
Henrik - currently thriving into the world of .NET Remoting
-
Jun 21st, 2004, 04:47 PM
#3
Fanatic Member
guide yeah right, more like, HOW TO CODE .NET CORRECTLY to me, A BLOODY BOOK
but should make good reading while downloading a log file
nice one
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|