Classes\Modules, Functions\Subroutines and general programming best practice

ssjaronx4ssjaronx4 Member Posts: 37 ■■□□□□□□□□
Hi Guys,

I'm trying to write an application and had a few questions regarding programming syntax and best practice.

Programming syntax

Does anyone have a site \ list of prefixes for different types of object e.g. you put frm before a form, int befor an integer variable etc.

Funtions \ Subroutines

Do functions have to have a specific value output for example would the following work as a function and if not why?

If intEnteredHours > 8 Then
intStandardHours = 8
intOverTimeHours = (intHours - intStandardHours)

Else
intStandardHours = intEnteredHours
intOverTimeHours = 0
End If


Classes\Modules

Both of these can be used to store functions and subroutines which can be called later but when would you use each one? Should you spit out all calculation subroutines into classes \ modules for each form and then call them or just leave anything that is form specific as a subroutine \ function of that form?

Thanks,

Aron

Comments

  • ssjaronx4ssjaronx4 Member Posts: 37 ■■□□□□□□□□
    OK did a bit of reading. So, the code I put up could only be a subroutine as it only defines values and doesn't return them. So a function would go something like:

    public function Example

    Dim result as string
    dim a as integer

    a = 10

    result = 1 * a

    Return result

    I could then use that function later on in the code by doing something like

    Word = 23 * (call Example)

    Right?

    Also, each form is created with an associated module by default so I would just store all form specific code and procedures in that form and then any non form specific code in a module \ class right? How about global variables, is it best to define them in the form in which they are first called or in a separate module?
  • JDMurrayJDMurray Admin Posts: 13,101 Admin
    What language are you using?

    And Microsoft stopped using Hungarian notation many years ago in favor of coding standards commonly used in Java.
Sign In or Register to comment.