Programming Style

fml 8 tutorial
Prev |  | Next

# Chapter 27. Programming Style

This chapter describes a few topics on programming technique.

See FNF on FML.ORG programming style.

# Variable Naming Convension

It is ambiguous where "default" word in the variable name is proper. The left side of the naming string is expected to show large scale such as CLASS.

Let us consider article related variables. We expect $article_* variables for them.

It seems better to use CLASS_default_XXX syntax not default_XXX.

## Structure Of Variable Naming

It seems proper to use systematic naming convension. For it, we define base class or inheritence of naming syntax.

Consider class names. For example, "mail" implies messsage/rfc822 format text. The input into fml system is a mail, outgoing one is a mail. The variable are sub class of "mail" object, so the name is unified as PREFIX_mail_ATTRIBUTE style.

    mail_XXX
    mail_default_XXX

    use_incoming_mail_XXX
    incoming_mail_XXX

    use_outgoing_mail_XXX
    outgoing_mail_XXX

    use_report_mail_XXX
    report_mail_XXX

Other example (header):

    header_XXX
    header_default_XXX

    article_header_XXX
    use_article_header_XXX

    command_mail_header_XXX
    use_command_mail_header_XXX

We can describe structure of class as follows:

    command {
    	SOMETHING_command
    	admin_command
    }

    directory {
    	XXX_directory
    }

    file {
    	template_file
    }

    mail {
    	incoming_mail
    	outgoing_mail
    	report_mail
    }

    message {
    	reply_message
    }

    article {
    	article_digest (not use digest to show digest of article)
    	article_spool  (not use spool to show  spool of article)
    }

## Example: Standard Pattern (e.g. log.cf lock.cf)

    use_VARIABLE		=	yes or no

    # append _dir for directory.
    VARIABLE_dir		=	STRING

    # append _file for file.
    VARIABLE_file		=	STRING

    VARIABLE_type		=	STRING

    VARIABLE_format		=	STRING

    VARIABLE_format_type	=	STRING

    VARIABLE_limit		=	STRING (NUMBER but STRING)

    VARIABLE_upper_limit	=	STRING (NUMBER but STRING)

    VARIABLE_lower_limit	=	STRING (NUMBER but STRING)

## Example 2: (e.g. acl.cf)

    VARIABLE_restrictions	=	reject_ATTRIBUTE1
    				check_ATTRIBUTE2
    				permit_XXX

    ATTRIBUTE1 			=	PATTERN1
    					PATTERN2
    					...

    ATTRIBUTE2			=	var1
    					var2

## Example 3: (program name prefix)

    PROGRAM_VARIABLE_ATTRIBUTE

Prev | Home | Next
release engineering | Up | A Few Topics On Design And Coding Style

fml 8.0 (fml-devel) project homepage is www.fml.org/software/fml8/.
fml 4.0 project homepage is www.fml.org/software/fml4/.
about one floppy bsd routers, see www.bsdrouter.org/.
other free softwares are found at www.fml.org/software/.

author's homepage is www.fml.org/home/fukachan/.
Also, visit nuinui's world :) at www.nuinui.net.

For questions about FML, e-mail <fml-bugs@fml.org>.