Late to this, but I use includes with code in two situations:

1. As standard library pieces managed through a pre-compiler, usually for
platform-dependent sections. For example, I have standard includes for
getting command line arguments, reading and writing from ini files and so
forth. The precompiler builds versions of the code for each supported
platform (Universe, UniData, D3, QM etc) by pulling in the required blocks. 

I also make the same code available as subroutines (that have the same
includes), but as I have a lot of utilities it's easier for me if each of
them if relatively stand-alone and I can send them out without the need for
any supporting code.

2. For self-initializing named common blocks. I use these extensively with
web and GUI development, as it means I don't have to assume any specific
start-up routine or entry point - I can just include the declaration and
know it will be valid whatever piece of code is hit first.

These are usually of the format:

COMMON /SOMECOM/ prefix.PARAMS(SomeSize),prefix.INIT
If prefix.INIT = @False Then
  .. go and initialize it, e.g. set params to empty, open files etc.
  prefix.INIT = @True
End

(remember that named common is initialized to zero i.e. @false not to
empty).

For example, a lot of my older green screen routines have a clipboard
function and cursor handling. So I have a CLIPBOARD named common which needs
to be set to empty to begin with, and a TERM named common that defines the
terminal settings and keys, initially as a set of defaults then by reading
overrides from an INI style record. They will be initialized by whatever
routine uses either of them first, without having to call a start-up routine
on login if they aren't going to be used.

Brian



-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Baker Hughes
Sent: 07 February 2012 23:05
To: U2 Users List (u2-users@listserver.u2ug.org)
Subject: [U2] Including Code - A Best Practice?

A friendly discussion arose recently among some U2/MV Developers about
whether to include code.

If any of you have opinions about the positive aspects or negative aspects
of this practice, please respond.  Should it be adopted as a best practice,
or rejected as special situation use only?

Many shops probably include long sections of variable assignments, or
perhaps globally opened files.  This is pretty much accepted everywhere as a
good practice.

In question here is the insertion of actual code - business logic or screen
I/O programs or code snippets.

Maybe you know of methods to overcome some of the obvious downsides:
unintended reassignment of local variables, difficulty in debugging, others.

What are the positive upsides?  Performance gains?

What is the longest snippet you think should be included, if allowed?

What advantage has included code over a CALL or a Function?  Reuse.  What
else?

Can the downsides be mitigated satisfactorily to justify the gains?

Thanks so much.

-Baker




  ________________________________
This communication, its contents and any file attachments transmitted with
it are intended solely for the addressee(s) and may contain confidential
proprietary information.
Access by any other party without the express written permission of the
sender is STRICTLY PROHIBITED.
If you have received this communication in error you may not copy,
distribute or use the contents, attachments or information in any way.
Please destroy it and contact the sender.
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to