[petsc-dev] How to enforce private data/methods in PETSc?

Junchao Zhang jczhang at mcs.anl.gov
Fri Aug 10 22:29:04 CDT 2018


It seems we do not have naming conventions for private members.
--Junchao Zhang


On Fri, Aug 10, 2018 at 9:43 PM Matthew Knepley <knepley at gmail.com> wrote:

> On Fri, Aug 10, 2018 at 5:43 PM Junchao Zhang <jczhang at mcs.anl.gov> wrote:
>
>>  I met several bugs that remind me to raise this question. In PETSc,
>> object of type A can arbitrarily access object of type B's data. But
>> designer of B may later change the meaning of its data (and of course,
>> update B's interfaces, which are usually local to few files). The designer
>> may think the job is done, but actually it is not.  He/she has to grep the
>> code to know where its data members are accessed (that is relatively easy
>> to get) and what is the contract, for example, is an array assumed to be
>> sorted (that is hard to know).  With C++, one can use private to minimize
>> data exposure.
>>
>
> This just has to be coding discipline. People should not be accessing
> private members.
>
>    Matt
>
>
>> --Junchao Zhang
>>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20180810/7116921a/attachment-0001.html>


More information about the petsc-dev mailing list