Does using modules have any advantages?

General discussion for topics related to the FreeBASIC project or its community.
Richard
Posts: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Post by Richard »

I wanted to know what was meant by “modules” when applied to FB, so I kept watching this topic. Now it is confirmed that this is a philosophical discussion and that it all comes down to the many individual interpretations of the vague term “module”.

It seems that without any definition, “modules” must be good, just like motherhood and apple pie.

Maybe it is time to define what in the FB a module is, and why and how to implement an FB module.
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Post by stylin »

Richard, at the moment, FB only has the notion of QB/C/C++-like modules (C/C++ call them translation units). Typically, a module comprises of a source file (.bas), which may import the text of include files (.bi). The entire text is then compiled into an object file (.o), which is linked to other object files to produce an executable (or library). So, externally, the smallest "self-contained" grouping of code is the eventual object file. In the past, some QB people have called the source file a module, and the QuickBASIC [the language FB was originally designed to succeed] manual seems to agree:
BASIC programs consist of one or more modules. A module is a source file
that can be separately compiled.

A module may contain SUB and FUNCTION procedures, as well as code not
directly part of a SUB or FUNCTION. Statements that are not part of a SUB
or FUNCTION are called module-level code. Module-level code includes
declarative statements like DIM and TYPE as well as error-handling and
event-handling code.

A program has one special module, the main module. The main module contains
the entry point of the program (the place where the program starts
running). Each program contains only one main module. In the main module,
module-level code corresponds to what is often called the main program.
Any discussion of different types of module schemes doesn't apply to FB as it is now, though it seems that there is some interest in moving away from/deprecating the QB/C/C++/FB scheme. However, any form of encapsulation is generally more beneficial than not. If you have a 50KLOC program, splitting those lines into separate files is useful for the obvious reasons, even if they are ultimately compiled as a single module. When you create multiple modules out of those lines, the benefits increase.
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Post by relsoft »

Galeon wrote:In time, it is still useful in slow computers. According to relsoft, it took 2 minutes to compile fjrx in his own computer. It is divided in modules, but he compiles it all at once, the default in FbEdit.
Remember that I compiled it on a 233mhz cyrix at that time. :*)

BTW, may "globe tatoo" na ako. hahahahahahaha

Internet anytime in 53 kbps since the signal here is only 2g. But 2g is better than "no g". hehehehehe

Anyways, making FJRX into a multi module program made things easier for me. I could use a debugger to debug each module independently. Less headaches.
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

I use modules because I can easily find a function by reading the file names.
relsoft, alam mo libre ngayon internet ko, nakakatuwa 500mb+ na nga ng Ubuntu programs ang nadownload ko eh, libre pag gabi basta pipilitin mo. Yung SmartBro ko pinakamabilis na ang 150kbps tuwing 1am+, kalimitan >35kbps ung bilis niya, 'di malayo yung sa 'yo.
Yung 233mhz, may iba ding programmers na may ganyang computer kaya nabanggit ko na din.
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Post by relsoft »

Galeon wrote:I use modules because I can easily find a function by reading the file names.
relsoft, alam mo libre ngayon internet ko, nakakatuwa 500mb+ na nga ng Ubuntu programs ang nadownload ko eh, libre pag gabi basta pipilitin mo. Yung SmartBro ko pinakamabilis na ang 150kbps tuwing 1am+, kalimitan >35kbps ung bilis niya, 'di malayo yung sa 'yo.
Yung 233mhz, may iba ding programmers na may ganyang computer kaya nabanggit ko na din.
hahahahaha. My download speeds would range fronm 0.5 to 2.00 kbps so napakalayo.
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

Wala na yung SmartBro, kinuha ng tito ko...
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

I think the reason no one could answer my question is that you have different types of modules you're talking about...
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Post by marcov »

which question?
mathwizard44
Posts: 72
Joined: Oct 13, 2006 6:11
Location: Latte Plantation, Guam
Contact:

Post by mathwizard44 »

Wow, I didn't know there are Tagalog-speaking members on the FreeBASIC forum! Somehow this makes me glad. ^_^
From what I remember in reading the QuickBASIC online help, the module is where code goes when it isn't in any kind of SUB or FUNCTION.
Post Reply