How to Review Code | Best Practices | Pull/Merge Requests | iOS | Swift | Checklist
HTML-код
- Опубликовано: 10 июл 2024
- In this video, I have discussed about the things which we should keep in mind while reviewing the code (pull/merge request). Apart from this, I’ve also discussed about creating Pull/Merge requests, how to apply merge checks, best practices and compiled all the checks in an exhaustive checklist. Also, demonstrated each check with an example (by reviewing a dummy PR).
Checklist 👇🏼
gist.github.com/pallavtrivedi...
Chapters 👇🏼
00:00 Start
01:53 What’s there in the video.
02:16 Brief about demo project
03:34 How to apply merge checks
05:00 PR Creation
07:00 PR Review
07:58 Unnecessary Imports
08:15 Protocol Conformance in Extensions
09:25 Typo Checks
09:52 View should not have Data Object
10:25 Type Inference
11:46 Responsibility Division
12:00 Naming of the Variables
12:43 Single Responsibility - Different methods for different tasks.
13:10 Unnecessary Checks
14:40 Consider edge cases (keep fallbacks) - Error Handling
15:30 Write code for maintainer
16:24 Hard Coded Values
17:24 Prefer Enums, Switch over if/else
18:30 Use APIs provided by Apple
19:20 Check for Force Unwraps (Prefer Optional Binding)
20:02 Check for Indentations
20:50 Check for efficient Memory Managment (avoid retain cycles)
21:26 Avoid using deprecated APIs
21:56 Dependencies should be injected
23:03 DRY (Don’t Repeat Yourself)
24:08 Prefer Higher Order Functions
25:35 YAGNI Principle (You Aren’t Gonna Need It)
27:33 Early Returns wherever possible
28:15 Check Array’s count before accessing the elements
29:09 ViewModel Should Only Have Business Logic
29:31 Unintended Changes
31:00 Boy-Scout Principle
32:55 Code Review Checklist
I believe it's good practice to also explain the reason for requesting the change in each comment, that way more junior devs can learn new concepts and apply them to their future code.
When given code reviews as a Senior or team member, it’s generally good practice to include sample code snippets along with your feedback. Simply pointing out poor practices is half the journey.😊
Exactly
I was looking for one proper process for code review and you have given exactly that. Thanks for your inputs.
I love the way you explain.
Generally we forgot most of the point while coding but the way you explained every point with an example will remain in mind.
Thanks a lot.
Will expect more interesting content from you😊
Great suggestions, Pallav! Thanks for the useful video, I'll definitely keep watching your next issues :)
very well explained! Thank you!
Really great tips!
Thanks Pallav, please keep posting more and help us to learn more 😊
Sure 🙂
Very much useful, thanks a lot Pallav for this video.
Awesome video. Kudossss!
very useful video , Thanks
Sir please keep going. You are helping a lot of people(Developers) to gain free of cost very information knowledge. :)
Great list! I have not been exposed to CR but wanted to ask someone to take a look. Now I can be ready to look at their code as well. Thanks for the tips!
Hi Pallav, It is great that you provide extreme information free of cost. First of all Love from the heart brother.
I follows you for the last month only. I have learned lots of things from you and I'm trying to implement them in real client projects.
I have created many demos to be a better Sr. iOS Developer, but I was struggling. After checking every single video, I can see improvement. Your style of passing information is very easy and simple to understand complex things.
Please create a video on a learning path. Like where to start, what to learn, and how to learn. Because every developer missed this path and was stuck between multiple topics.
Your series are always have some unique content ... Thanks for making unique content for iOS developers.
Thanks Krishnendra 🙂
nice video bro! u got my subscription!
It’s Best tutorial. I ever found related to Code Review learning. Keep it up bro waiting for your next tutorial.👍
Glad to hear that Rehan. Thanks for your support 🙂
One of the best video
Thanks Pallav. it was very informative.Keep inspiring US 👍🏻
Glad that you found it useful 🙂
Class as always. Thank You Sir.
Thanks 🙂
Yeah... that's right ...even the smallest mistake breaks the code...i was really searching for something that can help mitigate the same ...thanks for the same again ....once again Awesome tricks to mitigate the code gulping mistake .
Glad that you found the video useful. Thanks 🙂
great and clear explanation! thanks for sharing this. greetings from Ukraine!
Very good observations... keep it up. nice content.
Thanks you Sakir 🙂
Just subscribed, nice work👍
Glad that you liked the videos 🙂
Quality content 🔥🔥🔥
Thanks Devesh 🙂
Best Video Ever
Thanks Bro
Super video
Thanks 🙂
Nice video Pallav, with step by step explanation.
Can you make video on iOS app UI Design using storyboard or share some links for UI Design.
also please make video on storyborad code review.
nice
Hey Pallav.. thanks for video first… Appreciate your efforts. One query .. at the start you gave comment 10:18 .. how can VM send the data to VC if not allowed to to declare such thing
at 8:15 of this video, you mentioned to check if there are any unnecessary imports. `Foundation` is unnecessary when `UIKit` is imported already since UIKit contains Foundation.
Was expecting this comment, for some reason there is always someone pointing this out. I dont really see the issue here since UIKit depends on Foundation, Foundation will still be there and there is no overhead in making this explicit, the real issue would be to import something that is not used.
In a UIViewController that has a WKWebView would you remove the "import UIKit" statement because UIKit (and Foundation) is transient dependencies of the "import WebKit" statement? I would definitely not do that since it would be more confusing than helpful.
Is there any option to check the major storyboard/XIB changes?
Good video. I think returning tuple from a method does not promote readability rather a struct should be returned.
Awesome tips, good learning progress with your videos! I have some questions, Pallav. I hope you can answer those.
I didnt' get the part, how the data received from API in VM? Should we make the API calls from VM and return the model to VC?
How about, on best directory structure? For example, Should we keep the models under MVVM folder/module, or create a different folder for Network layer and keep them there as Request/Response models?
Lastly, this is not direct related to this video but do you have any video on working with legacy code (ObjC) in Swift project? Especially, i heard this Adapter pattern that converts Swift objects to be directly used in ObjC classes or vice versa, without needing additional marks in class itself but in Adapter. I think, it will be awesome to watch an implementation video from you.
I'm glad that you are liking my videos.
Regarding your questions -
- I didnt' get the part, how the data received from API in VM? Should we make the API calls from VM and return the model to VC?
View Model is calling method of Network Manager, which is handling web service calls. It returns the model to View Model.
For communication between controller and view model, I'm not passing the model to view, instead, observing the changes on that model using Combine.
If you haven't watched my videos on MVVM and Combine, please do. I've explained this there.
- How about, on best directory structure? For example, Should we keep the models under MVVM folder/module, or create a different folder for Network layer and keep them there as Request/Response models?
The kind of structure that I prefer is -
Module Directory (say Profile) -> 3 directories at Same Level (View, Model, ViewModel). Inside View you can have directory for cells.
If you are having different network configuration for each module, you can have a directory for network to (at the same level). But yeah, root should be for module, and then M, V, VM. It is more manageable (still, personal preference 😅)
For your last point, I'm not having any video/project showing adapter, or bridging between Objc and Swift projects. I'll try to cover it.
Thanks 🙂
@@iCode_Happy_Coding Thanks for answering my questions. I'll look forward to your design pattern videos, especially Adapter. All the best :)
Great videos, REG:- type inference point,
1)var name = "iCode" -> is compiler taking time more
2)var name : String? = ""iCode""-> is compiler taking time less
3)var name : String! = "iCode"- > is compiler taking time less
in 2 and 3 which one is take more to compiler ?? . Please post any video of closures..Thanks in advance
Awesome Content Pallav. Why you stop posting new content now a days ? All Good.
Please make a video on complete App Architecture in Swift UI..like how to separate and communicate Model,Network,VewModel,UI Layers for any kind of application
Thanks for the suggestion Vinay. I’ll try covering it 🙂
Eagerly waiting for this video..thank you..Out of all iOS videos in RUclips Your videos are so clearly explained, unique and practically useful for any iOS dev..you will grow for sure..Keep uploading the videos..All the best!!!
Create a tutorial on CI/CD please.
How code review is done by just reading the code? Dont we have to checkout it build run and test the feature before approving .
So to solve this issue, there's a practice that we follow "Feature Level Approval by QA".
A PR is not merged until it has x number of developer approvals and y number of QA approvals. X and Y can vary depending on team/feature size, but atleast 1 QA approval is required for PR to be merged. That assures that feature is working as expected, while code quality is evaluated by PR review.