If you truly believe that, then share the channel on any social media sites you have 😉
@KSwizzleDrizzle4 жыл бұрын
Thank you so much for this video! I've always been scared of dependency injections because it sounded so complicated. Even articles online do a very poor job of explaining it. But watching this video, I'm baffled by how easy this was!
@mattsanford57566 жыл бұрын
Good intro to the topic. One thing that you’ll find if you work on big projects is that you’re going to have lots of dependencies so you end up creating these bloated initializers that look horrific and suck to use. That’s where protocols come in to take all your dependencies, wrap them up in a nice neat package to be used later on. Testable and swifty!! I think a lot of people could benefit from demonstrating this protocol oriented approach to dependency injection. Keep it up!
@Kilo_Loco6 жыл бұрын
Yea, that’s going to also be covered in a video but I have to do more research to fully understand them. I’m struggling fully grasping how they work and trying to see how the factory pattern plays a role in it all. I do appreciate the comment though
@DanKardell2 жыл бұрын
Great job (your video's always are). However I'm still at a loss as to "why use DI"? it seems like the original code with the singleton was much smaller a straight forward. I get asked about DI all the time, and I'm still not sure of "why do we use it?" Why not keep the isolation inside the function vs having to have the "parent" know about it?
@abdurakhmonjamoliddinov70192 жыл бұрын
I think dependency injection grew because of test driven development, if you initialize inside functions then it's not very testable, one function needs this class and that class needs another one and on, but if you take it as function argument or initializer argument then you can test that function or that class alone by passing some dummy implementation, so basically if you want to test a function alone or some class alone then using dependency injection makes sense
@dev_jeongdaeri4 жыл бұрын
Super cool finally I got what DI is
@ayon35276 жыл бұрын
Good to see you man. Welcome back
@Kilo_Loco6 жыл бұрын
Glad to be back!
@FailMachineInc4 жыл бұрын
What are your thoughts on things like SnapKit?
@rdforte6 жыл бұрын
i keep getting error: Thread 1: Fatal error: init(coder:) has not been implemented
@saitama1676 жыл бұрын
Great informative video! Also that fade looks and fresh 😎
@saitama1676 жыл бұрын
Also when do we get T-Shirts??
@Kilo_Loco6 жыл бұрын
Thanks! I was at a wedding yesterday so I had to look good 😎
@Kilo_Loco6 жыл бұрын
T-shirts are already available Code Passionately T-Shirt www.amazon.com/dp/B07DWKMSX5/ref=cm_sw_r_cp_api_PpCoBbD2J5Z64
@wch09153 жыл бұрын
So much helpful! but im still wonder ViewController is still not testable though you did dependency inhection cos you wanted to make VC testable. right?
@abdurakhmonjamoliddinov70192 жыл бұрын
yeah, ideally we would take protocol as argument and then we can provide some dummy implementation when testing
@yuvrajagarkar89424 жыл бұрын
what is init(nibName: , bundle:) and what is required init() , please list a resource that will explain me this kinda initialiser
@LordStiltskin4 жыл бұрын
You can initialize objects from nib files. And you can pack such nibs in nsbundles. There, you’re specifying if you’re instantiating the superclass from a nib file in a bundle. The required initializer is a requirement set by the superclass so that your class can be saved to disk with nskeyedarchiver with all its properties and can be read and brought back to memory with the saved state (lets the instances of your class survive through app terminations). You can’t save all types to disk, so the compiler requires you to write how you convert your data to supported types. This is a quick, careless comment. Look up the stuff I mentioned and you’ll be able to figure it out.
@omrankhoja3193 жыл бұрын
Great explanation! Thank you!
@matthewbird86036 жыл бұрын
ur content has helped me so much now just gonna go and like all ur vids cos they are so helpful and amazing
@rasheshbosamiya14826 жыл бұрын
Thank you for this tutorial and coming back KZbin. I am bit confused for the difference between Singleton and Dependancy Injection. How does both deals with memory, can you differentiate?
@Kilo_Loco6 жыл бұрын
In this tutorial I am showing how someone might use a singleton as the dependency they are using in their code. Not too sure about memory though
@rasheshbosamiya14826 жыл бұрын
Kilo Loco okay
@TheHy6xD6 жыл бұрын
So, basically I can use it to send data to another VC? I love segues, but I hate storyboards, so I needed to figure out how to send data. Notifications sadly not always work. Thank you!
@Kilo_Loco6 жыл бұрын
Happy I could help
@abdurakhmonjamoliddinov70192 жыл бұрын
have you tried prepareForSegue?
@davidruvinskiy63475 жыл бұрын
Hey Kyle. If you do it programmatically, does that mean you can't do any UI work in the storyboard and you have to do everything programmatically?
@Kilo_Loco5 жыл бұрын
No, you can do it both in storyboards or programmatically. Hell you can even mix and match, I just wouldn't recommend it
@cultibotics6 жыл бұрын
I think the aversion to singletons may have a lot to do with how they can complicate coordinating with others on a team development effort, but, in the context of the lone coder, I'm in agreement. As for testability, why can't test components be built into the singleton class, to be invoked as part of tests of client (of the singleton) code. As for shared state, that's kind of the point. Sometimes you *want* shared state. That's why there are application delegate singletons, for example. It's just important to make sure that the state being shared is only what actually makes sense to be shared, not something specific to the client context.
@sovanndyul75805 жыл бұрын
great explanation.
@naidubangaru32626 жыл бұрын
Excellent Tutorial
@Kilo_Loco6 жыл бұрын
Thanks! Glad you liked it! 👍🏽
@naidubangaru32626 жыл бұрын
can you share Complete Autolayout tutorial ?
@Kilo_Loco6 жыл бұрын
Not sure if I’m going to go down the autolayout path yet. I’m trying to focus on more advanced concepts while moving toward doing things programmatically
@AppalarajuPetaInfo6 жыл бұрын
Kilo Loco that's great Thankyou
@TheAhmadReza6 жыл бұрын
Why just don't use singletone?
@vamseeg10974 жыл бұрын
Singleton is a tightly coupled and you can't test your code as DI usage, since state will change unexpectedly with tons of your classes.
@lubomir.o6 жыл бұрын
awesome tutorial
@Kilo_Loco6 жыл бұрын
Glad you like it!
@kav046 жыл бұрын
with storyboard you can use Object from Object Library and pass it in above of UIViewController representation in Storyboard. This Object will be subclass of SomeService
@Kilo_Loco6 жыл бұрын
Interesting! I will look into that approach as well
@nizz4m6 жыл бұрын
Good explanation kilo loco @ kilo gram, lol 😂
@Kilo_Loco6 жыл бұрын
Glad you liked it 😁
@bngamebee49236 жыл бұрын
thanks man
@tomblah3 жыл бұрын
4:59 not your fault, Xcode's autocomplete is really, really, really, really dumb.
@andrewdavies57225 жыл бұрын
maaan... thank you
@cultibotics6 жыл бұрын
So why not just use static properties and methods, instead of single instance properties and methods. That's partly a matter of aesthetics, and partly a matter of the conflation involved in doing so. Even if you only have a single instance of a class, you may still have use for class properties and methods. Say you don't need that singleton continuously available and want to free up the memory it occupies when it's not in use, and there's a small amount of state that needs to be preserved between instantiations; static properties can be used for that. Also, it probably would be better to make test code static and dedicate the single instance to just what it needs to interact with other code and just the state it needs to preserve between contexts.
@Kilo_Loco6 жыл бұрын
Singletons were used in this example to refer to what most devs mean when they talk about dependency injection. While almost every person uses dependency injection in their code, there are a lot of devs that don’t understand what it really means and what is meant by the other devs that say singletons are bad. This is why I used singletons in this tutorial. Also, you won’t always be using your own objects as dependencies so you can’t control whether they are singletons or objects with static attributes on them.
@cultibotics6 жыл бұрын
Yes, I must confess that I'm among those who don't have a good handle on what's meant by dependency injection. I jumped on the tangential topic of singletons because it's something of a hot-button issue for me; I think singletons have gotten an underserved bad rap. In my admittedly naive view, they are sometimes the best, most appropriate solution, but, because of that bad rap, there isn't much discussion around how best to use them and how to avoid pitfalls. What does it mean to use a class when you only intend for there to be a single instance (at any given time), and how should its functionality be divided between static and instance code? What rules of thumb apply? kzbin.info/www/bejne/bpPRnYSNZaeZkM0
@abdurakhmonjamoliddinov70192 жыл бұрын
interesting, I never thought about using static except for constants, I feel like I am doing something wrong when I use them, maybe that's because of my lack of understanding of them
@cultibotics2 жыл бұрын
@@abdurakhmonjamoliddinov7019 The keyword "static" may have something to do with that. It's a little ugly, and a little misleading.