Hi all,
Can I turn the proposition around? If I was looking for example code to
find products with a feature, I would be looking in the wiki and other
documentation. In other words, I would look in places where examples are to
be found. I would not look in the source code. So putting an example in the
code would make it obscure and hard to find.
Cheers
Paul Foxworthy
On 2 October 2016 at 21:55, Jacques Le Roux
wrote:
> Despite the possible decay, I still think the best place is in the
> context. But it's up to the community.
>
> Jacques
>
>
>
> Le 02/10/2016 à 12:25, Taher Alkhateeb a écrit :
>
>> Put it somewhere in documentation if you want to. Live code is not a place
>> for commented out code snippets, it's bad coding practice and it adds to
>> the entropy and chaos. Commented out code with time decays and eventually
>> becomes broken and does not even work (changing dependencies, API
>> signatures, etc ...). Also, usually when committers see commented out code
>> they think someone put it there because they're working on it and it is
>> important somehow. No code should be important and everything should be
>> subject to refactoring and improvement.
>>
>> I think places where example code is suitable are: documentation and
>> tests.
>> Beyond that, it is just dead weight
>>
>> On Sun, Oct 2, 2016 at 1:17 PM, Jacques Le Roux <
>> jacques.le.r...@les7arts.com> wrote:
>>
>> Then how to keep this interesting code example?
>>>
>>> Jacques
>>>
>>>
>>>
>>> Le 02/10/2016 à 12:12, Taher Alkhateeb a écrit :
>>>
>>> Commented out code should always be removed as a general programming
guideline
On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux <
jacques.le.r...@les7arts.com> wrote:
Hi Ashish,
> I think we should keep this example
>
> Thanks
>
> Jacques
>
>
> Le 04/09/2016 à 08:41, ash...@apache.org a écrit :
>
> Author: ashish
>
>> Date: Sun Sep 4 06:41:20 2016
>> New Revision: 1759147
>>
>> URL: http://svn.apache.org/viewvc?rev=1759147&view=rev
>> Log:
>> Applied patch from jira issue - OFBIZ-8074 - Clean up commented out
>> code
>> in Groovy for Order. Thanks Aman for the contribution.
>>
>> -/*
>> - The following code is commented out because it is just an
>> example
>> of the business logic to retrieve products with a similar feature.
>> -
>> -// get other cross-sell information: product with a common
>> feature
>> -commonProductFeatureId = "SYMPTOM";
>> -// does this product have that feature?
>> -commonProductFeatureAndAppls = delegator.findByAnd("ProductFe
>> atureAndAppl",
>> [productId : productId, productFeatureTypeId :
>> commonProductFeatureId],
>> ["sequenceNum", "defaultSequenceNum"], false);
>> -if (commonProductFeatureAndAppls) {
>> -commonProductFeatureIds = EntityUtil.getFieldListFromEnt
>> ityList(commonProductFeatureAndAppls, "productFeatureId", true);
>> -
>> -// now search for other products that have this feature
>> -visitId = VisitHandler.getVisitId(session);
>> -
>> -productSearchConstraintList = [];
>> -productSearchConstraintList.add(new
>> ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>> -// make sure the view allow category is included
>> -productSearchConstraintList = ProductSearchSession.ensureVie
>> wAllowConstraint(productSearchConstraintList, currentCatalogId,
>> delegator);
>> -
>> -// don't care about the sort on this one
>> -resultSortOrder = null;
>> -
>> -commonFeatureResultIdsOrig = ProductSearch.searchProducts(p
>> roductSearchConstraintList,
>> resultSortOrder, delegator, visitId);
>> -commonFeatureResultIds = [];
>> -commonFeatureResultIdIter = commonFeatureResultIdsOrig.ite
>> rator();
>> -while (commonFeatureResultIdIter.hasNext()) {
>> -commonFeatureResultId = commonFeatureResultIdIter.next
>> ();
>> -// filter out the current product
>> -if (commonFeatureResultId.equals(productId)) {
>> -continue;
>> -}
>> -// filter out all variants
>> -commonProduct = delegator.findOne("Product", [productId :
>> commonFeatureResultId], true);
>> -if ("Y".equals(commonProduct?.isVariant)) {
>> -continue;
>> -}
>> -commonFeatureResultIds.add(commonFeatureResultId);
>> -}
>> -if (commonFeatureResultIds) {
>> -context.commonFeatureResultIds = commonFeatureResultIds;
>> -}
>> -}
>> -*/
>> -
>> // get the DIGITAL_DOWNLOAD related Content records to show
>> the
>> contentName/description