-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAC Models Refactoring: isModelValid() #1075
Conversation
The default implementation verifies that the number of coefficients in the supplied model is as expected. Specific SAC models extend this function by checking the user constraints (when applicable).
Hi Sergey, sorry for being picky again, can you elaborate a little why we want this? |
As stated in the title, in this pull I did some refactoring. It does not change functionality in any principal way, but rather rearranges internal stuff (by removing copy/pasted code), the purpose being improved maintainability and readability of the code. In particular, the function |
Yeah, I got what you did, but why? I would rather go the opposite way and move |
Ah, now I get your point. Yes, this externalized constants seemed strange to me as well. There might be some reason why this is implemented in this particular way. I do not know it, but I simply assumed that there is a reason and changed the other part to match the style. Personally, I would I implement it the way you suggested, i.e. with virtual |
Would be great :). |
I wonder what would be better:
or
The first one is a bit more straightforward, but the second one is presumably faster, because no virtual calls (and |
Shouldn't it be enough to make it a public const and access it directly? |
Won't work, because if we make something public const in the base class, then it should be initialized in the initializer list of the base class constructor. Deriving classes will not be able to modify it later because it is const. |
What about something like: http://stackoverflow.com/questions/9999952/set-const-member-value-from-subclass |
This could work! |
Hey there, hope you don't mind me throwing in some thoughts of mine about this topic: Making the getSampleSize method pure virtual, as I did in my suggestion has the advantage, that it needs to be implemented in direct subclasses, so there is no way of forgetting it for those. However in classes further down the hierarchy (like parallel plane), which could potentially have different sample/coefficient sizes, one had to think of it again. Furthermore declaring it pure virtual could potentionally break existing client subclasses which do not implement getSampleSize yet, for obvious reasons. So this was probably a bad idea in my suggestion. Cheers, |
Hi Stefan, thanks for the inputs. I think exposing variables to the public API is a no-go, we should have a getter function. As I proposed before
We can mark it
This can be addressed by adding compulsory What do you think? |
Sounds good. It should solve the problem of forcing the programmer to specify sample and model sizes like the pure virtual methods but presumably faster. But it also does not solve it for second level subclasses (which I think cannot be sovled and perhaps is also not worth thinking about, because someone implementing a new model will think about and check those values anyway.). But I just thought about the Semantic Versioning System. Is this applied to PCL? Cause then adding a compulsory parameter to the constructors of So for the 1.8.0 version I'd just introduce the |
+1 for the last proposal by @stefanbuettner. Can both of you coordinate who will send a pull request? Thanks for the discussion! |
I'll take care of it. |
The
isModelValid()
function in every SAC model class begins by verifying that the number of coefficients in the passed model is as expected. This pull request extracts this check into the base implementation of this function.