Comments (9)
In GitLab by @valentjn on Nov 17, 2016, 15:00
My two cents:
- I wouldn't say any part of
sgpp::base
has stabilized. I'm only involved for 2.5 years, but as far as I can tell, quite a lot of restructuring and refactoring was done, not only since SG++'s beginnings in 2008, but also in those two years. Ok, there is indeed some code which hasn't been touched in years, but not the core things. And the future's no one's to see π - I generally agree that
const
correctness is a good thing. In fact, all of my code (i.e.,sgpp::optimization
) uses it whenever possible, and I already did some efforts to introduce someconst
correctness insgpp::base
(search the log, examples includesgpp::base::Grid
). - In an ideal world, you would be completely right. But unfortunately, I think
const
correctness cannot be enforced all the way in all situations, at least not in a non-intrusive way. Just one example isGridStorage::getSequenceNumber
. TheGridPoint& index
argument cannot be madeconst
in the current implementation:GridStorage::grid_map::find
needs aconst
reference to aGridPoint*
, and if we made theindex
argumentconst
ant, the given&index
would be aconst GridPoint*
, which of course is incompatible. I suppose that one would need some serious work to fix that. - Besides,
const
correctness isn't that important in the sense that all non-const
-correct code is necessarily bad. My stance is that I useconst
s whenever I can, but when I can't, due to whatever reason, then I don't.
Are there any specific code areas you thought about for adding const
correctness?
from sgpp.
In GitLab by @valentjn on Nov 17, 2016, 15:14
Oh yeah, and w.r.t. the "improve overall code quality without breaking any of the code which builds on top of it": That's only true if you're talking about adding const
s to variable declarations in function bodies. If you mean adding const
s to argument or return types, it will indeed likely break code building on top of it. Where return types are usually no problem, but argument types are.
That's just the thing about const
correctness: If you use it for some code, then you have to use it for all the code which depends on that code. That's why I spent quite some time coding when I was adding some const
s in the core of sgpp::base
.
from sgpp.
In GitLab by @lettrich on Nov 18, 2016, 18:08
Thank you for you for sharing your experiences and your opinion. I agree with the points you made - especially 4. I opened this "issue" more as a discussion/survey to see how much it matters to the main contributors and how much I should car as ultimately my goal is to write good code and help the project (especially parts of sgpp::datadriven
) to improve in features , quality and usability.
As far as adding const
correctness, I have not seen too many places in sgpp::base
(at least the classes I work with) where I would want to add const
but on the other hand many more member functions in sgpp::datadriven
that could be revised.
from sgpp.
In GitLab by @MLocs on Dec 14, 2016, 13:44
I think, to move this discussion forward, we need to consider individual parts. And I just happen to have a good example π : the evaluation of the basis functions is symantically stateless and hence should not change the grid structure. I started to add const modifier to the function and then noticed that BsplineClenshawCurtisBasis evaluation actually does. @valentjn: I may be working on the outdated version of the code, is it something that you are using? Is the evaluation is logically const and the user does not see the changes?
from sgpp.
In GitLab by @lettrich on Dec 22, 2016, 14:30
@MLocs I am not entirely sure which member functions you are talking about but the concept sounds logical. Maybe my observation is related to this. I have noticed this for sgpp::base::operationMultipleEval
. The eval
member function takes the surpluses vector and writes into a result vector. As surpluses should not be changed by the evaluation process, I think the argument should be const
. I also think that the eval
member function from a conceptual perspective should not change the state of the operationMultipleEval
object und thus be a const
member function.
from sgpp.
In GitLab by @valentjn on Dec 22, 2016, 14:42
Oops, sorry @MLocs, that one slipped through my attention (blame the many MR mails). No, it's not an outdated version of the code. I agree with both of you, the evaluation should logically be a const
method (i.e., user doesn't see the state's changes), but BsplineClenshawCurtisBasis
stores some temporary vectors as member variables in the object. Otherwise, for each eval
call these objects would've be allocated and de-allocated on the stack, which should be much slower. Downsides of that approach are that you can't use const
and that you get issues when trying to parallelize with only one basis object. I guess it's the old discussion "fast/efficient code" vs. "good code" ("good" from a software engineering point of view). I'm not sure if there's an alternative solution that's both fast and good.
from sgpp.
In GitLab by @MLocs on Dec 23, 2016, 13:22
Yes, I addressed both of your concerns (I think) in my current branch as a side note to what I was currently doing π
@valentjn The solution was to declare your cache member variables as mutable. This way I tell compiler that those are not seen outside of the class and the methods modifying the cache can still be logically constant.
from sgpp.
In GitLab by @valentjn on Dec 23, 2016, 13:33
Ah--lo and behold! The endless depths of the many mysteries of C++ provide a solution for this very problem (usually the depths introduce even more mysteries). I did not know the mutable
keyword. Guess it's never too late to learn new things π
Thanks and Merry Christmas Valeriy (I just saw I forgot it in the e-mail).
from sgpp.
In GitLab by @MLocs on Dec 23, 2016, 13:40
Merry Christmas to you too! π :mother_christmas: π π
from sgpp.
Related Issues (20)
- Issues Installing on Windoze HOT 4
- Travis Minimal. Job Boost Libraries Missing HOT 1
- SG++ lacks clear contributing policies
- Condense evalDx & evalDxDx for certain Bsplines
- Copyright & style (& linter?) checks for Python code
- Python 3.8 support on Windows HOT 2
- Issue With MatLab Binaries HOT 9
- error: βnβ not specified in enclosing βparallelβ HOT 4
- Better release automation with travis HOT 1
- MinGW and localtime_r HOT 3
- DataMatrix::resizeToSubMatrix off-by-two error
- DataMatrix::resizeRowsCols returns wrong matrix HOT 3
- pysgpp fails to import on linux HOT 3
- Avoiding LF/CRLF line terminations issues
- Missing extensions directory (compiling with GCC under Linux) HOT 1
- build fails on AArch64, Fedora 33
- pysgpp does not work on Windows with Python 3.8+ HOT 1
- Several compiler warnings with MSVC++ HOT 1
- Julia API HOT 2
- Compilation problem newer versions because of depreceated "distutils" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sgpp.