Re: Perl Safety
by merlyn (Sage) on Aug 25, 2000 at 19:17 UTC
|
If the code-review rule is adopted that nobody touches anyone else's package data, then you have nothing to worry about unless you have people that don't go through code review.
You don't need safety from the compiler. You can get safety implemented as
humanware. And if that's not enough, yes, you can do some difficult things
with Perl to make it also compiler-enforced, at the expense of clarity and
maintainability.
If you're working in a place where you can't trust your fellow hacker,
quit.
-- Randal L. Schwartz, Perl hacker | [reply] |
|
|
Well I am having fun... so no need to quit. Anyway, the situation is basically this:
several functions that I call return nothing, instead the implicitly set variables $x,$y,$z.
I am just worried that at some point $x,$y,$z may also at some point include $a which may be something I'm using and need to keep clean myself.
Does Perl provide any clean way to partition myself from other parts of the program?
| [reply] |
|
|
Don't call them. Raise a stink. Really.
In the meantime write wrappers for these functions, in
the wrappers call, check the implicit variables, and
return them. Then when the code can be fixed, less has
to be changed. If you can, localize the variables in
your wrapper.
And "use strict" to be sure you have everything lexically
scoped.
But people like that are a hazard to your code base,
nothing more and nothing less.
| [reply] |
|
|
|
|
Ugh. So you're telling me you've got bad code? No amount of Perl Safety will
help you.
If $x and $y and $z are in their package, you're safe. If you're telling me
you're not using packages, quit, no matter how much fun it is. {grin}
-- Randal L. Schwartz, Perl hacker
| [reply] |
|
|
Re: Perl Safety
by xdb19 (Sexton) on Aug 25, 2000 at 23:14 UTC
|
Most people cannot up and quit their jobs just like that. No offense Randal, but that is some horrible advice you gave the man. Quitting is not an option.
By Nature, I do not quit at anything, and that has proven very helpful throughout my short life. Now given that you are older, and most probably wiser than I, I still must express what I believe in.
My suggestion would be to look for another job. Try to find a nother job, go to interviews. Do something to find a place you like. Now, If by chance you want to stay where you are, or are unable to find another suitable job, TAlk to your coworkers, and tell them what you think.
I am sure noone likes to be criticised, but sometimes it is necessary (once again, i appologize to Randal for Criticizing him).
The most important thing is to be happy where you work. Most people dont like their jobs. I am one of the few that does (like his job that is I am just an intern) . And I wish this for everyone.
So gaspodethewonderdog, my advice is simple. Be Happy, and if you're not.. do anything in your power to become happy. Spend the few days that you have in life, enjoying it. Work is something we have to do. Might as well make it enjoyable.
- Have Fun, XDB19 | [reply] |
|
|
I do have to say, I have had to laugh at this thread a little... I've been working with perl off and on the last seven (gosh maybe more...) years and have always enjoyed it... my current employer wanted me to implement some code in perl (I argued for java or c pretty hard... but hey sometimes money talks ;)... anyway I was hoping more somebody would come in with a nice solution and say "here is some neat trick... try this :)"
Instead I've gotten professional help ;)... which is cool, but I'm a *lowly* contractor here *and* too young... hrmmm... so I can't really get in and play the political games to actually fix the problem correctly... I've bugged the guy a few times to help him fix some things, but he's a little put off by having some 'green' punk kid teach him anything. If anything I think it bothers him more that I've been programming longer than him... and more than likely getting paid more. :(
Be that as it may, are there *any* tricks I can pull off to protect myself. I know I could localize variables and all that fun stuff, but I'm more afraid he'll go off and create new variables and such and walk all over my code. It has happened a few times to me and unfortunately talking to his manager hasn't helped any because he is basically given free reign to do whatever he wants.
So can I do something weird like localize main:: or somehow seperate his memory space from mine without his code knowing about it? I really don't care to spend the time to re-write any of his code, especially since I don't want to be walking on any toes.
I've already ran into enough problems now that I am trying to get him to fix anyway... so this isn't highest on my priority list to get him to fix... I'd rather get him focusing any time he can give me to *not* crashing out on me and killing my programs that use his code.
Oh well... I guess this thread has become more 'off topic' than what *I* expected at least :)... guess I'll have to see what I can do on my end to get this engineer to help me out :).
| [reply] |
|
|
| [reply] |
|
|
|
|
|
|
|
Instead I've gotten professional help ;)... which is cool,
but I'm a *lowly* contractor here *and* too
young... hrmmm... so I can't really get in and play the
political games to actually fix the problem correctly...
I've bugged the guy a few times to help him fix some
things, but he's a little put off by having some 'green'
punk kid teach him anything. If anything I think it
bothers him more that I've been programming longer than
him... and more than likely getting paid more. :(
###########
This is precisely the culture that I work so hard to avoid,
yet landing there seems to be unavoidable.
If you have a valid point ( and it looks like you do based
on your description of the problem ), then I suggest you
become an evil, manipulative bastard by asking the following
question:
"What am I missing?"
This insidious little question is extremely confrontational
because it forces them to explain to YOU exactly how their
way will work. Their explanation will not make sense, so
be sure to ask it in the presence of at least 1 ally. If
they dodge, repeat the question.
If they dodge, repeat the question.
If they dodge, repeat the question.
If they dodge, repeat the question.
If they dodge again, say "Excuse me, but I really do not
understand what you are doing here. Can you please help
me understand what you are trying to do and how I can
succeed with your code?"
If they don't help you, then that is a refusal to help
a coworker whose work depends upon their success. At that
point, maybe some sort of third party intervention shall
be required. Be sure to present it as in the context of
how you do not understand what the other person is doing and
they are refusing to work with you to solve the problem.
Also, be prepared to leave if your company is extremely sick
culturally. They will not like this. Having allies
present is extremely important. This is a CYA for your
presentation to HR...if 3 people complain to HR, it will
probably be believed. If 4 people complain to HR, it shall
be believed and action will be taken.
##########
On a lighter note:
while ( $dodge ) {
print "What am I missing?\n";
} # while
--moo
| [reply] |
|
|
Instead I've gotten professional help ;)... which is cool,
but I'm a *lowly* contractor here *and* too
young... hrmmm... so I can't really get in and play the
political games to actually fix the problem correctly...
I've bugged the guy a few times to help him fix some
things, but he's a little put off by having some 'green'
punk kid teach him anything. If anything I think it
bothers him more that I've been programming longer than
him... and more than likely getting paid more. :(
###########
This is precisely the culture that I work so hard to avoid,
yet landing there seems to be unavoidable.
If you have a valid point ( and it looks like you do based
on your description of the problem ), then I suggest you
become an evil, manipulative bastard by asking the following
question:
"What am I missing?"
This insidious little question is extremely confrontational
because it forces them to explain to YOU exactly how their
way will work. Their explanation will not make sense, so
be sure to ask it in the presence of at least 1 ally. If
they dodge, repeat the question.
If they dodge, repeat the question.
If they dodge, repeat the question.
If they dodge, repeat the question.
If they dodge again, say "Excuse me, but I really do not
understand what you are doing here. Can you please help
me understand what you are trying to do and how I can
succeed with your code?"
If they don't help you, then that is a refusal to help
a coworker whose work depends upon their success. At that
point, maybe some sort of third party intervention shall
be required. Be sure to present it as in the context of
how you do not understand what the other person is doing and
they are refusing to work with you to solve the problem.
Also, be prepared to leave if your company is extremely sick
culturally. They will not like this. Having allies
present is extremely important. This is a CYA for your
presentation to HR...if 3 people complain to HR, it will
probably be believed. If 4 people complain to HR, it shall
be believed and action will be taken.
##########
On a lighter note:
while ( $dodge ) {
print "What am I missing?\n";
} # while
--moo
| [reply] |
|
|
Please don't misread my "quit" as literally "don't check in for work tomorrow".
What I mean is change the situation. Work whatever way you can
to make it different, because it's dangerous the way it is. "quit" doing business
as you've been doing it.
If you can't find a common purpose, and you've tried to find alignment,
then you literally do need to find a different job, or be miserable.
There's no third option.
-- Randal L. Schwartz, Perl hacker
| [reply] |
Re: Perl Safety
by LunaticLeo (Scribe) on Aug 26, 2000 at 00:21 UTC
|
--- Global.pm ---
$GLOBAL = 'Bad bad global';
sub dumbproc {
$GLOBAL = 'Still sucks';
}
Then you can hide the globals like this...
--- HideGlobals.pm ---
package HideGlobals;
use vars qw( @ISA @EXPORT_OK );
require Exporter;
@ISA = qw( Exporter );
use Globals;
@EXPORT_OK = qw( &hidden_dumbproc );
sub hidden_dumbproc {
dumbproc(@_);
return $GLOBAL;
}
1;
Here is my test code...
use HideGlobals qw( &hidden_dumbproc );
print $HideGlobals::GLOBAL, "\n";
print &hidden_dumbproc, "\n";
| [reply] [d/l] [select] |
Re: Perl Safety
by ferrency (Deacon) on Aug 26, 2000 at 00:55 UTC
|
If you want a Really Quick Hack that will Probably protect you from what the other kids are doing...
Write your own code inside a package, use strict in your
code, and explicitly reference the globals in package
"main" which they seem to have claimed for themselves.
As long as you're in a different package, and don't create
any globals in main::, you should be Okay, no? (until they step
on each others toes instead of yours... but to a certain extent you're
never going to be able to fully insulate yourself form stupid programs
or programmers)
Alan
| [reply] |