Foo Ji-Haw wrote:


OK, looking at 'perlnewmod', it has a section called 'What should I make into a module?', which states:

"You should make a module out of any code that you think is going to be useful to others."

That settles my question. The classes I have written for this project are specific to this project, thus not useful to others. Thus, I will keep them in .pl files, not try to make modules out of them.


If this is not your first and last time you're using Perl, then it is a good practice to create modules to group similar functionalities together. Creating a huge .pl file, or lots of .pl files (and require() them later) only makes future debugging and expansion difficult.

Well, the two files in question are not huge. They each have one class. What's the difference between require-ing them later, and use-ing them later? Why is it more difficult to require them?

Creating a module is painless, yet it sets you on the right path for any complexities that may arise.

I will say that this is not a Perl-thing, but rather a good general software development mindset.

Thanks, but this does seem like a Perl-thing. No other language distinguishes between 'package-in-a-file' and 'module'.

In Java, classes are required to be in their own file, and every file is '.java'. Or '.jar', which contains a bunch of related classes.

The .NET equivalent of a perl package is a namespace. They also have source files, classes, 'modules' and 'assemblies'. A source file can contain multiple namespaces. A class can be spread across source files. A module can contain multiple namespaces, and I think a namespace can be spread across modules. But a class must be contained in a single module. An assembly can contain multiple modules (but most have only one). A module is sort of like a Java '.jar' file. I'm not saying it's better or worse, just different. Every language/framework is different.

--
Lyle Kopnicky
Software Project Engineer
Veicon Technology, Inc.


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to