473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Ask for C# programming styles?

Hi all,

I used to be a Delphi progammer and swithed to C# recently. I know c# is a
pure OOP language. But my main goal is developing database application. In
delphi, I could put some DBconnections and datasets etc, in a runtime
invisible form and they are automatically public visible to other forms. But
in Visual Studio .NET, it seems that I could not do it like in this way.
Although I know that I could set all variables to public (which default are
private) to pass them around forms as parameters or even make them public
static, I still wonder if Visual .NET could make this process automatically
and I simply don't know it yet.

Another question is where I can find some programming conventions for c#?
For example, name conventions for files, classes names and control names?

Thanks in advance!

Karl
Nov 16 '05 #1
13 1223
The state-of-the-art in architecture and design methodology is called Model
Driven Architecture (MDA) also referred to as Model View Controller (MVC).
There are apparently some differences in implementation when used with any
given framework. The emerging Service Oriented Architecture (SOA) is also
proving to be a widely accepted methodology.

Start by diving into MSDN and read till your eyes sting :-)
Naming conventions and most everything else you need will be found there but
for the refinements found in the many blogs and of course this and related
newsgroups.
--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Karl" <Ka**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Hi all,

I used to be a Delphi progammer and swithed to C# recently. I know c# is a
pure OOP language. But my main goal is developing database application. In
delphi, I could put some DBconnections and datasets etc, in a runtime
invisible form and they are automatically public visible to other forms. But in Visual Studio .NET, it seems that I could not do it like in this way.
Although I know that I could set all variables to public (which default are private) to pass them around forms as parameters or even make them public
static, I still wonder if Visual .NET could make this process automatically and I simply don't know it yet.

Another question is where I can find some programming conventions for c#?
For example, name conventions for files, classes names and control names?

Thanks in advance!

Karl

Nov 16 '05 #2
State of the art? MVC is as old as Smalltalk (20+ years). Not that there is
anything wrong with it.

The MS .NET Design Guidelines for Class Library Developers:
http://msdn.microsoft.com/library/en...guidelines.asp

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
The state-of-the-art in architecture and design methodology is called
Model
Driven Architecture (MDA) also referred to as Model View Controller (MVC).
There are apparently some differences in implementation when used with any
given framework. The emerging Service Oriented Architecture (SOA) is also
proving to be a widely accepted methodology.

Start by diving into MSDN and read till your eyes sting :-)
Naming conventions and most everything else you need will be found there
but
for the refinements found in the many blogs and of course this and related
newsgroups.
--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Karl" <Ka**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Hi all,

I used to be a Delphi progammer and swithed to C# recently. I know c# is
a
pure OOP language. But my main goal is developing database application.
In
delphi, I could put some DBconnections and datasets etc, in a runtime
invisible form and they are automatically public visible to other forms.

But
in Visual Studio .NET, it seems that I could not do it like in this way.
Although I know that I could set all variables to public (which default

are
private) to pass them around forms as parameters or even make them public
static, I still wonder if Visual .NET could make this process

automatically
and I simply don't know it yet.

Another question is where I can find some programming conventions for c#?
For example, name conventions for files, classes names and control names?

Thanks in advance!

Karl


Nov 16 '05 #3
Les
Karl,
If you need somplace quick and dirty to put your globals into, put them into
a public or protected class with public vaiables. Your entire project will
be able to see them, just like in your Delphi days or in VB. This is not a
great nor even recomended way of doing things, but if you need to get going
in a pinch, it'll do it for you.

"Karl" wrote:
Hi all,

I used to be a Delphi progammer and swithed to C# recently. I know c# is a
pure OOP language. But my main goal is developing database application. In
delphi, I could put some DBconnections and datasets etc, in a runtime
invisible form and they are automatically public visible to other forms. But
in Visual Studio .NET, it seems that I could not do it like in this way.
Although I know that I could set all variables to public (which default are
private) to pass them around forms as parameters or even make them public
static, I still wonder if Visual .NET could make this process automatically
and I simply don't know it yet.

Another question is where I can find some programming conventions for c#?
For example, name conventions for files, classes names and control names?

Thanks in advance!

Karl

Nov 16 '05 #4
Yes, start off badly, write code with little or no structure, generate as
much spaghetti as you can and when you're done you'll see the benefits of
correct program design.

But seriously folks...

Karl, don't use global variables. C# doesn't cater for them and people who
use odd techniques to sidestep this usually end up in pain.

My own personal programming conventions, for what they're worth, can be
found on my blog http://bobpowelldotnet.blogspot.com

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Les" <Le*@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
Karl,
If you need somplace quick and dirty to put your globals into, put them into a public or protected class with public vaiables. Your entire project will be able to see them, just like in your Delphi days or in VB. This is not a great nor even recomended way of doing things, but if you need to get going in a pinch, it'll do it for you.

"Karl" wrote:
Hi all,

I used to be a Delphi progammer and swithed to C# recently. I know c# is a pure OOP language. But my main goal is developing database application. In delphi, I could put some DBconnections and datasets etc, in a runtime
invisible form and they are automatically public visible to other forms. But in Visual Studio .NET, it seems that I could not do it like in this way.
Although I know that I could set all variables to public (which default are private) to pass them around forms as parameters or even make them public static, I still wonder if Visual .NET could make this process automatically and I simply don't know it yet.

Another question is where I can find some programming conventions for c#? For example, name conventions for files, classes names and control names?
Thanks in advance!

Karl

Nov 16 '05 #5
on this subject...
why does everyone recommend not using Hungarian naming conventions in c# ? I
think it's very helpful!
Nov 16 '05 #6
> why does everyone recommend not using Hungarian naming conventions in c# ?
I think it's very helpful!
Ditto.

Cheers

Doug Forster

"Davids" <db****@simnet.is> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... on this subject...

Nov 16 '05 #7
Hi all,

Thank you for your wonderful advices on styles.

Still I have to make the first point straight. Because all the purpose of
dirty globles is to share them over forms (Not OOP thought). For example, if
I use private variable and create one atabase connection for each form, first
it is a kind of silly to me; second, if I forget to close the connection when
I switch to another form, I might run out of SQL server connection limits. So
I want to know that in C# database application, what is C# expert's
recommondation about where to put common used variables, such as DB
connections for sharing? And if Visual .NET IDE has some database form
similar to Diaphi?

Thanks,

Kai
Nov 16 '05 #8
Davids <db****@simnet.is> wrote:
on this subject...
why does everyone recommend not using Hungarian naming conventions in c# ? I
think it's very helpful!


advPersonally, proI vrbDislike adjHungarian nNotation. proI vrbFeel proIt
vrbMakes nThings adjHarder prpTo vrbRead.
Nov 16 '05 #9
Davids <db****@simnet.is> wrote:
on this subject...
why does everyone recommend not using Hungarian naming conventions in c# ? I
think it's very helpful!


1) It's error prone - it's very easy for a variable to change type
later in a project, but not renamed.

2) Some people (myself included) find it drastically reduces
readability - the code no longer reads in pseudo-plain English.

3) When using an IDE, hovering over a variable name gives you much more
information - it gives the actual type, along with any comments you've
added to explain the use.

4) Names should give semantic meaning which can be much richer than a
small set of pre-defined prefixes.

5) With so many types, either you need to make the set of prefixes
*huge* (and thus cumbersome) or all kinds of things end up as objFoo
which is almost entirely useless.

Personally I can't stand Hungarian, and am very glad it's being
discouraged by MS.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #10
Roy
> The state-of-the-art in architecture and
design methodology is called Model
Driven Architecture (MDA)
also referred to as Model View Controller
(MVC).


Model Driven Architecture (MDA) new way of writing specifications and
developing applications, based on a platform-independent model (PIM).
A complete MDA specification consists of a definitive
platform-independent base UML model, plus one or more
platform-specific models (PSM) and interface definition sets, each
describing how the base model is implemented on a different middleware
platform. A complete MDA application consists of a definitive PIM,
plus one or more PSMs and complete implementations, one on each
platform that the application developer decides to support.

From: http://www.omg.org/mda/
Nov 16 '05 #11
Excellent, and hilarious.
--
Grace + Peace,
Peter N Roth
Engineering Objects International
http://engineeringobjects.com
Home of Matrix.NET
"C# Learner" <cs****@learner.here> wrote in message
news:7l**************@csharp.learner...
Davids <db****@simnet.is> wrote:
on this subject...
why does everyone recommend not using Hungarian naming conventions in c#
? I
think it's very helpful!


advPersonally, proI vrbDislike adjHungarian nNotation. proI vrbFeel proIt
vrbMakes nThings adjHarder prpTo vrbRead.

Nov 16 '05 #12
As for naming conventions are concerned, the best naming convention is
that with which you are comfortable.

Some conventions you could consider are

1. Prefix the identifier with the data-type in small case
Eg - intScore, strName etc.

2. Use the Pascal naming convention (the default in C#) - the identifier
is in two parts as in "UserName", the first letter of the first word is
capitalized as is the first letter of the second word.

3. Use the Camel-casing convention (as in Java) (the default in VC#) -
the identifier is in two parts as in "userName", the first letter of the
first word is non-capitalized but the first letter of the second word is
not.
with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #13
I'd argue that the best naming solution is the one that makes your components look and feel like ones from the BCL. That means that people who use your components and maintain them will have familiar code to work with. You can see the guidelines that Microsoft publish here

http://msdn.microsoft.com/library/de...guidelines.asp

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

As for naming conventions are concerned, the best naming convention is
that with which you are comfortable.

Some conventions you could consider are

1. Prefix the identifier with the data-type in small case
Eg - intScore, strName etc.

2. Use the Pascal naming convention (the default in C#) - the identifier
is in two parts as in "UserName", the first letter of the first word is
capitalized as is the first letter of the second word.

3. Use the Camel-casing convention (as in Java) (the default in VC#) -
the identifier is in two parts as in "userName", the first letter of the
first word is non-capitalized but the first letter of the second word is
not.
Nov 16 '05 #14

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

Similar topics

0
by: Quinton | last post by:
I'm running a website that uses CSS to format the text and a CGI program Coranto that icludes news updates via SSI. My problem is that some parts of the CSS don't seem to take effect on the...
18
by: Chris Mantoulidis | last post by:
There is a LARGE number of syntax styles in most (if not all) programming languages. For example, one syntax style (my current one): .... int main() { for (int i = 0; i < 50; i++) {
12
by: dan.vendel | last post by:
Hi, I know nothing about javascript, but quite a lot about regulat html and CSS. Have bumped into a problem that people in this fine congregation perhaps can help me with. I'm making a...
4
by: Ed Davis | last post by:
I'm trying to decide which of the following programming styles is better, as in easier to understand, and thus easier to maintain. Keep in mind that for posting purposes, this is a greatly...
7
by: TechBookReport | last post by:
TechBookReport have just published a review of 'C Programming In Easy Steps', if you're a C beginner looking for an intro book (or an ex-C developer looking for a quick refresh), ready why this is...
3
by: JezB | last post by:
What's the generally accepted approach for using Styles and Stylesheets in a web application based on .aspx files, Web Controls, User Controls, and code-behind modules (c# in my case)? Most style...
3
by: Raed Sawalha | last post by:
I've been developing since year ago , I noticed that I developed my programming skills in first 6 months then , my coding style and strategy been the same, so what you advice me to develop my...
4
by: Sreekanth | last post by:
Hi all, I have implemented a timing out version of fgets function call. I am pasting the entire code below. I have following doubts: 1. The code which I have written does it follow standard C...
5
by: JoeC | last post by:
I am a self taught programmer and I am starting to get better and create larger and more complex projects. Mostly I write games because they keep me interested. I have done some reading with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.