Link to home
Start Free TrialLog in
Avatar of corelio
corelio

asked on

Coding Standards

Where can I obtain a document containing a good coding standard for VB 4.0 ??
Avatar of JoeyH
JoeyH

Throughout the 'Language Reference' and 'Professional Features' manuals for VB 4.x you will find various examples of code naming standards. Also, the TechNet provides a document with coding standards, regarding naming conventions. If you do not have access to this, let me know and I will e-mail you a copy of it.

Regarding coding 'standards' insofar as style, etc., this is still a bit grey. Visual Basic provides the foundation tools for developing in the event-driven paradigm. What comes into play here the most is how to write code that can handle more than just a specific item, if/when applicable. For example, in a data entry form, you may want the application to behave such that each time the user cursors, or clicks within a text box, if there is already data in that box, automatically select those data. This follows Windows programming conventions. To do this, you would write code for the gotfocus event that selected the text automatically, like the following:

Sub obj_GotFocus()
   ' if text exist, select it...
   if len(txtObject) <> 0 then
      txtObject.SelStart = 0
      txtOBject.SelLength = len(txtObject)
   end if
End Sub

Doing this for each applicable text object would be tedious and a lot of code. Another approach would be:

within a public module (this is not a class approach)

Sub SelectField(lobjText as Control)
   ' If the control passed is Text, then if it contains data, select
   ' those data...
   If TypeOf Control Is Text Then
      If Len(lobjText) <> 0 Then
         lobjText.SelStart = 0
         lobjText.SelLength = Len(lobjText)
      End If
   End If
End Sub

Now, for the gotfocus event

Sub obj_GotFocus()
   ' Pass to our select field so any text will be selected...
   SelectField Screen.ActiveControl
End Sub


This is just a small example of coding with an approach that reduces 1) maintenance issues, 2) overall coding effort involved.

Try to design the application, using object/control names (possibly control arrays) with this mind-set.

I hope this has been helpful.

Have a nice day...
Avatar of corelio

ASKER

No ofenses, JoeyH´s , but I´m  very worried about maintanance of the code that our team writes in VB. So, I would like a FORMAL
document that specify a coding standard to be followed for
a large group of people programming in VB.

I´ve read the technical references and other Microsoft´s materials, but they are a pretty vague. And the other material
you quoted regards just naming conventions, right ??? I was
looking a document that describes many other details of coding
standard, like headers, syntax of VB comands, comments, and so
on, as described in the Personal Software Process book, of
Humphrey Watts. -> (Enginner Software Guru)

As I found a document very close to the format I want, I would like to share it with you and the other experts. It can be found at http:/www.apexsc.com/vb/ and has the name codstds.zip. It has
27 pages of description regarding these and other features.


Well, thanks a lot for you help, anyway.
See you
As you have likely found by now, Microsoft does not publish much regarding a standard of design and coding. Though they do teach a fundamental layout, as you indicated, it is, as you say, vague. Actually, it's rather elementary.

You will find a number of articles on Carl and Gary's site that may suite what you are looking for. I am gathering that you are looking for something that will suite a corporate standard, based on your reply.

Microsoft publishes two training objects pertaining to programming prose, one more focused on VB 3 and the event driven paradigm, and one of OOP. Both are available through the Microsoft Press and can be queried on 'Programming Standards' through their ISBN library.

I sincerely apologize for not being of more help and wish you luck with the MS Press queries.

Have a nice day...
ASKER CERTIFIED SOLUTION
Avatar of mheacock
mheacock

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial