Making the Code Easier to Read and update #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In your project's README, you mentioned that when you first made this code, you didn't have much experience with Objective C/CoreFoundation. Even though you thought the code might not be great, the app works well and many people use it. I wanted to make the code easier to understand, so I changed the names of some functions and variables.
I fixed a part of the code called
find_itemname()
because it wasn't being used before. I also removedsidebar_insert()
because it didn't do anything. It seems like you were waiting forfind_itemname()
to work properly before makingsidebar_insert()
useful. But after six years, no one has asked for it, so I deleted it.I made the error checking clearer by putting it into two new functions,
ValidArguments()
andValidateSideBarList()
. This makes it easier to see what theadd
,remove
, andlist
options are doing. I also made a new function calledClearSideBarItems()
to remove everything at once, which meansRemoveSideBarItem()
now just removes one item with the help of the improvedFindItemByName()
.I updated the
xcodeproj
files needed to make the code work with the newest Mac Silicon chips.It's a bit difficult to read the diffs, so checking out the final version of the code might be simpler: https://github.com/mosen/mysides/blob/ebd838ade305e850962f88f492dc1ac559834940/src/main.m
With these changes, the code should be easier for you or anyone else to read and work with in the future. You did a great job making something that helps so many people with automating their Macs, even after all this time.