473,598 Members | 3,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Design Guidelines

I have been reading "Design Guidelines for Developing Class Libraries" at
http://msdn2.microsoft.com/en-us/library/ms229042.aspx. Is it correct that
they are recommending camelCase for private member variables? Doesn't this
create problems for case-insensitive languages when we create a private
member variable along with properties?

For example

Private thisIsAVariable As Int32

Public Property ThisIsAVariable As Int32
Get
Return thisIsAVariable
End Get
Set(ByVal Value As Int32)
thisIsAVariable = Value
End Set
End Property
--
Tom Stevens
Jul 31 '07 #1
12 1298
=?Utf-8?B?VG9tKys7?= <To**@newsgroup .nospamwrote in
news:99******** *************** ***********@mic rosoft.com:
I have been reading "Design Guidelines for Developing Class Libraries"
at http://msdn2.microsoft.com/en-us/library/ms229042.aspx. Is it
correct that they are recommending camelCase for private member
variables? Doesn't this create problems for case-insensitive languages
when we create a private member variable along with properties?

For example

Private thisIsAVariable As Int32

Public Property ThisIsAVariable As Int32
Get
Return thisIsAVariable
End Get
Set(ByVal Value As Int32)
thisIsAVariable = Value
End Set
End Property
VB is case insensitive, so the code above will not compile.

Similar code in C# will compile (since it's case sensitive) but it won't
cause a problem in VB.NET since one of the variables is private, thus not
accessible when referenced.

Jul 31 '07 #2
AFAIK the code will compile , however if you access the property it wil
overflow ( stack overflow , eg out of memory exception )

most common is :

Private m_thisIsAVariab le As Int32
Public Property ThisIsAVariable As Int32
Get
Return m_thisIsAVariab le
End Get
Set(ByVal Value As Int32)
m_thisIsAVariab le = Value
End Set
End Property
i found this to be a verry valuable book

http://www.amazon.com/Practical-Guid...5860444&sr=8-3

"Spam Catcher" <sp**********@r ogers.comschree f in bericht
news:Xn******** *************** ***********@127 .0.0.1...
=?Utf-8?B?VG9tKys7?= <To**@newsgroup .nospamwrote in
news:99******** *************** ***********@mic rosoft.com:
>I have been reading "Design Guidelines for Developing Class Libraries"
at http://msdn2.microsoft.com/en-us/library/ms229042.aspx. Is it
correct that they are recommending camelCase for private member
variables? Doesn't this create problems for case-insensitive languages
when we create a private member variable along with properties?

For example

Private thisIsAVariable As Int32

Public Property ThisIsAVariable As Int32
Get
Return thisIsAVariable
End Get
Set(ByVal Value As Int32)
thisIsAVariable = Value
End Set
End Property

VB is case insensitive, so the code above will not compile.

Similar code in C# will compile (since it's case sensitive) but it won't
cause a problem in VB.NET since one of the variables is private, thus not
accessible when referenced.

Jul 31 '07 #3
Hi Tom,

VB.NET is a case-insensitve language, and on the contrary C# is a
case-sensitive language.
Doesn't this create problems for case-insensitive languages when we
create a private member variable along with properties?

Yes, it would create a compilation error when a private member variable has
a same name as a public property ignoring the case. The sample code you
showed would generate a compilation error.
Is it correct that they are recommending camelCase for private member
variables?

Could you please tell me where you read it from?

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 31 '07 #4
Michel,

As addition I never use an underscore in VB.Net.

For me is an underscore a kind of mix between Hungarian notation and Pascal
case in my opinion and hard to use on the US keyboard because it needs a
shift and I can not reach that because I have learned and use forever blind
typing and than that underscore is reachable for me but not common.

I just use only the m in this case.

(Just to give another opinion for others)

Cor

"Michel Posseth [MCP]" <MS**@posseth.c omschreef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
AFAIK the code will compile , however if you access the property it wil
overflow ( stack overflow , eg out of memory exception )

most common is :

Private m_thisIsAVariab le As Int32
Public Property ThisIsAVariable As Int32
Get
Return m_thisIsAVariab le
End Get
Set(ByVal Value As Int32)
m_thisIsAVariab le = Value
End Set
End Property
i found this to be a verry valuable book

http://www.amazon.com/Practical-Guid...5860444&sr=8-3

"Spam Catcher" <sp**********@r ogers.comschree f in bericht
news:Xn******** *************** ***********@127 .0.0.1...
>=?Utf-8?B?VG9tKys7?= <To**@newsgroup .nospamwrote in
news:99******* *************** ************@mi crosoft.com:
>>I have been reading "Design Guidelines for Developing Class Libraries"
at http://msdn2.microsoft.com/en-us/library/ms229042.aspx. Is it
correct that they are recommending camelCase for private member
variables? Doesn't this create problems for case-insensitive languages
when we create a private member variable along with properties?

For example

Private thisIsAVariable As Int32

Public Property ThisIsAVariable As Int32
Get
Return thisIsAVariable
End Get
Set(ByVal Value As Int32)
thisIsAVariable = Value
End Set
End Property

VB is case insensitive, so the code above will not compile.

Similar code in C# will compile (since it's case sensitive) but it won't
cause a problem in VB.NET since one of the variables is private, thus not
accessible when referenced.

Jul 31 '07 #5
<stupidity modus >
AFAIK the code will compile , however if you access the property it wil
overflow ( stack overflow , eg out of memory exception )
</stupidity modus >

No it wil NOT compile , although Sharpdevelop wil only show a message when
you compile the code VS.Net 2005 refuses to compile the code and shows the
messages inmediatly
To Cor :

Well i guess it is just a mather of taste

in VB6 i used mVar_Propertyna me
the VB.Net C# best practices and guidelines book says m_Propertyname
i also see a lot of code with _Propertyname ( probably because COM hides _
prefixed names to the outside world )

but i guess m ( module member ) allone would also be clear and uniform
enough

"Michel Posseth [MCP]" wrote:
AFAIK the code will compile , however if you access the property it wil
overflow ( stack overflow , eg out of memory exception )

most common is :

Private m_thisIsAVariab le As Int32
Public Property ThisIsAVariable As Int32
Get
Return m_thisIsAVariab le
End Get
Set(ByVal Value As Int32)
m_thisIsAVariab le = Value
End Set
End Property
i found this to be a verry valuable book

http://www.amazon.com/Practical-Guid...5860444&sr=8-3

"Spam Catcher" <sp**********@r ogers.comschree f in bericht
news:Xn******** *************** ***********@127 .0.0.1...
=?Utf-8?B?VG9tKys7?= <To**@newsgroup .nospamwrote in
news:99******** *************** ***********@mic rosoft.com:
I have been reading "Design Guidelines for Developing Class Libraries"
at http://msdn2.microsoft.com/en-us/library/ms229042.aspx. Is it
correct that they are recommending camelCase for private member
variables? Doesn't this create problems for case-insensitive languages
when we create a private member variable along with properties?

For example

Private thisIsAVariable As Int32

Public Property ThisIsAVariable As Int32
Get
Return thisIsAVariable
End Get
Set(ByVal Value As Int32)
thisIsAVariable = Value
End Set
End Property
VB is case insensitive, so the code above will not compile.

Similar code in C# will compile (since it's case sensitive) but it won't
cause a problem in VB.NET since one of the variables is private, thus not
accessible when referenced.


Jul 31 '07 #6
"Michel Posseth [MCP]" <MS**@posseth.c omwrote in news:#1e30Vz0HH A.1208
@TK2MSFTNGP03.p hx.gbl:
AFAIK the code will compile , however if you access the property it wil
overflow ( stack overflow , eg out of memory exception )
I dont' think so?
Private thisIsAVariable As Int32

Public Property ThisIsAVariable As Int32
Get
Return thisIsAVariable
End Get
Set(ByVal Value As Int32)
thisIsAVariable = Value
End Set
End Property

Won't it say thisIsAVariable has already been declared?
Jul 31 '07 #7
"Tom++;" <To**@newsgroup .nospamschrieb:
>I have been reading "Design Guidelines for Developing Class Libraries" at
http://msdn2.microsoft.com/en-us/library/ms229042.aspx. Is it correct that
they are recommending camelCase for private member variables?
No, there is no recommendation for naming private variables because these
variables are not part of the interface.
Doesn't this create problems for case-insensitive languages
when we create a private member variable along with properties?
Yes, it would not be possible in VB at all, and it's a bad idea in other
programming languages too because it can lead to nasty mistakes when
identifiers get mixed up, potentially bypassing validation code, and code
still compiles.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jul 31 '07 #8
The following link refers to "Member Design Guidelines"

http://msdn2.microsoft.com/en-us/library/ms229057.aspx

The code sample shows "dataValues " being defined camelCase (although it is
defined as public). they show the property that accesses the array has the
name "Data". It is an example of bad design, but it is the only place that I
could find an example of a member variable.

I have always defined a member variable as follows:

Private m_Data As Integer()

and named the property the name without the "m_" prefix (for example, "Data")

The "General Naming Conventions" in the ".NET Framework Developer's Guide"
state that I should not use an underscore '_' character. What is the naming
convention for a private member variable that will work with the CLR and all
languages?

"Linda Liu [MSFT]" wrote:
Hi Tom,

VB.NET is a case-insensitve language, and on the contrary C# is a
case-sensitive language.
Doesn't this create problems for case-insensitive languages when we
create a private member variable along with properties?

Yes, it would create a compilation error when a private member variable has
a same name as a public property ignoring the case. The sample code you
showed would generate a compilation error.
Is it correct that they are recommending camelCase for private member
variables?

Could you please tell me where you read it from?

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 1 '07 #9
Hi Tom,

Thank you for your reply.

I look into the MSDN library for naming fields, but don't find a recommeded
way to name a field. Perhaps, there's no recommended way to name a field.

I find a sample provided in MSDN library which implements a composite
control. The private fields of the composite control are defined as follows:

Private colFColor as Color
Private colBColor as Color

And the corresponding public properties are defined as below:

Property ClockBackColor( ) as Color
' Retrieves the value of the private variable colBColor.
Get
Return colBColor
End Get
' Stores the selected value in the private variable colBColor, and
' updates the background color of the label control lblDisplay.
Set(ByVal Value as Color)
colBColor = Value
lblDisplay.Back Color = ColBColor
End Set

End Property

Property ClockForeColor( ) as Color
Get
Return colFColor
End Get
Set(ByVal Value as Color)
colFColor = Value
lblDisplay.Fore Color = ColFColor
End Set
End Property

In my opinion, as long as the name of a field doesn't break the rules that
the 'General Naming Conventions' makes, the name should be good.

If you have any concern, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Aug 2 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4939
by: wycklk | last post by:
Suppose: Process 1 contains: AppDomain A, AppDomain B Process 2 contains: AppDomain C Is there any design guidelines on partitioning the AppDomain (for example, I should put AppDomain C within Process 1 instead of Process 2 for better performance vs stability etc) ?
0
1210
by: Bob | last post by:
Is there a complied Word document for the "Design Guidelines for Class Library Developers" instead of hyperlinked HTML pages?
0
463
by: Patrik Berglund | last post by:
Hi! Does anyone know if there is a downloadable and printable version of the "Design Guidelines for Class Library Developer" on MSDN? Having a printed version for reference and reading seems to me a _much_ more efficient way of having the document than the current click-o-mania on the MSDN site. /Patrik
0
1856
by: JKJ | last post by:
I'm not an OOP guru, but I would say ". . .not necessarily" What if the base class and derived classes are internal? Then the base class has to be within the same assembly to be inherited from. You may want to create several classes that are used throughout the assembly, but are not accessible outside the assembly. . . If your base class will be inherited across multiple assemblies and future applications, then I would then
3
1986
by: Michael Roper | last post by:
http://tinyurl.com/2vnd This is a very painful section to navigate as every atomic bit of information gets its very own page. Is this information available anywhere in a more printer-friendly version? Or even better, in a book? Michael Roper
2
1555
by: Michael R | last post by:
Hey folks... Does anyone know if there is a Microsoft doc out there that give guidelines on developing a GUI interface? i.e. The look and feel of it, and how it's supposed to flow? Thanks, --Michael
3
4664
by: Leslie Sanford | last post by:
I have a hierarchy of message classes. Many times when messages are created/received by a class, an event is generated to let the outside know. Also, the message is passed along when raising the event. To follow the .NET event guidelines, each message class therefore needs its own EventArgs derived class to represent it. The problem is that these EventArgs classes do not add anything of value themselves. There is no additional event data...
7
1293
by: Dave | last post by:
What books, articles, guides, etc. would you recommend on good GUI design principles and practices? Thanks. Dave
1
1391
by: SemSem | last post by:
iwant to know if there any way to make awell design forms as ithink .net can offered to me good design tools ineed to kow how idsign an asp well design site and if there techneques are used in designing ihear something like css or style sheet ihope to find enough infomration from somebody. Thnax at all
0
7991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7902
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6719
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2412
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1250
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.