Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.programming Subject: Re: Function naming scheme Date: Wed, 19 Apr 2017 22:37:29 +0300 Organization: Aioe.org NNTP Server Lines: 38 Message-ID: References: <20170419121533.114@kylheku.com> NNTP-Posting-Host: HO54yo/wQJHrp4blb7RQ6A.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.14.10 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.programming:7724 Kaz Kylheku wrote: > On 2017-04-19, Victor Porton wrote: >> I have two sets of similar (for pairings of functions from the different >> sets) functions: one for single orders and one for basket orders. > > How about: an order contains a list of items. When that list is > length 1, we call it a single order; when it's two or more, we call it a > basket order. Then we don't need a separate type, with repeated > boiler-plate code that is almost the same except for handling a list > versus one item. Sorry, we have a set relational DB structure where single orders and basket orders are represented differently. I don't have the power to change the DB scheme. So them are two different cases and need to be processed somehow differently (despite having much in common). >> Should I name the functions like ProcessOrder/ProcessOrderBasket or >> ProcessOrderSingle/ProcessOrderBasket? > > I'd use a programming language in which I can have polymorphic function > or method called "process", which can work on objects of various types. > > order.process(); // process the order: any kind of order > > cheese.process(); // process the cheese; totally different We use Perl, we consider to rewrite all our software in PHP. These are set facts, I cannot freely choose a language of preference. We this `cheese` can be don in Perl with object oriented programming, but this would increase complexity rather that decrease. -- Victor Porton - http://portonvictor.org