Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Program design in perl?

Reply
Thread Tools

Program design in perl?

 
 
Mohammd M. Hussain
Guest
Posts: n/a
 
      07-14-2004
Hi,

I have a good knowledge of Perl ( 2 and half years ) and despite
working with the language that long, I have yet to build a substantial
program ( during this time I was merely testing out various aspects of
the language ). I have tried many times to build a program like a web
blog or a bulletin board but it seems that my attempts fail as soon as
I fire up the text editor! I just cannot determine what is the optimal
design to use when coding a web application.

So, I would love to read about how you guys organise your Perl code.

Thanks,
 
Reply With Quote
 
 
 
 
penguinista
Guest
Posts: n/a
 
      07-15-2004
Mohammd M. Hussain wrote:

> Hi,
>
> I have a good knowledge of Perl ( 2 and half years ) and despite
> working with the language that long, I have yet to build a substantial
> program ( during this time I was merely testing out various aspects of
> the language ). I have tried many times to build a program like a web
> blog or a bulletin board but it seems that my attempts fail as soon as
> I fire up the text editor! I just cannot determine what is the optimal
> design to use when coding a web application.
>
> So, I would love to read about how you guys organise your Perl code.
>
> Thanks,


One good approach, not just for perl, is to start by laying out the data
your project will need to deal with. A project can live or die on good
or bad data organization. List the operations needed on that data, as
these will influence the prefered representation of the data, and may
indicate additional data fields needed. For persistant data (blog,
bulitin board), consider interfacing a database (module DBI). Or if you
prefer a flat file, start coding with routines to read/write records.

 
Reply With Quote
 
 
 
 
Mohammad Mahmoud Khajah
Guest
Posts: n/a
 
      07-16-2004
On Wed, 14 Jul 2004 19:00:38 -0700, penguinista wrote:

> Mohammd M. Hussain wrote:
>
>> Hi,
>>
>> I have a good knowledge of Perl ( 2 and half years ) and despite
>> working with the language that long, I have yet to build a substantial
>> program ( during this time I was merely testing out various aspects of
>> the language ). I have tried many times to build a program like a web
>> blog or a bulletin board but it seems that my attempts fail as soon as
>> I fire up the text editor! I just cannot determine what is the optimal
>> design to use when coding a web application.
>>
>> So, I would love to read about how you guys organise your Perl code.
>>
>> Thanks,

>
> One good approach, not just for perl, is to start by laying out the data
> your project will need to deal with. A project can live or die on good
> or bad data organization. List the operations needed on that data, as
> these will influence the prefered representation of the data, and may
> indicate additional data fields needed. For persistant data (blog,
> bulitin board), consider interfacing a database (module DBI). Or if you
> prefer a flat file, start coding with routines to read/write records.


Thanks for your reply,

I would like to know more details: How to handle errors ( I mean is it by
using exceptions or regular return codes ) and How the overall structure
of good modular web application should look like.

I coded an OO database interface for a blog program and
I have made it loosely-coupled so I can test it quickly and it turned out
to be fine. I would love to read suggestions about the next step(s) after
creating an abstraction layer for the DB.
 
Reply With Quote
 
Skeleton Man
Guest
Posts: n/a
 
      07-17-2004
>I would like to know more details: How to handle errors ( I mean is it by
>using exceptions or regular return codes ) and How the overall structure
>of good modular web application should look like.


Error handling during the development stage would be something like this:
(using a file read as an example)

$fname = "/path/to/file";
open (FILE, "<$fname") || die ("Unable to open $fname: $!");

If the program is gonna be released to the masses, it may be better to have
error codes and an FAQ:

$fname = "/path/to/file";
open (FILE, "<$fname") || die ("Errror 123: Consult FAQ for details !");

As for structure, personally I prefer to split a program into a series of
libraries and actions:

Example:

myscript.cgi?action=someaction
File structure:

/cgi-bin/myscript.cgi
-- Script itself
/cgi-bin/myscript_actions/
-- Directory of files with code related to specific tasks
/cgi-bin/myscript_actions/someaction/
-- Subdirectory for the specific action "someaction"
/cgi-bin/myscript_actions/someaction/code_for_this_function.pl -- Code
related to the specific action.


If you go to http://www.guestwho.com and download "GuestWho" (perl
guestbook, flatfile), you can get an idea of how I choose to structure to my
programs. This is just personal preference, there's not really a right or
wrong way to approach it.


>I coded an OO database interface for a blog program and
>I have made it loosely-coupled so I can test it quickly and it turned out
>to be fine. I would love to read suggestions about the next step(s) after
>creating an abstraction layer for the DB.


Start by thinking of one the major tasks (viewing, posting, etc) and what's
involved (such as user input, verification, etc).
Once you know what that task needs to do and what's involved with it, start
thinking about how you're going to tackle it.

After you have one task done, repeat the above with another task..


DISCLAIMER: The above is my prefered methods of operation, but I make no
claim that it is the best or only way to do it.

Regards,
Chris


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
program design - template design pattern Adam Akhtar Ruby 5 03-27-2009 07:54 AM
Class design/design pattern resources TomTom MCSD 2 10-09-2004 07:38 AM
OO design in servlet design question dave Java 5 07-17-2004 12:58 PM
Xilinx Schematic design vs VHDL code design ZackS VHDL 5 07-09-2004 07:51 AM
Looking for help/resources on Writing a nice detailed design / tech design for vb.net code SpamProof Java 3 12-01-2003 06:06 AM



Advertisments