Skip to content
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

Refactor code #4

Merged
merged 49 commits into from
Jun 13, 2017
Merged

Refactor code #4

merged 49 commits into from
Jun 13, 2017

Conversation

faizan-khan-iit
Copy link
Contributor

I think the current code in the animint compiler is a bit hard to debug. Especially because the functions are too long (saveLayer spans about 500 lines) and the implementation is mixed up with the logic. As such I sometimes find it difficult to locate the problem as I have to wade through a lot of unrelated code before I get to the buggy part. And often I have a lot of variables that were probably used a 100 lines back cluttering the work-space.

This PR has 2 motives:

  • Separate the implementation from the code: The implementation is separated in a file animintHelpers.R (for now), while the logic stays in the top level functions. This will avoid us going through trivial code in a debugger that probably is totally unrelated to the problem.

  • Reduce the size of functions to easily spot errors and reduce the number of active variables

So the code in the top level functions looks like this:
https://github.com/faizan-khan-iit/animint2/blob/refactor/R/animint.R#L153-L164
with their implementations in other files.

Note: The file helperFunctions.R is composed of functions we probably will never need to care about. So I separated those too.

R/doc.R Outdated
##' @author Toby Dylan Hocking
##' @export
##'
makeDocs <- function(doc.dir){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest deleting this in animint2

@tdhock
Copy link
Collaborator

tdhock commented May 25, 2017

I would suggest removing the meta environment, if possible. since it is mutable, it also makes the code harder to understand.

@faizan-khan-iit
Copy link
Contributor Author

I too think removing the meta environment will help a lot. But it will take some time. I will try it over the weekend and see what I can do..

@faizan-khan-iit
Copy link
Contributor Author

@tdhock Do we need to retain the gg2animint function? I think it will be better that we remove it in the new version.

@tdhock
Copy link
Collaborator

tdhock commented May 29, 2017

it would be great to remove the gg2animint function

R/animint.R Outdated
@@ -955,7 +950,6 @@ animint2dir <- function(plot.list, out.dir = tempfile(),
g.list <- list()
for(p.name in names(ggplot.list)){
ggplot.info <- ggplot.list[[p.name]]
meta$prev.class <- NULL # first geom of any plot should not be next.
for(layer.i in seq_along(ggplot.info$ggplot$layers)){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not need this, I think. It is not updated anywhere in the code

@faizan-khan-iit
Copy link
Contributor Author

@tdhock I was thinking we could merge this PR now, and work on the rest of clean up later. Some part of the code is a bit tricky to deal with, especially selectors that are passed through the meta environment. We can sort it out later.

@tdhock
Copy link
Collaborator

tdhock commented Jun 9, 2017 via email

@faizan-khan-iit
Copy link
Contributor Author

faizan-khan-iit commented Jun 12, 2017

Just as a last note, what should we keep the version number? v2.2017.06.12? You could edit the DESCRIPTION file and merge appropriately.

@tdhock
Copy link
Collaborator

tdhock commented Jun 12, 2017 via email

@faizan-khan-iit faizan-khan-iit merged commit 5cb96a8 into animint:master Jun 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants