473,508 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best Coding Practice

First, let me say that this question is a rather general programming
question, but the context is PHP, so I figured this group would have
the most relevant insight.

Anyways, this is also more of an opinion based question than one
seeking a definite answer. Recently, while maintaining a rather large
system. I needed to add an array class member to an object. It was
exactly the same as another class member, except that one array stored
regular products, and the other stored free promotional products. As
such, I needed a way to add products to the new, free array. Since all
the logic was the same between the two arrays aside from the price, I
had a few different options to do this. I'm interested in polling
which way some of the group members feel would have been the best.
Naturally these are abbreviated versions of what I envisioned as
possible solutions.
#1.
public function addArrayA($object){
//logic
$a[] = $object;
}

public function addArrayB($object){
//same logic
$b[] = $object;
}
#2. (These next two are arranged as such, because the class using
these functions is included in many script files,
all of which I may not be aware of, so there would have to be some
default value for the array that was always used
before this new array was needed)
public function addArray($object, $free = NULL){
//logic
if(!$free){
$a[] = $object;
}else{
$b[] = $object;
}
}

or

#3
public function addArray($object, $arr = "a"){
//logic
$$arr[] = $object;
}

I ended up going with option number 1, because I felt that despite the
inefficient, redundant code it would later be more readable to other
programmers that might work on the project. Additionally, I didn't
feel wholly comfortable with default variables being the only
difference between a full price product and a free product. Thoughts?

Aug 24 '07 #1
52 3324
bu*************@gmail.com wrote:
First, let me say that this question is a rather general programming
question, but the context is PHP, so I figured this group would have
the most relevant insight.

Anyways, this is also more of an opinion based question than one
seeking a definite answer. Recently, while maintaining a rather large
system. I needed to add an array class member to an object. It was
exactly the same as another class member, except that one array stored
regular products, and the other stored free promotional products. As
such, I needed a way to add products to the new, free array. Since all
the logic was the same between the two arrays aside from the price, I
had a few different options to do this. I'm interested in polling
which way some of the group members feel would have been the best.
Naturally these are abbreviated versions of what I envisioned as
possible solutions.
#1.
public function addArrayA($object){
//logic
$a[] = $object;
}

public function addArrayB($object){
//same logic
$b[] = $object;
}
#2. (These next two are arranged as such, because the class using
these functions is included in many script files,
all of which I may not be aware of, so there would have to be some
default value for the array that was always used
before this new array was needed)
public function addArray($object, $free = NULL){
//logic
if(!$free){
$a[] = $object;
}else{
$b[] = $object;
}
}

or

#3
public function addArray($object, $arr = "a"){
//logic
$$arr[] = $object;
}

I ended up going with option number 1, because I felt that despite the
inefficient, redundant code it would later be more readable to other
programmers that might work on the project. Additionally, I didn't
feel wholly comfortable with default variables being the only
difference between a full price product and a free product. Thoughts?
I'd pick choice 1.

Generally I try not to change an existing function's signature unless
necessary. Also, it's more clear as to what it's doing, and there is
only one line of duplicated code (if there were a lot of lines, I'd have
a common function and pass $a or $b to that function).

You could make a case could be made for choice 2, but it adds
complication (and processing time for the if statements).

No way would I ever pick choice 3. It's unnecessarily complicated and
confusing. And what would happen if someone passed 'c' to it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 24 '07 #2
On Aug 23, 8:41 pm, "burgermeiste...@gmail.com"
<burgermeiste...@gmail.comwrote:
First, let me say that this question is a rather general programming
question, but the context is PHP, so I figured this group would have
the most relevant insight.

Anyways, this is also more of an opinion based question than one
seeking a definite answer. Recently, while maintaining a rather large
system. I needed to add an array class member to an object. It was
exactly the same as another class member, except that one array stored
regular products, and the other stored free promotional products. As
such, I needed a way to add products to the new, free array. Since all
the logic was the same between the two arrays aside from the price, I
had a few different options to do this. I'm interested in polling
which way some of the group members feel would have been the best.
Naturally these are abbreviated versions of what I envisioned as
possible solutions.
#1.
public function addArrayA($object){
//logic
$a[] = $object;

}

public function addArrayB($object){
//same logic
$b[] = $object;

}
still have redundant logic, as you stated
>
#2. (These next two are arranged as such, because the class using
these functions is included in many script files,
all of which I may not be aware of, so there would have to be some
default value for the array that was always used
before this new array was needed)
public function addArray($object, $free = NULL){
//logic
if(!$free){
$a[] = $object;
}else{
$b[] = $object;
}

}
not very good practice. when you start using conditional statements
within your code, it's a good canidate for refactoring. Seeing this
as a possibility, I probably would have created a abstract base
Products class, which it's child concrete classes would act as
containers for product items. The base class would contain all the
core functionality, and the child classes the specific elements.
Then, come time to add a new sibling class, it simply inherets from
the superclass and your good to go.
>
or

#3
public function addArray($object, $arr = "a"){
//logic
$$arr[] = $object;

}
I've actually done something similar to this before. Only 2 months
later I was cursing the programmer that came up with this
chaos....damn.
I ended up going with option number 1, because I felt that despite the
inefficient, redundant code it would later be more readable to other
programmers that might work on the project. Additionally, I didn't
feel wholly comfortable with default variables being the only
difference between a full price product and a free product. Thoughts?

Aug 24 '07 #3

<bu*************@gmail.comwrote in message
news:11**********************@q3g2000prf.googlegro ups.com...
| First, let me say that this question is a rather general programming
| question, but the context is PHP, so I figured this group would have
| the most relevant insight.

since this is a general prog. q., let me answer with a formal approach...

i'd get more strict with the array. i'd make them into an object - a class.
i'd either have b extend a, or a and b extend another base/common object, or
have a and b implement a standard inter face. the array that you're holding
$object in should be strong-typed as the 1) base object or 2) the shared
interface. upon processing within your function, you'd simply get the class
type of the object and place it in its appropriate array.

but, that just may be to formal...especially since isp's seem reluctant/slow
in upgrading to more recent and oop compatible versions of php.

and, that could just be me.

cheers.
Aug 24 '07 #4
ELINTPimp wrote:
On Aug 23, 8:41 pm, "burgermeiste...@gmail.com"
>public function addArray($object, $free = NULL){
//logic
if(!$free){
$a[] = $object;
}else{
$b[] = $object;
}

}

not very good practice. when you start using conditional statements
within your code, it's a good canidate for refactoring.
Refactoring?
What's that?
Aug 24 '07 #5
rf

"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:CM*****************@newssvr25.news.prodigy.ne t...
ELINTPimp wrote:
>not very good practice. when you start using conditional statements
within your code, it's a good canidate for refactoring.

Refactoring?
What's that?
http://www.google.com.au/search?q=refactoring

Second hit.

--
Richard.
Aug 24 '07 #6
rf wrote:
"Sanders Kaufman" <bu***@kaufman.netwrote in message
>Refactoring?
What's that?

http://www.google.com.au/search?q=refactoring
http://en.wikipedia.org/wiki/Refactoring

Oh, I get it. It's a politically-correct, bidness-safe way of saying
you did something fundamentally wrong and have to re-design the whole
damned thing. Oddly, my spell-checker sees "refactor" as not-a-word.

I'll have to remember that one - I don't rewrite my code, I
refactor(sp?) it.

I notice they cite Agile and Extreme (but not Waterfall) in that
definition. That's funny. Every time I've been involved in a shop that
prayed from one of those bibles, agony and failure were the
words-of-the-day... for just that reason.

They always come up with convoluted ways of stating the simplest things,
and the most complex ways of performing the simplest functions.

On second thought... maybe I'll just forget that one.

Thx rf
Aug 24 '07 #7

"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:nH*****************@nlpi069.nbdc.sbc.com...
| rf wrote:
| "Sanders Kaufman" <bu***@kaufman.netwrote in message
|
| >Refactoring?
| >What's that?
| >
| http://www.google.com.au/search?q=refactoring
|
| http://en.wikipedia.org/wiki/Refactoring
|
| Oh, I get it. It's a politically-correct, bidness-safe way of saying
| you did something fundamentally wrong and have to re-design the whole
| damned thing. Oddly, my spell-checker sees "refactor" as not-a-word.
|
| I'll have to remember that one - I don't rewrite my code, I
| refactor(sp?) it.
|
| I notice they cite Agile and Extreme (but not Waterfall) in that
| definition. That's funny. Every time I've been involved in a shop that
| prayed from one of those bibles, agony and failure were the
| words-of-the-day... for just that reason.
|
| They always come up with convoluted ways of stating the simplest things,
| and the most complex ways of performing the simplest functions.
|
| On second thought... maybe I'll just forget that one.

but don't you just love the 'automatic unit testing blah blah blah'. i've
written tests more complex that the code it was performed on. perhaps
'automatic' should be stricken from that def.

however, the 'fundamentally wrong' is not really wrong at all. the
functionality is not broken. it could be that a new enhancement needs to be
added. refactoring old code for the addition may just mean code isolation so
that pertinent portions can be used in multiple places yet maintained in
one. it may mean you hired a consultant to produce quick results that you
were understaffed to complete. *always* go behind your consultants!!! *most*
of the shittiest working code i've ever seen comes from that source. plus
they may just innocently enough, not know your standards and practices...so
you're bringing it back in line. it could be that when reviewing a code
base, patterns emerge that could be consolidated or reduced to a more simple
statement...all of these things are reasons to refactor.

btw, i hate 'extreme programming'. it employs decades old scientific
management models and pawns them off as new and exciting, even
revolutionary...dare i say 'extreme'...methodology not seen until modern
times. but, i digress...

cheers
Aug 24 '07 #8
rf

"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:nH*****************@nlpi069.nbdc.sbc.com...
rf wrote:
>"Sanders Kaufman" <bu***@kaufman.netwrote in message
>>Refactoring?
What's that?

http://www.google.com.au/search?q=refactoring

http://en.wikipedia.org/wiki/Refactoring

Oh, I get it. It's a politically-correct, bidness-safe way of saying you
did something fundamentally wrong and have to re-design the whole damned
thing.
No it is most definately not. If you had read and understood the above
article you would know that.

While you are looking again at the article you may wish to follow the link
to Extreme Programming, of which refactoring is an integral component.

This is not, of course, programming 101. It's many levels above that.

--
Richard.
Aug 24 '07 #9
rf wrote:
"Sanders Kaufman" <bu***@kaufman.netwrote in message
>Oh, I get it. It's a politically-correct, bidness-safe way of saying you
did something fundamentally wrong and have to re-design the whole damned
thing.

No it is most definately not. If you had read and understood the above
article you would know that.

While you are looking again at the article you may wish to follow the link
to Extreme Programming, of which refactoring is an integral component.

This is not, of course, programming 101. It's many levels above that.
Yeah - so advanced that it leaves the programming world entirely, and
enters that of PC bidness-speak. Bleccchh.

I'm a code-monkey, and I like it.

Aug 24 '07 #10
bu*************@gmail.com wrote:
I needed to add an array class member to an object. It was exactly the
same as another class member, except that one array stored regular
products, and the other stored free promotional products. As such, I
needed a way to add products to the new, free array. Since all the logic
was the same between the two arrays aside from the price, I had a few
different options to do this.
Frankly I think all the options you outlined expose too much of the inner
workings of your class. What happens when you add a third category of
products (products that cost money, free products & products we have to
pay you to take away!)

A better solution would be something like this:

public function add_product (Product $p)
{
if ($p->price==0)
$this->free_products[] = $p;
else
$this->products[] = $p;
}

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 64 days, 11:44.]

TrivialEncoder/0.2
http://tobyinkster.co.uk/blog/2007/0...ivial-encoder/
Aug 24 '07 #11
On Aug 24, 12:59 am, Sanders Kaufman <bu...@kaufman.netwrote:
rf wrote:
"Sanders Kaufman" <bu...@kaufman.netwrote in message
Oh, I get it. It's a politically-correct, bidness-safe way of saying you
did something fundamentally wrong and have to re-design the whole damned
thing.
No it is most definately not. If you had read and understood the above
article you would know that.
While you are looking again at the article you may wish to follow the link
to Extreme Programming, of which refactoring is an integral component.
This is not, of course, programming 101. It's many levels above that.

Yeah - so advanced that it leaves the programming world entirely, and
enters that of PC bidness-speak. Bleccchh.

I'm a code-monkey, and I like it.
Sanders, I respect where you are coming from as wanting to be a "code-
monkey" and remove yourself from the "PC bidness-speak", as I've been
that way (and continue to be that way to some extent). There is a big
difference, however, in adopting sound best practices in software
engineering and "running with the crowd", as it were, using terms we
all love to hate like Web 2.0 and the like.

Refactoring your code doesn't always mean you screwed up in the design
or within the actual logic of the code. Most of the time, it has to
deal with improving your code to meet new business requirements. A
good (and dramatic) example is if you started with a very small
project that used OO, but not an MVC or similar framework. Later,
your customer tells you that their business has expanded and their
presence on the Internet must grow accordingly and now the customer is
needing something that is well beyond the original specifications of
the web application you created. Then starts the refactoring
process. Refactoring could also deal not just with your business
logic, but also database schema and aspects therein.

I recommend to all that hasn't already read them, to check out books
by Martin Fowler as a starter into this subject.

The term "refactoring" can be considered a label, really, similar to
giving a design pattern a name. It gives technical people a common
language so they can work together. Just because your PHB may pickup
on the term, and use it (probably incorrectly), doesn't mean it's
garbage and does not relate to a software engineer.

Extreme programming uses the term refactoring, but even though it may
be in the index of the book, doesn't mean they are strictly related.
Aug 24 '07 #12

| Agreed, please see my post above. I'll be sure to focus on the
| problem rather than the approach of the person in the future. Thanks
| for pointing this out, Jerry.

you always have to consider BOTH. that 'person in the future' is probably
going to be you. either way, it is the structure and pattern of what you
code that makes a project manageable and expandable. just looking at the
current problem is amatuer practice at best. that's called putting out fires
and is too short-sighted to do anyone much good.
Aug 24 '07 #13
ELINTPimp wrote:
>
Refactoring your code doesn't always mean you screwed up in the design
or within the actual logic of the code. Most of the time, it has to
deal with improving your code to meet new business requirements.
I understand all that... and how "refactor" doesn't necessarily mean
that everything's a mess.

In fact, I just "refactored" some code in which I was passing CSV
strings, but needed to change that to an array.

But I just told my payer that I did something fundamentally wrong, and
had to fix it before I went on. Had I said I need to "refactor" my code
, it wouldn't have been clear to her what happened. Worse, I think it
would have scared her into thinking that I was another one of many
coders she's hired before who bend over backwards to avoid admitting
that they made a mistake... while charging her for it.

I realize that in some circles, that kind of biz-speak is acceptable -
but those aren't my circles.

Aug 24 '07 #14
Sanders Kaufman wrote:
ELINTPimp wrote:
>>
Refactoring your code doesn't always mean you screwed up in the design
or within the actual logic of the code. Most of the time, it has to
deal with improving your code to meet new business requirements.

I understand all that... and how "refactor" doesn't necessarily mean
that everything's a mess.

In fact, I just "refactored" some code in which I was passing CSV
strings, but needed to change that to an array.

But I just told my payer that I did something fundamentally wrong, and
had to fix it before I went on. Had I said I need to "refactor" my code
, it wouldn't have been clear to her what happened. Worse, I think it
would have scared her into thinking that I was another one of many
coders she's hired before who bend over backwards to avoid admitting
that they made a mistake... while charging her for it.

I realize that in some circles, that kind of biz-speak is acceptable -
but those aren't my circles.
But that's not refactoring. You changed the interface. Refactoring
does not change the interface - just the internal workings.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 25 '07 #15
Jerry Stuckle wrote:
But that's not refactoring. You changed the interface. Refactoring
does not change the interface - just the internal workings.

What happened was that I had that Database->Baseclass->Implementation
structure going on, but I oopsed and put some features in the baseclass
that belonged in the database class.

Since the whole project relied on that wrong way of doing things, I had
to go to every page that extended the baseclass and modify it to reflect
the array way instead of the csv way.

That's refactoring, right?

btw - I just finished fixing up a working implementation and it's at
"http://www.kaufman.net/bvckvs/bvckvs_publication.php".

Except for a lot of cosmetology to do, I think it's what I wanted.
Aug 25 '07 #16
Sanders Kaufman wrote:
Jerry Stuckle wrote:
>But that's not refactoring. You changed the interface. Refactoring
does not change the interface - just the internal workings.


What happened was that I had that Database->Baseclass->Implementation
structure going on, but I oopsed and put some features in the baseclass
that belonged in the database class.

Since the whole project relied on that wrong way of doing things, I had
to go to every page that extended the baseclass and modify it to reflect
the array way instead of the csv way.

That's refactoring, right?

btw - I just finished fixing up a working implementation and it's at
"http://www.kaufman.net/bvckvs/bvckvs_publication.php".

Except for a lot of cosmetology to do, I think it's what I wanted.
No, refactoring is changing the implementation without changing the
interface.

IOW, you change HOW you do things, but not WHAT you do. You changed the
interface.

An example of refactoring would be to change a class so that it gets its
data from a relational database instead of a flat file. The function
calls (interface) remain the same, but the code in the functions
(implementation) changes.

Refactoring in OO would mean you would not have to change anything
outside of the class itself.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 25 '07 #17
Jerry Stuckle wrote:
No, refactoring is changing the implementation without changing the
interface.

IOW, you change HOW you do things, but not WHAT you do. You changed the
interface.

An example of refactoring would be to change a class so that it gets its
data from a relational database instead of a flat file. The function
calls (interface) remain the same, but the code in the functions
(implementation) changes.

Refactoring in OO would mean you would not have to change anything
outside of the class itself.
Ahh - so when I had to use new kinds of parameters - I was rewriting.
But if I'd made it all zero-impact on how it's used, it would have been
refactoring.

I don't get it. I can repeat it and rephrase it. But I don't get it.

Aug 25 '07 #18
No, refactoring is changing the implementation without changing the
interface.
Please read the book before you utter nonsense.

Refactoring is changing the _structure_ of the code without changing the
_behaviour_ of that code. So interface changes can be refactorings.

<snipped more incorrect stuff>
Refactoring in OO would mean you would not have to change anything
outside of the class itself.
I think you confuse with the Open Closed Principle. The Open Closed
Principle and refactoring are perpendicular ways to adapt code in a
_controlled_ fashion: The Open Closed Principle leaves the structure
intact, while refactoring makes sure the code behaviour remains the same
while you are restructuring it.
Aug 25 '07 #19
Dikkie Dik wrote:
>No, refactoring is changing the implementation without changing the
interface.

Please read the book before you utter nonsense.

Refactoring is changing the _structure_ of the code without changing the
_behaviour_ of that code. So interface changes can be refactorings.
I have read the book - many times. And I've been involved in
"refactoring" since long before the term ever came up. The interface IS
the behavior - and changing the interface changes the behavior.

Refactoring means you don't have to chance code outside that which you
are changing. For instance, you can change the body of the function
without changing the function name, parameter list and return value.
This requires no change outside of the function, and is refactoring.

But if you change the function name, parameter list and/or return value,
you have to change all of the code calling it. This is NOT refactoring.

Pull your head out of your ass and learn what you're talking about
before showing what an idiot you are.
<snipped more incorrect stuff>
>Refactoring in OO would mean you would not have to change anything
outside of the class itself.

I think you confuse with the Open Closed Principle. The Open Closed
Principle and refactoring are perpendicular ways to adapt code in a
_controlled_ fashion: The Open Closed Principle leaves the structure
intact, while refactoring makes sure the code behaviour remains the same
while you are restructuring it.
Not at all. But you have no idea what you're talking about.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 25 '07 #20
..oO(Jerry Stuckle)
>But if you change the function name, parameter list and/or return value,
you have to change all of the code calling it. This is NOT refactoring.
http://en.wikipedia.org/wiki/Rename_Method

http://www.refactoring.com/catalog/renameMethod.html

Micha
Aug 25 '07 #21
Michael Fesser wrote:
.oO(Jerry Stuckle)
>But if you change the function name, parameter list and/or return value,
you have to change all of the code calling it. This is NOT refactoring.

http://en.wikipedia.org/wiki/Rename_Method

http://www.refactoring.com/catalog/renameMethod.html

Micha
And that's where I disagree with the author of the refactoring site.
But that's one person's opinion. Other people who have written about
refactoring

Changing the name of a function which is externally available is
changing the behavior. It means changing every piece of code which
calls the function.

For instance, between Apache 1.x and 2.x, the Apache foundation changed
some of the function calls. This causes problems with any modules which
call those functions.

By your argument, ZEND should change the fopen() call to be file_open().
How much code would that affect?

Rather, they might change the code to make it more efficient and not
change the function name. This is refactoring.

But the author is correct - there is very little information available
on refactoring. In some ways the site is good. But in other ways it
contains incorrect information.

As to the Wikipedia page - I have no idea who wrote this page. Was it
the same person? Or someone else without a good idea about it? Anyone
can create a page there. I could create one which says the sun rises in
the west. Does this make it so?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 25 '07 #22
Dikkie Dik wrote:
>No, refactoring is changing the implementation without changing the
interface.

Please read the book before you utter nonsense.

Refactoring is changing the _structure_ of the code without changing the
_behaviour_ of that code. So interface changes can be refactorings.
Actually, refactor is a mathematical principle whose definition doesn't
even *address* the programming world.

I think you confuse with the Open Closed Principle. The Open Closed
Principle and refactoring are perpendicular ways to adapt code in a
_controlled_ fashion: The Open Closed Principle leaves the structure
intact, while refactoring makes sure the code behaviour remains the same
while you are restructuring it.
Perpendicular... Open Closed Principle... blecchh.

Might just as well call them the Democrat, Libertarian and Republican
methods - for all the clarity it brings.
Aug 26 '07 #23
Jerry Stuckle wrote:
And that's where I disagree with the author of the refactoring site. But
that's one person's opinion. Other people who have written about
refactoring

That's the way these discussions usually end up.
You get a bunch of folks who take a word like gigglethorpe, and each
assigns to it a meaning comfortable to himself. Then they argue which
one is the "true" meaning.

After digging in, I find that refactor is not an "opinion" word - it s a
mathematical term.

It was hijacked by some MBA's a few years ago, and incorporated into
their political philosophies on programming... like a logo.
Aug 26 '07 #24

"Michael Fesser" <ne*****@gmx.dewrote in message
news:cn********************************@4ax.com...
| .oO(Jerry Stuckle)
|
| >But if you change the function name, parameter list and/or return value,
| >you have to change all of the code calling it. This is NOT refactoring.
|
| http://en.wikipedia.org/wiki/Rename_Method
|
| http://www.refactoring.com/catalog/renameMethod.html

apparently, i'm not up on my lingo.

so what if i change an interface with optional parameters? i then don't need
to change *any* calling code, yet i've changed the interface. is this now
refactoring? further, most php is not written in OOP but with proceedural
code. so, the 'interface' would be a browser, in most cases. technically, i
could change any and all code yet not be mucking with the 'interface'. and
so that we're all clear...an 'interface' *only* exists as a communication
point between a caller and an *OBJECT*. functions alone and of themselves
are NOT interfaces.

as far as i'm concerned, when i 'refactor', i'm doing whatever needs to be
done to existing code to make it better for no other reason (new
enhancement, new logical/business requirement, etc.) than to make it better
(easier to maintain, bring it under standards of practice, make it faster,
etc.). imo, it's not worth splitting hairs over. i suppose it is a good
thing that when my boss and i talk about 'refactoring' some code, we
understand each other...which is the whole point of a word.

like i said before, there's no corner on any of this. 'extreme' programming
is an *OLD* construct under a new, stupid name.

but that's just my 0.02 usd and i appologise if i have stepped on someone
else's sacred cow. ;^)
Aug 28 '07 #25
Steve wrote:
"Michael Fesser" <ne*****@gmx.dewrote in message
news:cn********************************@4ax.com...
| .oO(Jerry Stuckle)
|
| >But if you change the function name, parameter list and/or return value,
| >you have to change all of the code calling it. This is NOT refactoring.
|
| http://en.wikipedia.org/wiki/Rename_Method
|
| http://www.refactoring.com/catalog/renameMethod.html

apparently, i'm not up on my lingo.

so what if i change an interface with optional parameters? i then don't need
to change *any* calling code, yet i've changed the interface. is this now
refactoring? further, most php is not written in OOP but with proceedural
code. so, the 'interface' would be a browser, in most cases. technically, i
could change any and all code yet not be mucking with the 'interface'. and
so that we're all clear...an 'interface' *only* exists as a communication
point between a caller and an *OBJECT*. functions alone and of themselves
are NOT interfaces.
OK, I should have clarified - you can't change the interface except to
*extend* it. Adding optional parameters would be extending the interface.

In this case, the "interface" wouldn't be the browser - the browser has
nothing to do with PHP. Rather, it would be the common function calls.
Interfaces existed long before OO programming! For instance, fopen()
is an interface to the file system.

as far as i'm concerned, when i 'refactor', i'm doing whatever needs to be
done to existing code to make it better for no other reason (new
enhancement, new logical/business requirement, etc.) than to make it better
(easier to maintain, bring it under standards of practice, make it faster,
etc.). imo, it's not worth splitting hairs over. i suppose it is a good
thing that when my boss and i talk about 'refactoring' some code, we
understand each other...which is the whole point of a word.
Then how do you differ between "refactoring" and "rewriting"? There is
a difference!
like i said before, there's no corner on any of this. 'extreme' programming
is an *OLD* construct under a new, stupid name.

but that's just my 0.02 usd and i appologise if i have stepped on someone
else's sacred cow. ;^)


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 28 '07 #26

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:W5******************************@comcast.com. ..
| Steve wrote:
| "Michael Fesser" <ne*****@gmx.dewrote in message
| news:cn********************************@4ax.com...
| | .oO(Jerry Stuckle)
| |
| | >But if you change the function name, parameter list and/or return
value,
| | >you have to change all of the code calling it. This is NOT
refactoring.
| |
| | http://en.wikipedia.org/wiki/Rename_Method
| |
| | http://www.refactoring.com/catalog/renameMethod.html
| >
| apparently, i'm not up on my lingo.
| >
| so what if i change an interface with optional parameters? i then don't
need
| to change *any* calling code, yet i've changed the interface. is this
now
| refactoring? further, most php is not written in OOP but with
proceedural
| code. so, the 'interface' would be a browser, in most cases.
technically, i
| could change any and all code yet not be mucking with the 'interface'.
and
| so that we're all clear...an 'interface' *only* exists as a
communication
| point between a caller and an *OBJECT*. functions alone and of
themselves
| are NOT interfaces.
| >
|
| OK, I should have clarified - you can't change the interface except to
| *extend* it. Adding optional parameters would be extending the interface.
|
| In this case, the "interface" wouldn't be the browser - the browser has
| nothing to do with PHP. Rather, it would be the common function calls.
| Interfaces existed long before OO programming! For instance, fopen()
| is an interface to the file system.

well, the op was regarding best programming practices in gereral. either
way, the user interface is very much a part of any language whether it is a
command-line or gui. in general, especially in case of the command-line, it
is equally effected by such changes (think of argument changes or command
name changes). i understand the difference between what we're talking about
and this idea, but the two don't always have a black/white distinction. the
main point i was trying to make is that functions are not interfaces, and if
they are - such as fopen being an 'interface' to the file system - then so
too are the methods a user interacts with in an application - their (caller)
way into accessing a set of features ('interfaces'). such an equation
doesn't help in distinguishing development tasks.
| as far as i'm concerned, when i 'refactor', i'm doing whatever needs to
be
| done to existing code to make it better for no other reason (new
| enhancement, new logical/business requirement, etc.) than to make it
better
| (easier to maintain, bring it under standards of practice, make it
faster,
| etc.). imo, it's not worth splitting hairs over. i suppose it is a good
| thing that when my boss and i talk about 'refactoring' some code, we
| understand each other...which is the whole point of a word.
| >
|
| Then how do you differ between "refactoring" and "rewriting"? There is
| a difference!

besides symantics, what is the superior definition and use of 'refactoring'.
anytime you 'refactor' code, you 'rewrite' it. i'm fine, as an employer,
when a developer says, 'i redid/willdo this to do/behave/help with this...it
impacted (will impact) this/these things.' THAT is more meaningful than
EITHER term. moreover, i just don't thing 'redid' and 'willdo' would have
sounded very 'extreme' and hence was not included in the book(s). ;^)

when discussing changes that need to be made in code with a client, i don't
use either term. i talk about things he understands like speed, flexibility,
longevity, scale, and costs (both long and short-term). when discussing
changes with my boss, i talk about strategy and architecture. and with my
employees, i talk about what i need done specific to all of the above...and
if in the course of their changes, they see a pattern, potential problem, or
oportunity that should be addressed, we get down to *specifics*...not lingo.

but that's just me. everything is a rewrite...or an origination. what
benefit is it to anyone to split hairs over a term that is itself, already
controvertial and unclear?

don't get me wrong, jerry. i think saunders kaufman has his head squarely up
his ass, which explains why he's 'in the dark' on this topic. however, i've
done all the 'extreme' stuff including paired programming, bidding, etc.. as
i've said, it comes from common practices in other fields all the way back
to the early 1900's. ain't nothn' 'extreme' about it as far as programming
is concerned. as for the lingo associated with it, may it forever be limited
to the context of the book that espoused it. for me, i use specifics when i
need someone else to understand what i'm doing or what they need to do.
'refactoring' is not specific enough.

if it works for someone else, i'm glad.

cheers.
Aug 29 '07 #27
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
but that's just me. everything is a rewrite...or an origination. what
benefit is it to anyone to split hairs over a term that is itself, already
controvertial and unclear?

don't get me wrong, jerry. i think saunders kaufman has his head squarely up
his ass, which explains why he's 'in the dark' on this topic. however, i've
done all the 'extreme' stuff including paired programming, bidding, etc.. as
i've said, it comes from common practices in other fields all the way back
to the early 1900's. ain't nothn' 'extreme' about it as far as programming
is concerned. as for the lingo associated with it, may it forever be limited
to the context of the book that espoused it. for me, i use specifics when i
need someone else to understand what i'm doing or what they need to do.
'refactoring' is not specific enough.
It's always so wild when someone STARTS by saying I have my head up my
butt, and then GOES ON to say why they agree with me about stuff.

But I wonder - what is it about the nature of this industry that seems
draw such self-contradictory folks in *droves*.

I mean, if it was just here and there, it would be one thing. But our
industry has become somewhat of a national joke because of this kind of
bad character.

I'm not a very good coder - probably never will be - but I get a lot of
gigs where the client says something like, "Hey, your not as belligerent
as the last 12 web developers I hired" or "Wow, that's pretty
straight-forward. How come the last 8 developers couldn't say it that
plainly?".

The reason is obvious, would you rather hire a genius to belittle you,
your company and your project - or a half-wit who will get the job done.


Aug 29 '07 #28
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:W5******************************@comcast.com. ..
| Steve wrote:
| "Michael Fesser" <ne*****@gmx.dewrote in message
| news:cn********************************@4ax.com...
| | .oO(Jerry Stuckle)
| |
| | >But if you change the function name, parameter list and/or return
value,
| | >you have to change all of the code calling it. This is NOT
refactoring.
| |
| | http://en.wikipedia.org/wiki/Rename_Method
| |
| | http://www.refactoring.com/catalog/renameMethod.html
| >
| apparently, i'm not up on my lingo.
| >
| so what if i change an interface with optional parameters? i then don't
need
| to change *any* calling code, yet i've changed the interface. is this
now
| refactoring? further, most php is not written in OOP but with
proceedural
| code. so, the 'interface' would be a browser, in most cases.
technically, i
| could change any and all code yet not be mucking with the 'interface'.
and
| so that we're all clear...an 'interface' *only* exists as a
communication
| point between a caller and an *OBJECT*. functions alone and of
themselves
| are NOT interfaces.
| >
|
| OK, I should have clarified - you can't change the interface except to
| *extend* it. Adding optional parameters would be extending the interface.
|
| In this case, the "interface" wouldn't be the browser - the browser has
| nothing to do with PHP. Rather, it would be the common function calls.
| Interfaces existed long before OO programming! For instance, fopen()
| is an interface to the file system.

well, the op was regarding best programming practices in gereral. either
way, the user interface is very much a part of any language whether it is a
command-line or gui. in general, especially in case of the command-line, it
is equally effected by such changes (think of argument changes or command
name changes). i understand the difference between what we're talking about
and this idea, but the two don't always have a black/white distinction. the
main point i was trying to make is that functions are not interfaces, and if
they are - such as fopen being an 'interface' to the file system - then so
too are the methods a user interacts with in an application - their (caller)
way into accessing a set of features ('interfaces'). such an equation
doesn't help in distinguishing development tasks.
Actually, functions have always been defined as interfaces. Even before
OO programming came along, it was common to build a library of functions
to perform a set of actions - similar to the file calls in PHP and C.

And yes, the methods a user interacts with an application is an
interface - widely known as the "user interface".
>
| as far as i'm concerned, when i 'refactor', i'm doing whatever needs to
be
| done to existing code to make it better for no other reason (new
| enhancement, new logical/business requirement, etc.) than to make it
better
| (easier to maintain, bring it under standards of practice, make it
faster,
| etc.). imo, it's not worth splitting hairs over. i suppose it is a good
| thing that when my boss and i talk about 'refactoring' some code, we
| understand each other...which is the whole point of a word.
| >
|
| Then how do you differ between "refactoring" and "rewriting"? There is
| a difference!

besides symantics, what is the superior definition and use of 'refactoring'.
anytime you 'refactor' code, you 'rewrite' it. i'm fine, as an employer,
when a developer says, 'i redid/willdo this to do/behave/help with this...it
impacted (will impact) this/these things.' THAT is more meaningful than
EITHER term. moreover, i just don't thing 'redid' and 'willdo' would have
sounded very 'extreme' and hence was not included in the book(s). ;^)
Yes and no. Refactoring typically is more limited - for instance,
recoding a function, set of functions, class, etc., without having to
change code which calls those functions or class members.
when discussing changes that need to be made in code with a client, i don't
use either term. i talk about things he understands like speed, flexibility,
longevity, scale, and costs (both long and short-term). when discussing
changes with my boss, i talk about strategy and architecture. and with my
employees, i talk about what i need done specific to all of the above...and
if in the course of their changes, they see a pattern, potential problem, or
oportunity that should be addressed, we get down to *specifics*...not lingo.
I do the same. I don't even talk about "rewriting" the code. I don't
even talk about architecture, and the only strategy is that which has to
be in place to get the job done. Rather, I talk about the benefits he
will receive from whatever I'm going to do.
but that's just me. everything is a rewrite...or an origination. what
benefit is it to anyone to split hairs over a term that is itself, already
controvertial and unclear?
It's fun? :-) But you're right, it's not really worth splitting hairs over.
don't get me wrong, jerry. i think saunders kaufman has his head squarely up
his ass, which explains why he's 'in the dark' on this topic. however, i've
done all the 'extreme' stuff including paired programming, bidding, etc.. as
i've said, it comes from common practices in other fields all the way back
to the early 1900's. ain't nothn' 'extreme' about it as far as programming
is concerned. as for the lingo associated with it, may it forever be limited
to the context of the book that espoused it. for me, i use specifics when i
need someone else to understand what i'm doing or what they need to do.
'refactoring' is not specific enough.
I think Sanders is just being honest when he says he's in the dark about
it. I think most programmers are.

And I also agree there is no "extreme programming". There are "extreme
sports", which can only be done by someone in excellent physical
condition, lots of practice and a willingness to die. But virtually any
programming can be done by a competent programmer versed in the
language, tools, etc. to be used. It just takes some people longer than
others.
if it works for someone else, i'm glad.
Yep.
cheers.

Caio!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 29 '07 #29

"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:Ff***************@newssvr22.news.prodigy.net. ..
| Steve wrote:
| "Jerry Stuckle" <js*******@attglobal.netwrote in message
|
| but that's just me. everything is a rewrite...or an origination. what
| benefit is it to anyone to split hairs over a term that is itself,
already
| controvertial and unclear?
| >
| don't get me wrong, jerry. i think saunders kaufman has his head
squarely up
| his ass, which explains why he's 'in the dark' on this topic. however,
i've
| done all the 'extreme' stuff including paired programming, bidding,
etc.. as
| i've said, it comes from common practices in other fields all the way
back
| to the early 1900's. ain't nothn' 'extreme' about it as far as
programming
| is concerned. as for the lingo associated with it, may it forever be
limited
| to the context of the book that espoused it. for me, i use specifics
when i
| need someone else to understand what i'm doing or what they need to do.
| 'refactoring' is not specific enough.
|
| It's always so wild when someone STARTS by saying I have my head up my
| butt, and then GOES ON to say why they agree with me about stuff.

i agree that to me, it's mostly lingo. HOWEVER UNLIKE YOU, i know BOTH
sides - what refactoring is, how it is used, have experienced the entire
'extreme programming' gammut. i have an INFORMED opinion while you not only
have your head up your ass, you seem quite comfortable in leaving it there
and speaking from it.

see the difference?
| The reason is obvious, would you rather hire a genius to belittle you,
| your company and your project - or a half-wit who will get the job done.

now that would entirely be based on the premise that 1) all geniuses
belittle people and 2) a half-wit can actually get the job done.

i'm glad you get jobs, but your category of 'wittedness' probably only
allows you exposure to those jobs that have little impact on things. if you
up the requirements or up the stakes, so too must you find developers that
can deliver. those would be the ones who learn about their industry
standards, practices, and yes, even lingo so that their expertise will lend
the best solution.

but you go ahead and be happy throwing dispution on things which you know
nothing about.
Aug 29 '07 #30

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:WN******************************@comcast.com. ..
| Steve wrote:
| "Jerry Stuckle" <js*******@attglobal.netwrote in message
| news:W5******************************@comcast.com. ..
| | Steve wrote:
| | "Michael Fesser" <ne*****@gmx.dewrote in message
| | news:cn********************************@4ax.com...
| | | .oO(Jerry Stuckle)
| | |
| | | >But if you change the function name, parameter list and/or return
| value,
| | | >you have to change all of the code calling it. This is NOT
| refactoring.
| | |
| | | http://en.wikipedia.org/wiki/Rename_Method
| | |
| | | http://www.refactoring.com/catalog/renameMethod.html
| | >
| | apparently, i'm not up on my lingo.
| | >
| | so what if i change an interface with optional parameters? i then
don't
| need
| | to change *any* calling code, yet i've changed the interface. is
this
| now
| | refactoring? further, most php is not written in OOP but with
| proceedural
| | code. so, the 'interface' would be a browser, in most cases.
| technically, i
| | could change any and all code yet not be mucking with the
'interface'.
| and
| | so that we're all clear...an 'interface' *only* exists as a
| communication
| | point between a caller and an *OBJECT*. functions alone and of
| themselves
| | are NOT interfaces.
| | >
| |
| | OK, I should have clarified - you can't change the interface except to
| | *extend* it. Adding optional parameters would be extending the
interface.
| |
| | In this case, the "interface" wouldn't be the browser - the browser
has
| | nothing to do with PHP. Rather, it would be the common function
calls.
| | Interfaces existed long before OO programming! For instance, fopen()
| | is an interface to the file system.
| >
| well, the op was regarding best programming practices in gereral. either
| way, the user interface is very much a part of any language whether it
is a
| command-line or gui. in general, especially in case of the command-line,
it
| is equally effected by such changes (think of argument changes or
command
| name changes). i understand the difference between what we're talking
about
| and this idea, but the two don't always have a black/white distinction.
the
| main point i was trying to make is that functions are not interfaces,
and if
| they are - such as fopen being an 'interface' to the file system - then
so
| too are the methods a user interacts with in an application - their
(caller)
| way into accessing a set of features ('interfaces'). such an equation
| doesn't help in distinguishing development tasks.
| >
|
| Actually, functions have always been defined as interfaces. Even before
| OO programming came along, it was common to build a library of functions
| to perform a set of actions - similar to the file calls in PHP and C.

all fine lines i suppose. i'm thinking of dll's here. i've always thought of
libraries as precursors to oop encapsulation...hence, really object-like.
but i do see your point.

| And yes, the methods a user interacts with an application is an
| interface - widely known as the "user interface".

thus my allusion of 'gui'. ;^) but i digress...

| | as far as i'm concerned, when i 'refactor', i'm doing whatever needs
to
| be
| | done to existing code to make it better for no other reason (new
| | enhancement, new logical/business requirement, etc.) than to make it
| better
| | (easier to maintain, bring it under standards of practice, make it
| faster,
| | etc.). imo, it's not worth splitting hairs over. i suppose it is a
good
| | thing that when my boss and i talk about 'refactoring' some code, we
| | understand each other...which is the whole point of a word.
| | >
| |
| | Then how do you differ between "refactoring" and "rewriting"? There
is
| | a difference!
| >
| besides symantics, what is the superior definition and use of
'refactoring'.
| anytime you 'refactor' code, you 'rewrite' it. i'm fine, as an employer,
| when a developer says, 'i redid/willdo this to do/behave/help with
this...it
| impacted (will impact) this/these things.' THAT is more meaningful than
| EITHER term. moreover, i just don't thing 'redid' and 'willdo' would
have
| sounded very 'extreme' and hence was not included in the book(s). ;^)
| >
|
| Yes and no. Refactoring typically is more limited - for instance,
| recoding a function, set of functions, class, etc., without having to
| change code which calls those functions or class members.

right. when i do use 'refactoring' in conversation, my boss knows i mean
that i'm not adding an enhancement and am usually just bringing shitty
coding practices into our standard...reformatting, consolidating code where
it is obvious some yahoo got the first bit working and then pasted it
elsewhere and maybe just changed on thing about it. hell, i did that this
week...some dumbass had 1,000 lines of billing validation for a 'current'
table, pasted that code right below and only changed the 'current' to
'history'. and the 1,000 lines where shit to begin with. i bettered the
query and got it to 200-ish. sorry, had to vent.

| when discussing changes that need to be made in code with a client, i
don't
| use either term. i talk about things he understands like speed,
flexibility,
| longevity, scale, and costs (both long and short-term). when discussing
| changes with my boss, i talk about strategy and architecture. and with
my
| employees, i talk about what i need done specific to all of the
above...and
| if in the course of their changes, they see a pattern, potential
problem, or
| oportunity that should be addressed, we get down to *specifics*...not
lingo.
| >
|
| I do the same. I don't even talk about "rewriting" the code. I don't
| even talk about architecture, and the only strategy is that which has to
| be in place to get the job done. Rather, I talk about the benefits he
| will receive from whatever I'm going to do.

which is all they want to hear anyway. that, and that you'll have the new
features in place yesterday.

| but that's just me. everything is a rewrite...or an origination. what
| benefit is it to anyone to split hairs over a term that is itself,
already
| controvertial and unclear?
| >
|
| It's fun? :-) But you're right, it's not really worth splitting hairs
over.

lol.

| don't get me wrong, jerry. i think saunders kaufman has his head
squarely up
| his ass, which explains why he's 'in the dark' on this topic. however,
i've
| done all the 'extreme' stuff including paired programming, bidding,
etc.. as
| i've said, it comes from common practices in other fields all the way
back
| to the early 1900's. ain't nothn' 'extreme' about it as far as
programming
| is concerned. as for the lingo associated with it, may it forever be
limited
| to the context of the book that espoused it. for me, i use specifics
when i
| need someone else to understand what i'm doing or what they need to do.
| 'refactoring' is not specific enough.
| >
|
| I think Sanders is just being honest when he says he's in the dark about
| it. I think most programmers are.

well, it's painfully obvious he doesn't. however, those other 'most'
programmers don't put down anything they know they don't know
about...especially with the fervor that he does.

keep 'em truck'n.
Aug 29 '07 #31
Jerry Stuckle wrote:
Yes and no. Refactoring typically is more limited - for instance,
recoding a function, set of functions, class, etc., without having to
change code which calls those functions or class members.
I've been having a LOT of fun with that word ever since that discussion
we had about it.

The other day I was talking to a fellow who wanted to know how I was
doing with this framework. He liked what I've said about it so far, and
may very well pony up a few KiloBucks for me to mash his website into my
framework.

He asked me to tell him about whatever I was currently doing with it and
I said that I had to "refactor" it to make sure that I could later add
other DBMS's to it and the user not have to change their code. (That's
the correct use of "refactor", right?)

Man! The look he gave me!

I saw he was nervous, so I laughed and said, "no what I mean is..." and
then explained what I was doing in better detail.

It turns out that "refactor" is a scary word for him - one that's caused
him serious coin in the past. He said it's like when politicians say
they're leaving office "to spend time with my family"

He's not a technie; he's a businessman. So while he may not understand
the nitty-gritty of programming - he know's when he's being bull-shitted.

I do the same. I don't even talk about "rewriting" the code. I don't
even talk about architecture, and the only strategy is that which has to
be in place to get the job done. Rather, I talk about the benefits he
will receive from whatever I'm going to do.
Amen.

And I also agree there is no "extreme programming". There are "extreme
sports", which can only be done by someone in excellent physical
condition, lots of practice and a willingness to die.
I think of these buzz-word processes as Legacy business logic. A
pattern that may have worked will in the 20th century, when IT was new,
but not so much in the present day.

Now that computers, for most people, are not scary, impossibly complex,
proprietary things - folks are more comfortable hearing the real talk -
instead of the talk about the talk.

Aug 29 '07 #32
Steve wrote:
i agree that to me, it's mostly lingo. HOWEVER UNLIKE YOU, i know BOTH
sides - what refactoring is, how it is used, have experienced the entire
'extreme programming' gammut. i have an INFORMED opinion while you not only
have your head up your ass, you seem quite comfortable in leaving it there
and speaking from it.
Man, I wish I could get my twit-filter working.
Aug 29 '07 #33
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
| I think Sanders is just being honest when he says he's in the dark about
| it. I think most programmers are.

well, it's painfully obvious he doesn't. however, those other 'most'
programmers don't put down anything they know
Really?!
In my experience, and I speak FOR myself as well, most engineering types
are HIGHLY critical of things they don't understand.

It's a side-effect of keeping yourself informed. If you're a smart
engineer, and you've kept your skills sharp, and then some businessman
comes along and tells you that "waterfall" or "extreme" or "agile" is
THE best way for you to work - you'd be a fool not to be critical.

Especially if, like so many of us here, you're an individual contributor.
Aug 29 '07 #34
On Aug 29, 2:41 pm, Sanders Kaufman <bu...@kaufman.netwrote:
Steve wrote:
"Jerry Stuckle" <jstuck...@attglobal.netwrote in message
| I think Sanders is just being honest when he says he's in the dark about
| it. I think most programmers are.
well, it's painfully obvious he doesn't. however, those other 'most'
programmers don't put down anything they know

Really?!
In my experience, and I speak FOR myself as well, most engineering types
are HIGHLY critical of things they don't understand.

It's a side-effect of keeping yourself informed. If you're a smart
engineer, and you've kept your skills sharp, and then some businessman
comes along and tells you that "waterfall" or "extreme" or "agile" is
THE best way for you to work - you'd be a fool not to be critical.

Especially if, like so many of us here, you're an individual contributor.
Man, I go away for a couple days and 50+ posts, about 20 different
kinds of insults targeted at an individual engineering capabilities,
and still having fun!

Aug 29 '07 #35
ELINTPimp wrote:
On Aug 29, 2:41 pm, Sanders Kaufman <bu...@kaufman.netwrote:
>Especially if, like so many of us here, you're an individual contributor.

Man, I go away for a couple days and 50+ posts, about 20 different
kinds of insults targeted at an individual engineering capabilities,
and still having fun!
That's sorta my fault. I'm a real mensch on the political newsgroups
and at least one of my trolls followed me here.

Sorry.
Aug 29 '07 #36

"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:uY*****************@newssvr13.news.prodigy.ne t...
| Steve wrote:
|
| i agree that to me, it's mostly lingo. HOWEVER UNLIKE YOU, i know BOTH
| sides - what refactoring is, how it is used, have experienced the entire
| 'extreme programming' gammut. i have an INFORMED opinion while you not
only
| have your head up your ass, you seem quite comfortable in leaving it
there
| and speaking from it.
|
| Man, I wish I could get my twit-filter working.

why? then you'd think none of your posts were making it to the server!
Aug 29 '07 #37

"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:f5***************@nlpi068.nbdc.sbc.com...
| Steve wrote:
| "Jerry Stuckle" <js*******@attglobal.netwrote in message
|
| | I think Sanders is just being honest when he says he's in the dark
about
| | it. I think most programmers are.
| >
| well, it's painfully obvious he doesn't. however, those other 'most'
| programmers don't put down anything they know
|
| Really?!
| In my experience, and I speak FOR myself as well, most engineering types
| are HIGHLY critical of things they don't understand.
|
| It's a side-effect of keeping yourself informed. If you're a smart
| engineer, and you've kept your skills sharp, and then some businessman
| comes along and tells you that "waterfall" or "extreme" or "agile" is
| THE best way for you to work - you'd be a fool not to be critical.
|
| Especially if, like so many of us here, you're an individual contributor.

you'd only be a fool NOT TO LEARN WHAT HE WAS TALKING ABOUT...which is why
you should watch leving the word 'fool'...since you hear 'refactoring',
don't look into it, and then talk outta your ass like you understood it
(which makes you even moreso).
Aug 29 '07 #38

"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:6g***************@nlpi068.nbdc.sbc.com...
| ELINTPimp wrote:
| On Aug 29, 2:41 pm, Sanders Kaufman <bu...@kaufman.netwrote:
|
| >Especially if, like so many of us here, you're an individual
contributor.
| >
| Man, I go away for a couple days and 50+ posts, about 20 different
| kinds of insults targeted at an individual engineering capabilities,
| and still having fun!
|
| That's sorta my fault. I'm a real mensch on the political newsgroups
| and at least one of my trolls followed me here.

or perhaps the truth lies in simply stating you are a real mensch and that
wherever you go, people realise this and react to it. unless you're of the
'i'm ok, everyone else is not' type of mentality. jury still out.
Aug 29 '07 #39
| The other day I was talking to a fellow who wanted to know how I was
| doing with this framework. He liked what I've said about it so far, and
| may very well pony up a few KiloBucks for me to mash his website into my
| framework.
|
| He asked me to tell him about whatever I was currently doing with it and
| I said that I had to "refactor" it to make sure that I could later add
| other DBMS's to it and the user not have to change their code. (That's
| the correct use of "refactor", right?)
|
| Man! The look he gave me!

and you were a dumbass to use private lingo to a public audience! 'refactor'
in programming is of no use to someone outside of programming. it could also
be lingo in another context. the fact that you don't know what appropriate
language to speak to whom and when is frightening!

| He's not a technie; he's a businessman. So while he may not understand
| the nitty-gritty of programming - he know's when he's being bull-shitted.

apparently not. he's considering your framework, right. ;^)

| I think of these buzz-word processes as Legacy business logic. A
| pattern that may have worked will in the 20th century, when IT was new,
| but not so much in the present day.

only, with the discussion at hand, refactoring and the greater context it
was birthed in are very sound programming methods to employ to ensure
quality. if you knew what you were talking about, you'd know the practice is
more than just words you don't understand. sad, it involves processes yet
known to you!

| Now that computers, for most people, are not scary, impossibly complex,
| proprietary things - folks are more comfortable hearing the real talk -
| instead of the talk about the talk.

so why the hell would you think lingo is profitably entangled with standard
english...such that you don't know to filter based on audience? that's just
dumb. i already think that about you, why are you giving me more cause?!
Aug 29 '07 #40
..oO(Steve)
>[...]
| | so what if i change an interface with optional parameters? i then
don't
| need
| | to change *any* calling code, yet i've changed the interface. is
this
| now
| | refactoring? further, most php is not written in OOP but with
| proceedural
| | code. so, the 'interface' would be a browser, in most cases.
| technically, i
| | could change any and all code yet not be mucking with the
'interface'.
[...]
OT, but would it be possible for you to use a proper quote indicator '>'
instead of '|' like all others on Usenet? Your posts are very hard to
read, and OE makes it even worse because of its stupid line breaking.

Micha
Aug 29 '07 #41
Michael Fesser wrote:
.oO(Steve)
>| now
| | refactoring? further, most php is not written in OOP but with
| proceedural
| | code. so, the 'interface' would be a browser, in most cases.
| technically, i
| | could change any and all code yet not be mucking with the
'interface'.
[...]

OT, but would it be possible for you to use a proper quote indicator '>'
instead of '|' like all others on Usenet? Your posts are very hard to
read, and OE makes it even worse because of its stupid line breaking.
Thanks for posting that. I thought I had a checkbox wrong somewhere
that was creating the mish-mash.
Aug 30 '07 #42
OT, but would it be possible for you to use a proper quote indicator '>'
instead of '|' like all others on Usenet? Your posts are very hard to
read, and OE makes it even worse because of its stupid line breaking.

Micha
just cuz it's you doing the asking. ;^)
Aug 30 '07 #43
>OT, but would it be possible for you to use a proper quote indicator '>'
>instead of '|' like all others on Usenet? Your posts are very hard to
read, and OE makes it even worse because of its stupid line breaking.

Thanks for posting that. I thought I had a checkbox wrong somewhere that
was creating the mish-mash.
seems all evidence indicates that you are easily stymmied. ;^)
Aug 30 '07 #44
On Aug 24, 5:41 am, "burgermeiste...@gmail.com"
<burgermeiste...@gmail.comwrote:
First, let me say that this question is a rather general programming
question, but the context is PHP, so I figured this group would have
the most relevant insight.

Anyways, this is also more of an opinion based question than one
seeking a definite answer. Recently, while maintaining a rather large
system. I needed to add an array class member to an object. It was
exactly the same as another class member, except that one array stored
regular products, and the other stored free promotional products. As
such, I needed a way to add products to the new, free array. Since all
the logic was the same between the two arrays aside from the price, I
had a few different options to do this. I'm interested in polling
which way some of the group members feel would have been the best.
Naturally these are abbreviated versions of what I envisioned as
possible solutions.
#1.
public function addArrayA($object){
//logic
$a[] = $object;

}

public function addArrayB($object){
//same logic
$b[] = $object;

}

#2. (These next two are arranged as such, because the class using
these functions is included in many script files,
all of which I may not be aware of, so there would have to be some
default value for the array that was always used
before this new array was needed)
public function addArray($object, $free = NULL){
//logic
if(!$free){
$a[] = $object;
}else{
$b[] = $object;
}

}

or

#3
public function addArray($object, $arr = "a"){
//logic
$$arr[] = $object;

}

I ended up going with option number 1, because I felt that despite the
inefficient, redundant code it would later be more readable to other
programmers that might work on the project. Additionally, I didn't
feel wholly comfortable with default variables being the only
difference between a full price product and a free product. Thoughts?
I will choose option 2.

Or better store it like this:

array (
[0]
type=>free
prod=>pid
[1]
type=>paid
prod=pid

)
http://satya61229.blogspot.com

Aug 31 '07 #45
On Aug 24, 5:41 am, "burgermeiste...@gmail.com"
<burgermeiste...@gmail.comwrote:
<snip>
#1.
public function addArrayA($object){
//logic
$a[] = $object;

}

public function addArrayB($object){
//same logic
$b[] = $object;

}
This may be a good solution for just 2 object arrays. But, for some
generalization, I'd prefer:
public function addArray($object, $key='a'){
$arr[$key][] = $object;
}

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Sep 2 '07 #46
R. Rajesh Jeba Anbiah wrote:
On Aug 24, 5:41 am, "burgermeiste...@gmail.com"
<burgermeiste...@gmail.comwrote:
<snip>
>#1.
public function addArrayA($object){
//logic
$a[] = $object;

}

public function addArrayB($object){
//same logic
$b[] = $object;

}

This may be a good solution for just 2 object arrays. But, for some
generalization, I'd prefer:
public function addArray($object, $key='a'){
$arr[$key][] = $object;
}

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
But this creates much more problems - like keeping track of keys, etc.

Better would be having one array in the object with an "Add" function.
If you need two different arrays, create two different objects.

And if you need to relate the objects, have a second class which allows
you to add as many of these objects as you wish.

This allows as many arrays as the user needs without having to worry
about ensuring you have the correct keys, etc.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 2 '07 #47
In article <37******************@news-server.bigpond.net.au>,
"rf" <rf@invalid.comwrote:
"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:nH*****************@nlpi069.nbdc.sbc.com...
rf wrote:
"Sanders Kaufman" <bu***@kaufman.netwrote in message
>Refactoring?
What's that?

http://www.google.com.au/search?q=refactoring
http://en.wikipedia.org/wiki/Refactoring

Oh, I get it. It's a politically-correct, bidness-safe way of saying you
did something fundamentally wrong and have to re-design the whole damned
thing.

No it is most definately not. If you had read and understood the above
article you would know that.

While you are looking again at the article you may wish to follow the link
to Extreme Programming, of which refactoring is an integral component.

This is not, of course, programming 101. It's many levels above that.
Hmmm, had a quick look at this. Not sure I can see how it differs from
simple best practice. I would call it programming defensively so as not
to get in a mess.

Or is there some big deal I am missing.
May 31 '08 #48
In article <KF*******************@news-server.bigpond.net.au>,
"rf" <rf@invalid.comwrote:
"Sanders Kaufman" <bu***@kaufman.netwrote in message
news:wh************@newssvr14.news.prodigy.net...
Jerry Stuckle wrote:
No, refactoring is changing the implementation without changing the
interface.

IOW, you change HOW you do things, but not WHAT you do. You changed the
interface.

An example of refactoring would be to change a class so that it gets its
data from a relational database instead of a flat file. The function
calls (interface) remain the same, but the code in the functions
(implementation) changes.

Refactoring in OO would mean you would not have to change anything
outside of the class itself.
Ahh - so when I had to use new kinds of parameters - I was rewriting. But
if I'd made it all zero-impact on how it's used, it would have been
refactoring.

I don't get it. I can repeat it and rephrase it. But I don't get it.

This is a real example, taken from the 1970's but still valid.

A function was required to invert a matrix. The programmer decided to use
one method [1] which worked perfectly on the 6x6 test matrix. However when a
real world matrix was fed to the function took too long (estimates (by IBM)
were that for a 30x30 matrix it would have taken, with the then current
hardware, thousands of years to complete).

The function was refactored to use a different [2] method, which inverted
the 30x20 matrix in seconds.

This was _not_ fixing a bug, or even a programming mistake. It was changing
internals of the function to use a more efficient algorithm. Nothing in the
functions interface changed.
So it was re-written. Why not say that and avoid the bullshit.
May 31 '08 #49
On May 7, 2:56 pm, Tim Streater <timstrea...@waitrose.comwrote:
In article <KFRzi.25911$4A1.12...@news-server.bigpond.net.au>,

"rf" <r...@invalid.comwrote:
"Sanders Kaufman" <bu...@kaufman.netwrote in message
news:wh************@newssvr14.news.prodigy.net...
Jerry Stuckle wrote:
>No, refactoring is changing the implementation without changing the
>interface.
>IOW, you change HOW you do things, but not WHAT you do. You changed the
>interface.
>An example of refactoring would be to change a class so that it gets its
>data from a relational database instead of a flat file. The function
>calls (interface) remain the same, but the code in the functions
>(implementation) changes.
>Refactoring in OO would mean you would not have to change anything
>outside of the class itself.
Ahh - so when I had to use new kinds of parameters - I was rewriting. But
if I'd made it all zero-impact on how it's used, it would have been
refactoring.
I don't get it. I can repeat it and rephrase it. But I don't get it.
This is a real example, taken from the 1970's but still valid.
A function was required to invert a matrix. The programmer decided to use
one method [1] which worked perfectly on the 6x6 test matrix. However when a
real world matrix was fed to the function took too long (estimates (by IBM)
were that for a 30x30 matrix it would have taken, with the then current
hardware, thousands of years to complete).
The function was refactored to use a different [2] method, which inverted
the 30x20 matrix in seconds.
This was _not_ fixing a bug, or even a programming mistake. It was changing
internals of the function to use a more efficient algorithm. Nothing in the
functions interface changed.

So it was re-written. Why not say that and avoid the bullshit.
Awesome! Resurrecting a conversation almost a year old!

Well, my stance on calling it 'refactoring' rather than 'internal code
re-written to keep the code scaleable/maintainable/etc' serves a
couple purposes:

First, 'refactoring' means something specific. Not just 're-written',
not just 'debugging'. I personally feel the best person to define
what code refactoring means is Martin Fowler http://www.refactoring.com/
(I'm not saying this looking for a fight, just my opinion). After
reading a little about what refactoring really is, you can see that it
means something different than simple 're-writing'.

Second, it goes along with one of the core reasons we have Design
Patterns - it gives the programmers a language to use to mean specific
things quickly and without having to elaborate. I guess this goes
along with my first point a bit, but bear with me. It is much easier
to say "We'll need to consider refactoring xyz component before we
extend its functionalities" than it is to say "We'll need to review
the architecture and design of the xyz component and see how it is
specifically implemented in regards to its internal interfaces with
sub-components (etc) before we extend its functionalities".

Everyone is welcome to their opinion, and if they feel 'refactoring'
is synonymous with 're-writing' that's fine...as long as your team and
customers understand what you mean. But, if you join my team, you can
be sure that we will use the term 'refactoring' and 're-writing' as
meaning two separate things. Re-writing is when you need to retain
the functionality of a component, but there is no hope in refactoring
the existing (it is so terrible, it will take less resources to throw
it out and start over). Re-writing is NOT the ideal way of doing
things, especially if your code is evolved.

In short, it could be boiled down to something my father said many
times when I was younger 'Say what you mean and mean what you say' (I
know he didn't coin this, but he did say this).

Regards,

Steve
May 31 '08 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
9212
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
2
3920
by: Dave | last post by:
Does anyone know much about this tool? Also, if anyone can point me to a TSQL coding standard, please let me know. -- Dave
136
9201
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
5
3984
by: Ant | last post by:
hi, I'm now using C#. Seeing as though you can declare & initialize or pass a value to a variable on the same line as the declaration, is it still best practice to group all the variables together...
10
2961
by: Ren | last post by:
Hi All, I'm still rather new at vb.net and would like to know the proper way to access private varibables in a class. Do I access the variable directly or do I use the public property? ...
13
3085
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
4
8351
by: Number 11950 - GPEMC! Replace number with 11950 | last post by:
Just looking for the best way to set an image to fill a <divcontainer as a background without upsetting HTML/CSS validation... Thanks in Advance... -- Timothy Casey GPEMC! >11950 is the...
16
2770
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.