Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
How do you start a new script? Do you just open a blank editor page and start typing?

Yes, exactly that. I usually start with this:

#!/usr/bin/perl use v5.12; use warnings;

(In the old days, I used strict instead of v5.12, but now all machines that I use have at least perl 5.12 installed. Modules start with package Some::Package::Name instead of the shebang line.)

From there on, everything depends very much on what kind of script / module I write and for what purpose I write it. Automating those three lines of code is a waste of time, simply because even those three lines may vary.

I'm no big fan of generating tons of boilerplate code. If a system - especially in an OOP environment - needs hundreds lines of code just for a hello world program to work, something has gone horribly wrong in the early stages of the system.

Loading your top 1000 modules in every script just because you could need one of them during the lifetime of one of your scripts looks as insane as the boilerplate aproach to me.

Furthermore, every coder (except for the snake lovers) has his/her own preferences of how code should be structured, ordered and indented. The same is true for projects and companies, and of course, all preferences are different. So any code generator you could write either generates code using "the wrong style" or has a phantastillion of options allowing to configure any option, including the most insane ones. Naturally, you need to support at least a hundred different configuration mechanisms to fit all needs.

During my professional carreer, I saw and used very different methods for creating new source code. "Do as I say (don't do as I do)", "Do what ever you want to solve the problem", "Use the only style that works", "Copy the templates and fill in your code, following the coding guidelines written on those two pages", "Copy some old code and modify it until it works", and of course "Follow this simple 350 page instruction manual to create a skeleton for a hello world program".

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: Starting a New Script by afoken
in thread Starting a New Script by LloydRice

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-19 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found