Re: reduce redundant code




"MP" <NoSpam@xxxxxxxxxx> wrote in message
news:%23$TdJz6gIHA.4684@xxxxxxxxxxxxxxxxxxxxxxx

"Ralph" <nt_consulting64@xxxxxxxxx> wrote in message
news:%239iw4B6gIHA.5160@xxxxxxxxxxxxxxxxxxxxxxx

"MP" <NoSpam@xxxxxxxxxx> wrote in message
news:OnSAUgXfIHA.3400@xxxxxxxxxxxxxxxxxxxxxxx
Is there any merit to the following idea?

I find myself repeating lines similar to below in many routines
the idea being I may want to process all objects of just objects who
have
certain property or whose "container" or "owner" or "child" has certain
property(ies)
snip
thanks for any comments
mark


Your actually chewing on several things at once here.
Get Fowler's book "Refactoring: Improving the Design of Existing Code".
Impossible to give a specific answer as it depends on the over-all
object
of
your design.
Hints: (???? no idea of this is useful or not. <g>)
Whenever you find yourself with a ton of parameters, think object.
If only certain objects of a specific type support something, why not it
let
the object handle it or ignore it?
"Filters" are usually only concerned with bags of stuff. Make it a
propery/method of the Bag.

-ralph

Hi Ralph,
re: your quote
"Filters" are usually only concerned with bags of stuff.

in my case the bag of stuff is the api of the external program my utils
"interact with"
that bag has lots of kinds of objects

the api presents a collection of all the objects in that file from which I
want to select

<snipped>

While I chew on your example, to see if there is anything I can offer that
is simple (and short <g>). Go purchase "Design Patterns Explained: A New
Perspective on Object-Oriented Design" by Shalloway & Trott. No CD so you
can get it cheap.

You will find a path to a solution starting on page 87. You'll still want to
read the first 86. <g>

-ralph


.



Relevant Pages

  • bags in collections - PEP 320
    ... bag ... Design theory intersects with many fields, ... name bag but most mathematicians use multiset.) ... Our pydesign package ...
    (comp.lang.python)
  • Re: Cobol books & experiences
    ... There is a Wal-Mart near here that is apparently testing a self checkout ... expects you to place the item in a bag on a scale, ... I contented myself with gnashing my teeth, describing the design ...
    (comp.lang.cobol)
  • Re: custom made bag
    ... I cannot find a bag I like, so I want one make accoding to my ... who can custom design a bag for you as long as you have a drawing ... a detailed drawing of your design. ... The only good yank is a dead yank kill the fucker and do the world a ...
    (soc.culture.singapore)
  • Re: AD/ANN: New Pipe Bag Design - The Urban Pipe Bag
    ... Well all I can say is that although familiar with the design you reference, ... my design started with a pattern that came from a company called Wild ... That done my bag pattern although similar to ... Home of the Ultimate Pipe Bag ...
    (alt.smokers.pipes)
  • Re: Henry survival weapon
    ... ## I just am fascinated with the design, love the weatherproof features, ... # # and can throw it in a duffle bag to goto the range. ... # 19 S&W in my camera bag. ... I have a Camera bag that came with my video camera a few years back. ...
    (rec.guns)

Loading