NBC, Apple, Iowa discussed on Inside iOS Dev
World Iowa's development two day with you your host Alex Bush and today's episode as part two to the previous episode about IOS interview questions for Senior Developers in two thousand twenty. The article that I wrote S- and this is the part two episode where I'm covering article so in this one. I'm going over questions next question. So we'll start with question number four. What is what is NBC? It's a very fundamental question again. Even though it's very basic question senior developers also need to know about and expected to give more detail on the show more depth of knowledge of such basic questions so NBC stands for Model View Controller. Software Design Pattern apple adopted. It came from small talk. Apple adopted its towards their own. Had has has its own reincarnation of it Model is responsible for data controller is responsible or views responsible rendering the dates and getting input from the user and control are supposed to glue views and models together right and be this coordinator control right at the end of the day. Apples flavor of it is More view skewed towards the view. That's why wouldn't really have controllers. Who Have you controllers what you should know? Besides there's this basics That that I just covered you also need to know and understand that model view controller. Nbc is not your application architecture. That's just a design pattern foot of you and if you want to architecture application especially architectures for scale you probably should go for something something else. Something with more flexibility. Something's more advanced at least. I'M VM MVP COORDINATOR. Design pattern or go for a heavy duty architectures such as viper and ribs but again as a as a senior developer. You should be aware of that so erratic flag that could raise here as well simply not knowing what an NBC is right. What what it stands for. And what that's fundamental Basic design pattern of APP Iowa's Apple Development in general I think they use it on all the platforms but nevertheless I again as I mentioned already as a senior. Dev rather the expectation is that you know. Other design patterns and architectures for further reading. Look at Apple. Apples article on their developer portal. It's called model dash view controller Then ABC's Dotto has a great article Cold lighter view controllers. It's from one of their previous issues of Went UP CIO. Had this Monthly I believe issue of their articles. Then there's another article on a con Lou con Lou. I think that's how I say it that come about massive you controller. Kennedy shoes with NBC. Another one is on a Napa soda actual this podcast inside. Iowa's Dev where and I covered the the issues with controller skull the problem with the problems with controllers another article you could read introduction to n. b. b. m. that's also obviously that article And then another episode of this podcast view models to the rescue As far as I recall Andrew in that episode. Goes over a great example of where? Mvp and could could save your bacon in the overblown view controller. Massive you controller code base and another article could read up on a model view presenter. It's MVP by Martin Fowler. It's on his website. March and following dot com. And as usual. You you'll find those links south. Put Him the Up put the link to the article in the show notes and they're in the further reading for that question. You can find links to those articles that I mentioned. The next question is number five. What do you know about? Singleton's where would you use one? And where would you not Singles Singleton Severi? It's very common design pattern. It'S CONSIDERED TO BE CO CORE. Competencies design pattern and it's used everywhere throughout all of the apple examples and They they actually utilizing soon bilton themselves in the API COCA API that they provide a four us. This jar short answer. Singleton Is a class that returns only one. And the same instance no matter how many times you requested what it really means at the end of the day that you have a type but say networking services and you implement a static or property rather. I think that's typically the implementation called shared or something like that instance and then in there you basically cash that instance the very first time. It's accessed you initials it and then you cash it and that's it. And then every other time when the in through that static property the instances rick. The SINGLETON has requested to return the same instance Singled and Sarah unfortunately anti pattern. They have a lot of issues with them and specifically they encourage global states. The they they really did. Sir and there are a lot of issues with dependency injection they. They really don't help at all with it. They make it more difficult. They you have to tie things to specific concrete types instead of relying and interfaces things like that so and in general even though apple promotes it. I do not recommend using singleton's and I know it's a it's a kind of a debatable topic if you will but there are a lot of prominent articles written about by prominence experienced developers Basically kind of debunking if you will the design pattern than explaining why. It's an anti pattern. So the Rad flak for this question as well you should actually know what a singleton the is and how to implement it and how to work with it even though it's a necessary and or unfortunate evil quite often and for further reading to to kind of get into the details of why. I'm saying it's an anti pattern. There are two resources you could go for. One is actually episode of this podcast. Called Y Singleton are evil and another one is actually similar styles. Single single are evil. It's by you can find this article on Viki Dot C two DOT com. They cover it more. They're in in more details in an an unwrap all the issues with singles. So the next questions number six. What's different between delegates and TV? Oh so this is a this is also quite common question on on. Irs INTERVIEWS THE DETAILED. Yar The cute. Let's let's start with What what is Ki? Ki Ki all right cave your sense. Four key valley observation so delicate design pattern and Kiva observation both are techniques for to establish relationships between objects and delegates establishes and declares using the delegates. You declare one to one relationship using protocols delegate protocols and Dan with Kiva labs operation you declare and establish a many to many relationship using other techniques but mostly. It's a kind of declarative key valor. While the that that's in the name Kiva Observation and your keys likely will be there strings or I believe you could use like selectors or something about for but the idea is if you want to when he needs to pass a message from one object to another you need to be aware are you in which type of relationship you are. Do you want to just send that message to one object than its delegates you want you wanNA use. Delegate Design Pattern and that object that receives the message will have to implement that protocol a delegate protocol and the delegate t will have to have a reference to that object that implements that protocol and with Kiva labs operation. You and then another one is Kiva variation if you want to send a message. But they're multiple receivers You you you could use key validation and then broadcast message and then whoever's listening and the the the broadcaster doesn't need to know who's listening there's a need to have a reference to them and then the listeners subscribe using What is it called the default censure notifications something something like that object and then they they use that to subscribe to those broadcasts that other objects and broadcast messages. And then one or mania of those or non actually could be observing that those broadcasts. That's that's overall the difference there is another TV always a very rudimentary implementation of observable design pattern effectively. And the way better implementations are Rx swift and reactive coca and now we we have combined which does the same dose are functional. Reactive programming libraries. That health with Observable design pattern and this broadcasting in a one to many broadcasting a red flag for this question spoil essentially a season developer should really know Not only the difference between the two But also what are that you know? These are all implementations of observable design pattern and what other options such as combine our our our Rx swift that you have available to implement them further reading for this question. delegation article on on Apples. Dev Portal Key valley observing an S. hipster dot com articles pretty good overview of a key key cave you'll and I highly recommend looking at Two others reactive x dot. Io that's a rx not just Iraq swift but in general Rx reactive ex absurd observable simplemente Shen and fundamental documentation for it and then another one combined. Take a look it up. Apple's documentation on combined framework as I mentioned before f. r. p. implementation kind of covers a lot of it as well and the last question for today number seven. What design patterns are commonly used an IOS APPS? This is sort of. Yeah I mean this is more or less fundamental question. All the developers should know that the children for this is NBC. Singleton delegates and observable observer. Those are the core so called core. Competencies design patterns used in coca coca touch applications. I already covered Singleton Nbc and delegates an observer actual basically covered all of them in other questions. Red Flag for this essentially. When you're interviewers asking this type of question in one form or another basically what they wanna hear is something besides NBC right. They want to know if you know any other designed parents against such a singleton delegate and so on that are commonly used in Iowa's APPs all besides just NBC because Mec's just so basic For everyone and the for further reading model view controller article on Apple Steph portal and them apples Dev portal actually has a another article about core competencies designed parents. The articles called coca design patterns. You can find more more about them. They're all right guys That set for today. This was part. Two of Ios interview questions for senior developers. In Twenty twenty I will. I will do more episodes and cover more questions from from the article. I also wrote a book called the Iowa Interview Guide that covers this questions and many other questions. It breaks down into groups such as you I- questions fundamental questions storage questions and so on so if you're interested checked Lincoln to show notes. Yeah if you WANNA reach us you can tweet us at inside our dev or email us at at how low at inside. Iowa's DOT COM and I'll see you next time..