Administrator
|
Hi Ashish,
I think we should keep this example Thanks Jacques Le 04/09/2016 à 08:41, [hidden email] 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("ProductFeatureAndAppl", [productId : productId, productFeatureTypeId : commonProductFeatureId], ["sequenceNum", "defaultSequenceNum"], false); > - if (commonProductFeatureAndAppls) { > - commonProductFeatureIds = EntityUtil.getFieldListFromEntityList(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.ensureViewAllowConstraint(productSearchConstraintList, currentCatalogId, delegator); > - > - // don't care about the sort on this one > - resultSortOrder = null; > - > - commonFeatureResultIdsOrig = ProductSearch.searchProducts(productSearchConstraintList, resultSortOrder, delegator, visitId); > - commonFeatureResultIds = []; > - commonFeatureResultIdIter = commonFeatureResultIdsOrig.iterator(); > - 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 |
Commented out code should always be removed as a general programming
guideline On Sun, Oct 2, 2016 at 1:10 PM, Jacques Le Roux < [hidden email]> wrote: > Hi Ashish, > > I think we should keep this example > > Thanks > > Jacques > > > Le 04/09/2016 à 08:41, [hidden email] 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("ProductFeatureAndAppl", >> [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(productSearchConstraintList, >> 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 >> > > |
Administrator
|
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 < > [hidden email]> wrote: > >> Hi Ashish, >> >> I think we should keep this example >> >> Thanks >> >> Jacques >> >> >> Le 04/09/2016 à 08:41, [hidden email] 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("ProductFeatureAndAppl", >>> [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(productSearchConstraintList, >>> 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 >>> >> |
We could put this in the Wiki, maybe a page and sub-pages with business
logic examples and some documentation. I agree with Taher, code examples do not belong in the code. Regards, Michael Am 02.10.16 um 12:17 schrieb Jacques Le Roux: > 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 < >> [hidden email]> wrote: >> >>> Hi Ashish, >>> >>> I think we should keep this example >>> >>> Thanks >>> >>> Jacques >>> >>> >>> Le 04/09/2016 à 08:41, [hidden email] 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("ProductFeatureAndAppl", >>>> [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(productSearchConstraintList, >>>> 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 >>>> >>> > smime.p7s (5K) Download Attachment |
In reply to this post by Jacques Le Roux
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 < [hidden email]> 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 < >> [hidden email]> wrote: >> >> Hi Ashish, >>> >>> I think we should keep this example >>> >>> Thanks >>> >>> Jacques >>> >>> >>> Le 04/09/2016 à 08:41, [hidden email] 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 >>>> >>>> >>> > |
In reply to this post by Michael Brohl-3
We have something similar for simple methods and Groovy:
https://cwiki.apache.org/confluence/display/OFBIZ/Simple-methods+examples+using+Groovy Am 02.10.16 um 12:25 schrieb Michael Brohl: > We could put this in the Wiki, maybe a page and sub-pages with > business logic examples and some documentation. > > I agree with Taher, code examples do not belong in the code. > > Regards, > > Michael > > > Am 02.10.16 um 12:17 schrieb Jacques Le Roux: >> 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 < >>> [hidden email]> wrote: >>> >>>> Hi Ashish, >>>> >>>> I think we should keep this example >>>> >>>> Thanks >>>> >>>> Jacques >>>> >>>> >>>> Le 04/09/2016 à 08:41, [hidden email] 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("ProductFeatureAndAppl", >>>>> [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(productSearchConstraintList, >>>>> 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 >>>>> >>>> >> > > smime.p7s (5K) Download Attachment |
Administrator
|
In reply to this post by taher
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 < > [hidden email]> 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 < >>> [hidden email]> wrote: >>> >>> Hi Ashish, >>>> I think we should keep this example >>>> >>>> Thanks >>>> >>>> Jacques >>>> >>>> >>>> Le 04/09/2016 à 08:41, [hidden email] 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 >>>>> >>>>> |
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 <[hidden email]> 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 < >> [hidden email]> 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 < >>>> [hidden email]> wrote: >>>> >>>> Hi Ashish, >>>> >>>>> I think we should keep this example >>>>> >>>>> Thanks >>>>> >>>>> Jacques >>>>> >>>>> >>>>> Le 04/09/2016 à 08:41, [hidden email] 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 >>>>>> >>>>>> >>>>>> > -- Coherent Software Australia Pty Ltd PO Box 2773 Cheltenham Vic 3192 Australia Phone: +61 3 9585 6788 Web: http://www.coherentsoftware.com.au/ Email: [hidden email]
--
Coherent Software Australia Pty Ltd http://www.coherentsoftware.com.au/ Bonsai ERP, the all-inclusive ERP system http://www.bonsaierp.com.au/ |
Free forum by Nabble | Edit this page |