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

Updated all Bool ivars to get rid of special Obj-C backing variables. #2687

Closed
wants to merge 13 commits into from
Closed

Updated all Bool ivars to get rid of special Obj-C backing variables. #2687

wants to merge 13 commits into from

Conversation

jjatie
Copy link
Collaborator

@jjatie jjatie commented Aug 7, 2017

  • There is no more confusion for Bool ivars in the exposed API, as there is only one exposed variable (i.e. no pinchToZoomEnabled and isPinchToZoomEnabled).
  • All backing variables are private, not fileprivate. The backing variables should only be called in the getter/setter of the public ivar.
  • All names internal to Charts have been updated for Swift naming conventions
  • All names external to Charts have obj-c setters with the appropriate obj-c naming convention
  • Almost all open access control on Bool ivars has been changed to public. This is what they should have been in the first place, as overriding all but a few of these ivars would result in unintended consequences.
  • Minor update to demos to support changes.

There are still some names that I would like to be changed, but I left them alone as that is outside the scope of this PR.

jacobchristie and others added 2 commits August 7, 2017 16:46
- There is no more confusion for `Bool` ivars in the exposed API, as there is only one exposed variable (i.e. no `pinchToZoomEnabled` and `isPinchToZoomEnabled`).
- All backing variables are `private`, not `fileprivate`. The backing variables should only be called in the getter/setter of the public ivar.
- All names internal to Charts have been updated for Swift naming conventions
- All names external to Charts have obj-c setters with the appropriate obj-c naming convention
- Almost all `open` access control on `Bool` ivars has been changed to `public`. This is what they should have been in the first place, as overriding all but a few of these ivars would result in unintended consequences.
- Minor update to demos to support changes.
@pmairoldi
Copy link
Collaborator

This would be a breaking change. I think we should hold off on this a bit until we make other breaking changes. If you have ideas on how to improve this to not make it a breaking change I'd be glad to hear them.

@jjatie
Copy link
Collaborator Author

jjatie commented Sep 10, 2017

Unfortunately this needs be a breaking change. As you commented on a few other of my changes, it makes sense to wait until Swift 4/Charts (4?) is released.

@codecov-io
Copy link

codecov-io commented Nov 14, 2017

Codecov Report

Merging #2687 into master will increase coverage by 0.02%.
The diff coverage is 27.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2687      +/-   ##
==========================================
+ Coverage   19.77%   19.79%   +0.02%     
==========================================
  Files         113      113              
  Lines       13663    13644      -19     
==========================================
- Hits         2702     2701       -1     
+ Misses      10961    10943      -18
Impacted Files Coverage Δ
...ata/Implementations/Standard/PieChartDataSet.swift 0% <ø> (ø) ⬆️
Source/Charts/Utils/ViewPortHandler.swift 24.8% <ø> (ø) ⬆️
...urce/Charts/Formatters/DefaultValueFormatter.swift 54.76% <ø> (ø) ⬆️
Source/Charts/Animation/Animator.swift 1.53% <0%> (-0.08%) ⬇️
Source/Charts/Renderers/PieChartRenderer.swift 0% <0%> (ø) ⬆️
...ts/Renderers/YAxisRendererHorizontalBarChart.swift 0% <0%> (ø) ⬆️
...ce/Charts/Renderers/CandleStickChartRenderer.swift 0% <0%> (ø) ⬆️
Source/Charts/Charts/CombinedChartView.swift 0% <0%> (ø) ⬆️
Source/Charts/Charts/PieRadarChartViewBase.swift 0% <0%> (ø) ⬆️
Source/Charts/Charts/PieChartView.swift 0% <0%> (ø) ⬆️
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc40b16...27e76e4. Read the comment docs.

@jjatie
Copy link
Collaborator Author

jjatie commented Nov 22, 2017

Can we either merge this, or create a branch for breaking changes (3.1 or 4.0 I'm guessing?)

@jjatie
Copy link
Collaborator Author

jjatie commented Nov 24, 2017

@petester42 This should be 4.0.0 I guess.

@pmairoldi pmairoldi added this to the 4.0.0 milestone Nov 24, 2017
@jjatie jjatie changed the base branch from master to 4.0.0 December 4, 2017 19:00
@jjatie
Copy link
Collaborator Author

jjatie commented Dec 14, 2017

@petester42 While this change works, it would be ideal to be able to just declare

// in objc, this can be accessed as:
// BOOL x = isBool
// x.isBool = false
// [x setIsBool: false]

@objc var isBool: Bool

This removes the custom setter name setBool:, but given that dot notation for properties is quite prevalent in obj-c now, I think it's acceptable to lose the custom setter name. Thoughts?

@danielgindi
Copy link
Collaborator

Seems reasonable to me to do this, for 4.0.
Please notice that some properties' names changed beyond the Bool issue, like "horizontalHighlightIndicatorEnabled " which was "drawHorizontalHighlightIndicatorEnabled".

One of the main goals of this library is being compatible with its Android counterpart, so we need to keep the naming close (while doing our best to conform to Swift standards).
Btw some things are named in multiple ways, as the Swift standard evolved and things changed. At first it was not clear how to do ObjC compatibility, and some things just couldn't be compatible and we needed bridging functions and variables.
Now ObjC is much less relevant, as Swift is more widely accepted, so personally I worry about that less.

@jjatie
Copy link
Collaborator Author

jjatie commented Dec 24, 2017

@danielgindi Great. I will reevaluate the names this week (maybe today) to try and get the most consistency with android and Swift possible.

Do you think it would be appropriate to drop the custom objc setters as I noted above? It would clean up the code A LOT as there wouldn't need to be a private backing var for every boolean property.

@danielgindi
Copy link
Collaborator

Wherever we can drop the custom objc getter/setters - it's best. They are just another thing that we need to manage and we don't want that...
You wouldn't believe what we had to do for interoperability with objc in Swift 1/2

@liuxuan30
Copy link
Member

That makes me recall this project is started with Swift 1.1, at that time, we have to do something weird from what you see now :)

@jjatie
Copy link
Collaborator Author

jjatie commented Dec 25, 2017

This is a huge codebase change, and as you can see many conflicts are building up. I will resubmit this to 4.0.0 later (likely as in pieces as part of other refactors) to make this more manageable.

@jjatie jjatie closed this Dec 25, 2017
@jjatie jjatie deleted the objc_bool_naming branch December 26, 2017 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants