Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: What training do YOU need?

by BrowserUk (Pope)
on Oct 21, 2002 at 05:00 UTC ( #206776=note: print w/ replies, xml ) Need Help??


in reply to What training do YOU need?

It difficult to make an informed judgement on the basis of the description you provide, but from what you've said, I would warn you to be careful. As an 'external' who has been charged with 'bringing the internal guys up to scratch on X', I have met with some fairly hostile reactions to training that was perceived as being 'trivial', 'academic', 'theoretical' or as one guy put it, 'teaching your grandmother to suck eggs!.

I had more success with a technique passed on by one of my mentors. Get them involved in the process from the start and make sure that they can see the relevance and benefit of the training.

In this case, I would ask them individually or collectively depending on your judgement of which would be viewed in the best light, to nominate the "worst" piece of code in their daily/weekly routine.

Ask them to provide you with a copy (minus any authorship info to save faces), along with sets of input and output data where applicable. Take this away, spend a weekend or week or whatever it takes to re-work it utilising the skills you wish to demonstrate. If you have time and the chosen piece lends itself to the task, do and retain multiple passes, concentrating on one aspect of your list at a time. Make sure that your final revision will operate as a replacement for what you started with, even if this stops short of best practice because achieving that requires modifications to stuff before and/or after in the processing chain.

Your aim should be to show them how the concepts on your list can be used to real effect to improve their daily/weekly lot, and how they can be used to effect beneficial change within their operating environment. This is much less likely to provoke the kind of reactions that I listed earlier.

If you can lay your hands on a good display projector, and make the changes to the chosen piece of code IRT, in front of them, rather than doing it as a set of slides or a PowerPoint (or unix eqiv.) presentation, so much the better. That also gives you the opportunity to impress the hell out of them with your power use of emacs/vim. Pick on a common example of code that can easily be improved using idiomatic constructs. Something like changing C-style for(;;)'s to foreach(@array) or map{..}@array. Make the first change manually explaining the reasons and benefits, then let loose a macro to convert the rest of them in the file, (even if you have to write the macro specially beforehand), and continue to discuss the benefits whilst the macro operates on screen.

If you can find a good example of where a substantial piece of code can be easily and quickly replaced with a CPAN module, do it. If possible, do the installation of the module "before their very eyes". Crop the lump of code you are replacing and implement the replacement. Demonstrate that it works.

If there is one thing I personally hate on training courses, and especially mandatory ones, is contrived examples that I cannot see how to apply to my real-life problems. I remember an OO course that was based around Yet Another Cutesy Animal Evolution Problem as a demonstration of Inheritance. Don't do it! If your audience cannot see the benefit of your examples to their real lives, it likely that your instruction will fall on deaf ears. Be really careful not to patronise or talk down to them, and I would avoid 'homework' tasks.

On the other hand, if they see you reduce a large monolithic piece of their own code that they have already identified as a problem, to a set of nicely decoupled, potentially re-usable, easily maintainable and modifiable functions and/or modules, they are much more likely to accept their need for the instruction in the first place.

Good luck. I do not envy you your task.


Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!


Comment on Re: What training do YOU need?
Re: Re: What training do YOU need?
by rir (Vicar) on Oct 21, 2002 at 14:35 UTC
    Good post!

    Pick on a common example of code that can easily be improved using idiomatic constructs. Something like changing C-style for(;;)'s to foreach(@array) or map{..}@array. Make the first change manually explaining the reasons and benefits,

    I realize you probably just quickly chose a this construct as an example. But your choice is unfortunate.

    Changing C-style loops to foreach loops is not as trivial as you would have it appear. The presentation would be impressive, but misleading.

    I might point out the advantages of foreach loops. And how the C-style loop is more cumbersome but more adaptable. These folk are probably very comfortable with this C phrasing. Saying this is how to improve the code is unnecessary optimization and quibbling over style at the risk of breakage.

    I like presentations that include workload and mental state, to wit:

    "It took me two hours to decipher this code."
    "Thirty minutes to get this rewrite, that has these problems. Notice how I used ..."
    "A hour of exploratory testing and minor tweaks. At this point I felt like I had a good understanding of ..."

    To the original post:

    If these are not fairly simple scripts and requirements are vague I'd first want my crew to instrument the old stuff to tee off both I and O on demand. Assuming this is reasonable.

    I cannot imagine the function-free java code these people are writing.

      But your choice is unfortunate.

      Interesting comment. Id be interested in hearing more about why you think this was an unfortunate choice.

      And how the C-style loop is more cumbersome but more adaptable.

      A C-Style for loop is always functionally and internally equivelent to a suitably constructed while loop. The primary differences being that many programmers from a C tradition find the for(;;) syntax more readable, while the rest of us find the while syntax more readble and maintainable. I am in the latter group. :-) Nine time out of ten (more really) when I see someone use a C-Style for loop they are not exploiting the equivelence to a while , but rather using a slightly less readble, more error prone and less efficient form of a for (LIST) loop. I avoid the term foreach because foreach is a synonym to for in perl, they are identical.

      E:\Smoke\source>perl -e "foreach (my $i=0;$i<10;$i++) { print $i,$/}" E:\Smoke\source>perl -e "for (my $i=0;$i<10;$i++) { print $i,$/}"
      Insofar that the majority of its use is to simulate for ($m..$n) where $m<$n I think advising people to convert to the more legible and less error prone form is probably a good idea. And I also think that its a good idea to use while () {} continue {} instead of for(;;) if only because it tends to be easier to read. Having said that in the time ive been using perl I think ive needed the construct a mere handful of times.

      Ultimately id argue that for(;;) is a construct mostly provided to reduce the pain for C junkies, and that in the long term better constructs that are more intuitive and less error prone are available and so should be encouraged.

      --- demerphq
      my friends call me, usually because I'm late....

        Having said that in the time ive been using perl I think ive needed the construct a mere handful of times.

        To reinforce the point.. I've literally never used it. There was not a single instance I wasn't equally or better served with the other constructs.

        And to be honest, considering the number of cases I advised people not to use for(;;) for whatever they were using it for, and the number of times I restructured loops in others' code to not use it, if it was to disappear from the language I wouldn't shed a tear. Actually, scratch that, I'd be cheering.

        Makeshifts last the longest.

        There is not much more. The context was about changing  for(;;) to  for(@array) or to  map {} @array and doing it with an editor macro to the worst work of a weak group of perlers. In a training presentation to that group.

        My points were:

        • This, in its presentation, would trivialize the issues.
        • The  for(;;) and  for(LIST) constructs are very different.
        • This a rather small issue, surely there are more important problems in the above situation.

        Your comparison of the  for(;;) and  while loops is a different issue. For the simple cases I prefer a  for( $i=1; $i < 10_000_000; $i++) as all the loop's controls are there upfront. This assumes good practice, i.e. you don't fiddle with  $i while looping. If you mess with  $i then you should use a  while loop.

        You say:

        Usually when someone uses a C-Style for loop they are not exploiting the equivalence to a while , but rather using a slightly less readable, more error prone and less efficient form of a for (LIST) loop.

        Which is exactly the difference I was refering to with: more cumbersome but more adaptable.

        If brevity caused my unclarity, please let me know.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://206776]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-09-30 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (372 votes), past polls