Skip to main content
Loading Explore guides…
Software Architecture Interview Questions · Acedra
Home
Explore
Computer Science
Software Architecture Interview Questions
Sign in to save
Chat
If YouTube asks you to sign in, open the video on YouTube.
Watch on YouTube
Reload player
Transcript
205 segments
Copy
Hide video
0:00
Good morning, good afternoon, good evening from whichever location you are watching this video and welcome to Questpond’s YouTube channel and today what we are doing, today we are going to go and cover 25 important architecture interview questions 25 important questions around software architecture in this 2 hours we will be talking about how to explain the project architecture we will be talking about architecture style, architecture pattern, design patterns,
0:26
structural, behavioral, creational we will discuss some questions around singleton pattern. MVC, MVP, MVVM, layered architecture, tired architecture and many other things disclaimer, disclaimer, disclaimer please note by just watching my videos you are not going to become an architect you are not going to go and crack architect interviews it is very important you should have experience you should have led your team technically
0:53
you should have solved some complex POC you do understand design patterns you don’t understand architecture pattern then you will say sir. Video what is this video all about this video is a revision video see happens is as a senior Share this video on your Linkedin Account, Email us at questpond@questpond.com and claim free access to Part 2 video on SOLID Principles Interview Questions & Answers but when you go for
1:26
interview there are questions which comes up. A quick revision is needed and this video will help you to revise quickly that’s disclaimer which you need to understand now very quickly I would like that if you guys can participate in two or three things in this whole video if you can do some participation that would help the community that would help me also for my further syllabus first thing I am sure that you are going for architect interview
1:53
you have been asked architecture questions if you can go and put down in the comments below saying that I was asked this question. I answered like this and this happened that would not only help the community but also we are recording further videos in the syllabus I will try to include them second thing is I am a teacher at the end of the day I want to know that are students really enjoying my lessons am I fruitful isn’t it in this two hours of video let
2:19
us say that if you are on the 20th minute or let us say that if you are on the 50th minute if you can just put down out there and say that ok I am on the 50th minute and I have completed till here. This will help me to analyze that how many people have completed my tutorial until what level and third important thing is I am giving you a gift at the last part of this video there is a beautiful gift out there and I would want that you should watch the complete video and
2:46
check out for the gift let us get started and here is the syllabus 25 questions I am flashing on the screen you can see right out there I am scrolling all the 25 questions which is going to go and cover the basic questions. MVC, MVP, MVVM, singleton pattern and then all the other questions what you are seeing on the screen let us get started with the first question, let us start with some candidate driven interview question what exactly is a
3:14
candidate driven interview question a candidate driven interview question is a question when you answer that question depending on your answer the interviewer can ask you connected questions or let me use that word over here you can provoke the interviewer to ask questions. Accordingly for example if the interviewer asks you which design pattern have you used in your project and you say that I have used singleton pattern I have used repository pattern I have
3:39
used CQRS it is very much possible that the interviewer can ask you questions around these three patterns now why is it important to identify candidate driven interview question it is important to identify candidate driven interview question because it will help you to control the interview think about it if you can provoke the interviewer to ask you. Questions and that questions which you are good in you are actually trying to bring the interviewer
4:05
in your area and that will make your interview easy and you can easily crack the interview it is important to identify candidate driven interview question and this first question is a candidate driven interview question let us start with it. This is a banking project very good project right. Can you explain this architecture of this project the current project? Sir MVC but I don’t want a three letter world right I can see that it’s a very big project
4:35
out here can you try to elaborate a little bit more Model View Controller you are going for architect interview you are a senior if you are going to go and answer such kind of one liner like MVC three layer and MVVM it’s not going to work remember you are asking for a bigger salary. Your answer should be elegant your answer should show of your knowledge your answer should be a knowledge which shows seniority which shows authority if I were to answer this question
5:13
I would go in such a way what I do over here is that I would actually glide from the 50,000 ft. level to the 30,000 ft. level to the 10,000 ft. level means what first from the 50,000 ft. level I will talk about the different layers I have used in my project. For example I will say that my we had like UI layer which was made in angular or react whatever is your framework you have used second we had MVC layer which is your middle layer then we had the
5:41
SQL server Database and then we had a cloud in case if you are using hosting cloud or in case you have some common layer you want to discuss and so on first talk about the different pieces and the layers in your project after that you can go inside those layers the 30,000 ft. level you can go and see ok inside the ASP.NET I had used MVC. We had the model we had the view we had the controller the view had the look and feel it had the positioning the controller was the binding
6:08
thing which binds the model and the view and the model had the business logic now you are going to
6:13
the next level the 30,000 ft. level then what you can do is that you can more glide down and go to the must be the 10,000 ft. level and talk about the different patterns you have used you can say that ok for connecting to the database we have used a repository patterns to do transactions we have used unit of work or for example. To centralize object creation you have used factory pattern or for example for caching and ETC, you have used singleton pattern you can
6:36
then go to the patterns out there remember that whenever you are discussing your architecture also talk about security if you have used open ID or if you used Oath or open ID connect start from the layers go to the architecture patterns and then talk about the design pattern remember this is an architect interview it’s a senior interview your salary is a higher. End salary your answer should show that credibility let me try to answer this now that I
7:06
have told you the way I will answer it this is how my answer will be remember that my answer cannot be your answer you should have your own answer in your mind because your project is different your architecture is different this is my answer but I will say that my project actually consisted of 4 or 5 layers the first one was the UI layer which had angular then we had the MVC layer the ASP.NET
7:27
layer where my server components were there. And then we had SQL server and also we had lot of common components there was also a common layer then and also we had used MVC pattern we were following ASP.NET we used the basic model view controller pattern where in the model had the business logic the view had the look and feel the controller was binding both of them also we had used different design patterns as well for example repository pattern using
7:57
entity framework I was connecting to SQL Server For a caching and for what do you call for caching and the global objects we have used singleton pattern and also dependency injection and factory pattern also we have used and overall for security we had open ID connect and O auth 2.0 for which I had used a your active directory the point is that your answer should be detailed polished and it should show that elegancy. MVC when we talk about MVC it’s a design pattern,
8:37
is it a design pattern I think it’s a design pattern and what about dependency injection dependency injection I think dependency injection it’s an architecture style what about rest, rest is an architecture pattern what about factory pattern. I think factory factory factory pattern I think is a architecture pattern I think so ok ok we all try to do this isn’t it we all try to guess sometimes, sometimes when we don’t know the
9:11
answer we try to guess the answer isn’t it but remember that when you try to guess the answer what happens is it can build a mistrust with the interviewer and specifically at the senior level this trust is so important this is such an important factor out there because they think that we are hiring a senior. He should not only be technically competent but we can trust him we can trust his solution because he’s going to go and lead a group of people out
9:38
there I would suggest that when you don’t know an answer what you should do is you should try to diplomatically move away saying that I need to look in to it or I will check out what it is and then you can say ok like must be at this moment I am not clear about it I do understand MVC I know that there is a controller view and Model I do understand rest that. Rest is there for network solution where you talk in terms of resources state statefulness statelessness and
10:07
so on what you can do is that you can try to diplomatically move away from it but see that you don’t try to guess answers don’t try to give wrong answers if you try to give wrong answers wrong vocabulary it will build mistrust and that can be very bad the whole interview can go good and there you are with that one mistrust. With that one think the whole interview can collapse let us now go ahead try to get the answer what it is architecture style is
10:36
at the 50,000 ft. level I’m so sorry in between I will be trying to give you some non-technical guidance also non-technical things also don’t feel bad about it definitely this video I want it to be a pure technical video but interview is not just about technical things it is also about non-technical things so sorry to little bit deviate away from the answer.
11:02
First thing if you look at architecture style it is at the 50,000 ft. level while architecture pattern goes little bit down and talks at the structure level and design pattern talks at the solution level at the code level at it talks about a specific context let us try to understand architecture style some examples of architecture style are rest, rest is a architecture style I is a architecture style in case of an architecture style there are just
11:27
guidelines and principle for example we say ok. Rest is an architecture style which defines how network application should work how networking or how two things can communicate with each other in network in that case rest says that it should be take stateless rest says that we should think in terms of resources rest says that we should have uniform interfaces like post get put delete or whatever rest talks about just guidelines and principles.
12:00
That is what is termed as architecture style it just talks about that how your solution should be shaping up it just talks about the principles and guidelines while in case of an architecture pattern it goes at a structure level it goes at least you will see a block diagram out there you can see like MVC is an architecture pattern, MVVM is an architecture pattern, MVP is an architecture pattern layered architecture when you say three layer
12:27
architecture that is again an architecture pattern in case of an architecture pattern. There is going to be a controller we know that there is going to be a view and we know there is going to be a model now this view it is built by using HTML or it is built by using a mobile this model is a class or a function it does not matter this controller is what it does like for example in case of ASP.NET we use the ASP.NET MVC to implement MVC in
12:55
the same way you can use something else to you implement MVC in case of architecture pattern. He does not talk about that how this will be implemented you or how the code would be he does not talk at the code level it just talks at the broader level at the block diagram level it just defines the overall structure that is the architecture pattern design pattern is very very specific it has a very specific context I can even that in step ahead and say that
13:24
in design pattern the code is also very clear for example some examples of design patterns. Are factory pattern your iterator pattern your singleton pattern non-golf means if you look at the non-golf patterns are like repository pattern unit of work CQRS these are some of the patterns in case of a design pattern what I have seen is things are very clear even at the code level things are clear or they are in sync you write either in Java or write either
13:55
in C# even the code also looks very same for example if you look at singleton pattern we say. It should have a private constructor isn’t it should have a static keyword lot of things are clear at the code level and second the context is very why are we implementing singleton pattern because we need some common sharing of data we need a global object why are you implementing factory pattern to do decoupling we want to centralize the object creation why are you
14:21
implementing repository pattern that we can have an abstraction over the data source there is a specific context when it comes to design pattern. Architecture style let us try to revise architecture style just defines the guidelines and principles architecture pattern defines the block level but it does not talk at the code level it is not very specific it is not at a context level while design pattern has a very very specific context almost that what the code
14:51
can be before we move to questions number three. Here’s a small question or I will rather say let us have a small discussion on these three things these three things that is dependency injection dependency inversion and inversion of control what do you think these three things are design pattern, architecture pattern or architecture style please note dependency injection and dependency inversion are two different things they are not same go ahead comment below let us
15:24
collaborate and let us discuss that these three things are architecture pattern, architecture style or design pattern. No architecture interview is complete without questions on design pattern let us start with some basic questions of design pattern and let us then go towards the advanced once let us first start with what are design pattern design pattern are time tested solutions for recurring architecture problems
15:50
remember the design pattern does not solve all the problems of software development it’s only around the architecture they solve the problem and they are time tested for recurring problems. For recurring issues in case of design pattern you have a problem and then you have a solution for it whenever you are answering these questions as a senior please try to use vocabularies which are in the industry for example you can see these words like time tested recurring these are some of
16:19
the vocabularies where the interviewer is looking from a senior time tasted solution from recurring architecture problems and when answering this question please try to know please try to. Qualify it with some examples of design pattern for example you can see over here something like this it is a time tested solution for recurring architecture problems some of the examples are for example adapter pattern if we have incompatible interfaces adapter
16:45
pattern solves that for example if you want to go and iterate over an object sequentially without exposing the underline representation underline representation means internally you don’t want to know it’s a dictionary internally you don’t want to know it’s a. List or an array iterator pattern what it does is it actually helps to you browse sequentially without exposing the underline representation template pattern you have a problem where you
17:14
have a fixed skeleton skeleton of algorithm in a parent class and you want that for specific steps the subclass should override it template pattern repository pattern it helps you to actually. Provides a separation between the application logic and data access code it helps you to abstract and centralize the data aces logic in an application and by doing you can make the code more modular more maintainable and testable make sure when you are qualify when
17:47
you are answering this question qualify it with some examples and there are there important things to remember whenever you are giving these examples first thing. Point number one just try to avoid singleton pattern I am not saying that don’t say singleton pattern but what if you want to stand out in the crowd then don’t do use singleton pattern as an example because every developer actually uses this example in interviews second do not
18:17
just stick to GOF pattern do not just stick to gang of patterns try to give some non -gof examples like repository pattern, unit of work, CQRS, these are some of the non-GOF patterns. Why because if you see the new era of micro services and DDD there are many new design patterns which have come in and any interviewer would like to hear about it and most important whatever patterns you mention out here you should be very confident about it
18:51
this part of the answer it depends on you as a candidate that what you want to answer if you think no like more than adapter pattern. I understand factory pattern then replace this answering this question holistically this is how I will answer it design patterns are time tested solutions for recurring architecture problems and some of the examples are for example if you have incompatible interfaces then adapter pattern comes to help for example you want to
19:19
loop through a collection without knowing what is the type of collection internally iterator pattern if you want to go and abstract and centralize the data access logic at one place repository pattern. What the different types are of deign patterns primary there are three categories of design patterns one is a creational category second one is behavioral category and third one is a structural category creational category actually talks about issues around object creation for
19:52
example if you say you want to create a single instance of an object then you have singleton pattern let us say you have an object and you want to create a copy of it. You want to create a clone of it prototype pattern remember that I have just given some examples out here there are many more patterns in creational but I have for this question I have just given two three examples which I am very comfortable talking second one is behavioural in case of behavioural the focus
20:18
is around communication between objects for example let us say that you have too many objects who are talking with each other and because of that things can become chatty. You have mediator it simplifies the communication between the classes let us that you have an object and you want to capture the internal state of the object. Like old values and new values memento let us say that you want to create like a workflow one object doing some task and then passing to the
20:47
other object and then the other object chain of objects then you have chain of responsibility this is around the what you call architecture issues or design issues around objects communication. Then we have structural which talks about the object composition and structure more more related around the structure let us say you have to two classes and they have incompatible interfaces adapter let us say want to create a composite object means you have how do you say it let us say
21:17
that you have a circle inside the circle you have a rectangle inside the rectangle you have again have a circle then you have a composite object decorator you want to add Behavioural dynamically these are the three different types of. Categories now please note that these categories have come from gang of 4 really if you ask me personally in today’s world these categories don’t actually as a architect it does not mind to me too much because
21:47
new design patterns have been introduced like repository pattern CQRS aggregate root and some of these pattern it is very difficult to put into one of these classes classifications frankly
22:00
But yes from the interview perspective remember this three and whenever you are answering whenever you answering give examples around it because once you give examples that send a message to the interviewer saying that yes this guy understands design pattern and whatever examples you give you should be very sure of those examples just revising there are three different categories of design pattern creational which talks about the object creation
22:26
issues which solves problem around the object creation issues like prototype and singleton Behavioural which talks about the communication between objects like chain of responsibilities memento and mediator structural which talks about the object composition and the structural issues like mismatching of interfaces adapter pattern composite objects composite pattern if you want to have composed objects and if you want to add responsibilities dynamically decorator
23:02
Which design pattern have you used in your project or I will rather say that what are the different design patterns you are aware of singleton only singleton any other patterns singleton pattern yeah that is right but see at the end of the day when you talk about a project a project does not work on one design pattern it needs multiple design patterns. You can add something more single man singleton ok this happens with most of the developers most
23:39
of the developers love this singleton pattern I don’t know there are so many patterns out there this pattern for some reason is talked or I will say over talked in interviews let me give you four suggestions of how to answer this question point number one do not answer singleton remember it’s a senior interview you stand outside the crowd stand away from the crowd. And you should look these things that’s the first point the second point is that I would suggest
24:04
that do not talk about golf patterns talk about non-golf patterns also like repository and unit of work and aggregate route event sourcing there are so many other design pattern which have currently emerged keep those also in mind third point what I would like to say out here is that only talk about those patterns which you are confident and how you can do that if you see any project. Whatever you have worked I am sure that you must have used at least 10, 15 patterns unknowingly,
24:36
unknowingly go and have a closer look at your projects see those patterns understand it and talk about those only in the interview what happens with that you not only talk confidently but you also talk naturally that word naturally is very important and when you start speaking naturally in an interview specifically in an architect interview believe me interviewer loves it An architect interview a senior level interview should not be just Q&A it should go into a
25:04
conversation mode in a conversation mode where both the interviewer as well as the interview interviewer both of them learn something that’s the third point and the fourth point I am going to go and cover 10 patterns out here which I feel that people use in their projects but remember that my patterns cannot be your patterns please see that see your project closely and come out with some of those patterns which you are confident on.
25:30
But let us here now talk about 10 patterns at least you know which I will now definitely in the interview you don’t have so much time to talk about 10 patterns but I will give 10 patterns must be you can remember three four from it confidently and that would help you to answer this question the first pattern which comes to my mind is repository pattern why repository pattern because if you see most of the applications what we see around are
25:55
CRUD applications that means interacting with database insert update and delete and so on.
26:02
This repository pattern what it does is it actually acts like an abstract layer between the model and the data access technology you have a model which has the business logic and then you have data access technology like entity framework or ADO.NET or whatever this repository pattern can stand in between and act like a mediator and in this repository pattern you can put you can centralize I will say common code of data access. And with that it will help you to make it more
26:33
maintainable more testable more modular and so on first pattern which comes to my mind is repository pattern the second pattern which goes hands in glove with repository pattern is unit of work repository pattern acts like a mediator and unit of work actually helps you to manage transactions between the repository pattern object for example let us say you have customer and customer has addresses you would like to say that ok if the customer if all the addresses
27:01
Gets inserted the customer will get inserted in other words if there is a failure in inserting of the customer or the address everything has to be revert back either all the customer all the address get persisted or everything rolls back for such kind of a thing unit of work is used inside repository pattern actually that is there the third pattern which comes to my mind is iterator pattern we all do for each loop iterator pattern what it does it is helps you to iterate over an
27:31
Aggregate object sequentially without exposing the underlying representation at the back end you don’t know you are iterating over a list, you are iterating over a collection, you are iterating over a dictionary that’s what iterator pattern does and one very important point when you’re discussing about iterator pattern please note in .NET and also in Java I enumerator and I enumerable is already there to implement iterator pattern
28:00
We don’t really have to go ahead and write a wrapper class above it in the interview if you can just say that you are using I enumerable and I enumerator that itself is a implementation of an iterator pattern the fourth pattern which comes to my mind is factory pattern creational pattern wherein the object creation is centralized and the instance of the creation goes to the derived classes this is again the fourth one the fifth one which comes to my mind is specifically
28:29
when you have incompatible interfaces. Adapter pattern specially around third party component you have two classes and both the classes have incompatible interfaces and if you want to make them compatible that’s where adapter pattern comes into picture specifically in case of a third party a third party components those methods you can’t change of the third party and then you have your own classes internally and the methods are not compatible with each
28:53
other then you put an adapter in between and you make the interfaces compatible. The sixth one is decorator pattern you have an object and you want to add a behaviour dynamically for example let us say you have an validator object and it is doing just required check and you want to say ok now I want to go and do a null check also or also I want to go and do a range number check you can add a behaviour and remove a behaviour dynamically the seventh one is
29:23
command pattern with CQRS is coming into picture we will talk about CQRS in the later videos. If you look at CQRS this command pattern the base of CQRS is command pattern specifically if you are doing MVVM also there also you will see I command whenever you see I command it is one of the sings saying that implement command pattern in command pattern what happens is you treat a command as a class or object for example till now you must be thinking that ok what can be an object an
29:53
object can be a person it can be a car it can be a printer it can be a customer it can be a supplier But if I say that command can be create, command can be update, command can be fire, command can be throw a bomb at that time you treat for such kind of scenario a command as a class this is the command pattern you will find heavy use in CQRS faced pattern again I find this very useful for example at the back end you have lot of things let’s say you are doing accounting
30:30
In case of an accounting you do a debit you do a credit you do a voucher of posting but you want to represent this system in a very simplified way through a web API or must be through a rest service or through a WCF or something that’s where facade pattern comes into use it represents and subsystem in a simplified way ninth one is composite composite means where you have object composed of each other for example let us say you have a square a square has a circle
31:00
A circle has a square or another example where I use composite pattern is menu a menu has a submenu a submenu again has a menu a composite pattern then tenth which is very much I feel I have been using a lot is the template pattern or template method in template method what happens is the steps are fixed like extraction transformation and loading the steps are fixed but the individual steps can be overridden in the child classes the steps of the algorithms are fixed
31:30
But the subclass can go and override the individual algorithm of the steps there are the 10 patterns which I can think about and remember I have said my patterns cannot be your patterns I will be having two three videos separate videos dedicated to each one of these pattern but for now in this first video I really don’t want to go in depth into each one of these patterns because we have to see the code we have to understand it see until
32:00
You don’t see the code you won’t be able to speak in the interview please understand it either you can go and you can see my design pattern videos there is a design pattern lengthy, lengthy lecture of design pattern with a project you can see that if not what I will be doing is in a second lecture of the third chapter three four chapters I will dedicate to these 10 patterns at least that you are able to answer in a more confident way but for now you can choose
32:30
Your three or four remember as I have said if you just look at your project I am very sure you must be using repository pattern I am very sure you must be doing a for each loop iterator pattern is almost there I am very very sure that you must be exposing a web API where you don’t know you have used facade but you are exposing the subsystem in a simplified way I am sure that you must be creating a menu and submenu where something is contained inside each other
33:01
Go and see your project I am sure that you will find many of these patterns you have implemented unknowingly and if you speak that in that interview also it will send a different level of confidence now before I move to question number six I would like to ask all our developer friends out here for this question which is flashed on the screen for this question which is flashed on the screen how many how many how many of you guys
33:38
have answered singleton pattern I can see the smile on your face if you are smiling out there yes I answer all the singleton pattern then please put a smiley down below in the YouTube comments but here it is quickly about singleton pattern not only know this pattern is favourite between the in between the candidates while answering the question but even the interviewers love it With all respect for this pattern the next coming up four or five questions are on singleton pattern
34:05
let us get start it singleton pattern helps to create a single instance of an object if you want to create a single instance and if you want that single instance to be shared across your application while it is running singleton pattern is useful now there are some use cases of singleton pattern first one is which I have been suing in my project is for cashing purpose For example now let us say you have country master you have state masters you have currency
34:39
masters then what you can do is that you can create one single object of it one single collection of it and use the same collection again and again and you don’t have to make a trip to SQL server or to your RDBMS again and again second use of singleton pattern which I have seen is for common data sharing for example you have a common theme which you want to share When your application is running you have some configuration data which you want to
35:05
share when the application is running then singleton pattern again is useful when such kind of question comes up it is very very essential to show your knowledge of to show your authority of don’t just answer in one liner private constructor and static keyword try to stand out from the crowd here it is at least I feel there are five or six important steps which you should be mentioning when you are
35:36
talking about singleton pattern here it is step one the first thing is I think we should have one separate rapper class for example in this case we are trying to load the country master for cashing you can see there is a list of countries you can have list of states you can have list of currencies whatever are those singleton objects they will be wrapped inside a separate Class called as singleton that is the first thing and second the access to these objects
36:06
will be provided from a instance within that mean that this singleton class instance will be created inside the class itself this is called as a whole part relationship you can see here this is a singleton class and the instance is created internally any access to the countries collection etc. will happen through the instance that’s the first thing I think we which you should talk about That there should be a separate singleton class the second one is when you talk about singleton
36:38
multiple threads can access it can be accessed from multiple places definitely there should be a threads safety for threads safety you can see we have created a lock object and every time we load an instance or every time we go ahead and load an asset like a countries or state whatever it is we always go and lock that object we can see this is the second thing which should come out That threads safety should be taken into account by using lock by using mute x whatever way you
37:06
think is good the third one is this singleton class nobody should be able to create an instance of it that’s why you can see that there is a private constructor inside it this is third thing the fourth thing is that should be lazy loading, lazy loading or eager loading you should have control over the loading you can see here whenever I make a call to the get countries The first check I do is that is the countries collection null if the countries collection in
37:35
null then only go and load it or else don’t go and load it again and again this is again one more important thing out here lazy loading the last one which I feel is very important and this is where your knowledge will show off is that should be a double null check why a double null check for example you can see out here we are using the lock keyword if somebody makes a call to the get countries we don’t want to lock this Again and again and again remember that lock
38:04
actually needs a lot of resources to acquire a lock or to release a lock you need a lot of resources out here this lock keyword should not be executed unnecessarily we can see here there is a one more null check here saying that if the countries is null then only go and lock it or else you don’t have to go inside this if condition I think at least when you are speaking in the interview three or four things Whole part relationship you are going through
38:33
a root class second one you should take care of multi-threading thread safety locking you should have a provision of doing lazy loading and also if you can talk about performance that is great when you answer in such a way in depth this is where the interviewer connects to you let us go ahead and run this program as well because my goal here is to not only just make you pass in the interview but also to give you knowledge And definitely both of them going to hand in
39:03
hand when you see a demo when you understand a concept you are in a better position to argue in the interview you are in a better position to handle the cross questions first thing we should not be able to create the object of the singleton class because the constructor is private you can see that I am getting an error out here that it is inaccessible due to the protection level the second thing you can see here in line number 12 here is that we are using that singleton class
39:30
Which is now the root to first get access of the instance once we have access of the single instance to that single instance now we can go ahead and say ok get me countries get me the hit counter or get me states get me currency and so on let us go ahead and run this and let us see how it looks like first thing is you will get the instance you will get the access of the instance the root instance the single instance and then you can go ahead and
40:00
get the access of the resources And second thing whenever you are getting access of the instance remember the pattern which is followed out here throughout is the first thing everything is lazy loaded until you don’t call the Instance the instance the singleton is not initialized see here first thing we can see until in this first call now the instance is getting initialized Second you can see we have taken care of threading all that is again there also this first null check
40:34
is for the performance why didn’t it go inside looks like the instance was already created how was it created why was the instance created let me rerun the program again I don’t know why it did not go inside that if condition let me I think this is exe was running out here let us go ahead and run this again strange There it is it goes inside it and if the instance is null there that’s it I think the instance was already running and that’s why that singleton down
41:12
object was created first thing it goes and locks the object checks this is the first time we are doing it lazy loading and gives you back the instance once you have the instance with you now you can go and say ok get me countries get me states and the best part here is again the same kind of structure same kind of pattern here First go ahead and check if the countries is loaded if it is null then only go and lock the object and then yes again and again check you
41:38
if the countries is null remember this double check is because in between somebody can call get countries that’s why double check is there and then again initialize the countries now this is lazy loading and there it is if I go and again say get countries you can see the countries collection is out here if I again go and see get countries out here
42:01
It will not go inside this thing and it will not do any locking basically three things when you are explaining singleton pattern the first one is that there should be a root remember that should be an a whole part relationship that should be a root object through which we access things second we should take care of making sure that only one instance is created by the private constructor we should make sure that we are using a static keyword out here
42:30
For the singleton we should take care of the locking we should take care of the lazy loading one of the things the interviewer would definitely like to know do you understand the difference between static and singleton the two questions what you see on the screen at this moment is targeted around the same let us try to understand the question first the question is that we have this Root class out here singleton if I go and
43:03
if I put a static out here then I don’t need this private constructor I don’t need this private constructor out here I can get rid of it because a singleton class you don’t need to create it it will always have a single instance there is nit way anybody can go and create an instance in the first call itself the singleton object will be initialized the question is that If you just put a static keyword out here remove the private make this list as static
43:35
will that not work why we have to do this private constructor and the second question says that for example we want a single instance of the countries isn’t it can’t we just go and make it static like this just make one static somewhere on your program globally and just use it that is also singleton because singleton what does it say singleton says that a single instance of an object has to be created just by putting static everything should work isn’t it
44:00
Let us try to answer this question the first thing which will come to my mind or the first thing which I think which I would like to comment here is that static is keyword it is a programming keyword while singleton is a pattern it’s a design pattern with a certain structure of code as soon as you say design pattern there are certain code around it like the private the singleton the constructor Putting the lock object making sure that
44:32
only one instance is created performances it is not just one keyword the first difference which I want to point out here is that static is keyword it’s a programming keyword while singleton is a design pattern the second thing is that static definitely the complete singleton uses static internally first point static is the base on which singleton is created is established But singleton has many other things it has thread safety a static keyword does
45:05
not provide that by default you want to make sure that a single instance is created you want to do lazy loading you want to make sure there is a lock performance if you really ask me singleton pattern in my mind what goes is singleton pattern is equal to yes we need the static keyword But at the same time we should have thread safety we should have lazy loading we should have performance there are many other things which singleton pattern brings into picture
45:45
static keyword is just one single part of it the other point which I want to point out here is that if I make this class as static I lose many objected oriented programming features For example if I make this class a static I cannot implement a interface for example if I want to implement interface I will get an error I cannot do inheritance also if I try to inherit this again does not work for example if you see cannot implement interfaces second base
46:21
class must come before interfaces ok if I put here inheritance implementation of interfaces all this Actually then we lose it you can see here now static class cannot derive from a singleton parent class singleton static classes cannot implement interfaces again these all things lose I think there are three prime things which you can specify when this question Is when these two questions are asked first we lose almost all the objected oriented programming features
46:55
like implementing a interface inheritance from a class the second important thing is When you talk about singleton pattern we also need to make sure it is thread safe we also need to make sure it is lazy loaded we also need to make sure it is performance oriented and many other things which at this moment I can’t which at this moment is out of the scope of the discussion singleton is pattern while static is a keyword these three things
47:22
I will talk about objected oriented programming concepts thread safety lazy loading performance and the third one which is a punch line That static is keyword while singleton is a design pattern this question is put forward to check that do understand the importance of thread safety that’s what this question is trying to test as architect do you understand what can be the implication that if you have a multi-threaded environment
48:02
And if the both of threads are trying to access the same object at the same time what can be the issue let us try to understand in case of a singleton pattern what is the issue multi-threaded means what multi-threaded means that multiple threads can execute that code and C# is multi-threaded in this get countries you can have a situation wherein one thread is executing this line of code which is initializing the countries at the same time another
48:29
Thread is executing this line of code where he’s trying to get the countries think about it that you have let’s say two threads have entered into get countries one thread out here let’s say assume that this is T1 it is initializing the countries in your database you have 100 countries assume but let us say that he has loaded only five he has loaded only five and he’s still loading let us say this process is going on at the same time another thread comes up
49:00
And this thread definitely because the five countries are loaded it sees this is not null and starts executing this line of code it does not go into that if condition it is very much possible that when he returns back he will return back with five countries but in the database you have 100 countries what happens is if your code is thread unsafe you can have undesirable results Buggy results what do you do you go ahead and you use a lock keyword when you say lock out
49:36
here whatever objects are participating inside this lock thing out here whatever objects are participating inside this they get locked in other words until this initialized countries does not finish until the countries object is not fully loaded or until it does not cross this scope out here All the other threads will go in a blocking mode what this lock does the locks is that only one thread can enter at a time here first thing inside this lock and
50:13
when that object is locked out there the other lines of the code will be waiting until this countries object is filled that’s why in case of a singleton pattern this is very essential that we don’t get any undesirable results When you get these kind of questions it means that the person whom you are taking with is a real architect he has really grown from the scratch he understands things now you have to be more alert isn’t it here it is what is this double null check
50:56
first thing us start with the internal check This check out here is there for lazy loading, lazy loading means that if the country is null then only load it and don’t keep loading it again and again that is what this first check now the second top check out here this is for performance reason see if the countries is null then only you want to go ahead and put a lock or else what will happen is if you put a lock Then what happens is this complete scope becomes
51:33
synchronous it becomes single threaded if it becomes single threaded then your performance decreases it does not make sense that if the countries is not null you are entering into the lock keyword isn’t it that’s why this first one here is for performance check this is to make sure that the lock scope does not execute unnecessarily and this internal one is for lazy loading Gang of four design pattern surfaced out publicly in the year 1994 it was released
52:16
via a book which was written by the four Devs in those times the examples were by using C++ most of the examples were using C++ now if you look 30 years ahead evolving programming languages like C# and Java and Python And many of those languages what they have done is they have embraced many of the gang of four design pattern in the programming languages itself for example let’s say if you want to implement iterator pattern then you have I
52:45
enumerator and I enumerable in C# and I am sure that you have such kind of interfaces in Java as well these two questions out here is try to test you as an architect that can we go ahead and can we avoid this This double id check this lock keyword because remember that these things we are going to go and repeat for every resource we share globally for example now this is get countries let us say in the same way we have get states we have
53:14
get currency every time we are going to go and have those resources we have to write this line of code is there something in the programming language itself in C# which we can use which we can implement and make this code easy. In case of C# we have something called as a lazy keyword this lazy keyword not only helps you to load lazily but at the same time it will do the double null check also for the performance if you see out here for
53:44
example look at these get countries you can see it is just one single line of code and if you remember our old singleton code out here you can see there are so many lines of code out here that has now literally become one line of code If you see out here now you will say that ok where it does get loaded what you have to do is that you have to go ahead somewhere in the constructor or somewhere you define the variable you have to define that this countries collection
54:14
how will it get loaded for example I am seeing out here this countries collection will get loaded by this initialized countries this initialized countries is a method which actually goes and gives back a list what will happen now you just define out here that how this will get loaded And this will be called when you call the dot value until you don’t call dot value this initialized countries does not fire for example if I go and if I run this look at this let us
54:40
go and see now if you see here he is doing a get countries remember this is the code out here I am actually calling the get countries if you go and if you move your mouse first thing you will find that the value is null look at that the value is null but as soon as you make a call to the value it will go and it will fire initialized Countries you can see lazy loading is now getting implemented this lazy loading gets fired it gives him the countries collection
55:09
and if you now see go and see the countries value you will see now the count is three and we have three countries inside it by using the lazy keyword the singleton pattern code Can be minimized a lot and I think when you are in if you are using the new C# features now I think this is the way it should go ahead and you should try to avoid writing such kind of lengthy ok first thing congratulations, congratulations, congratulations to you congratulations
55:58
to me why because we have completed 1 hour of this video almost 1 hour has been completed now before I move to the next questions I want to talk about a very serious topic out here it’s a serious topic but hilarious situation that kind of situation it is what happens we are recruited as architects you enter the company and you think that your work profile is that you should be giving a technical road map by creating an hid document or by creating a low
56:26
level design document your work profile is that if Anywhere technically the developer has is stuck or the team is stuck you go out there and you try to solve the situations probably as an architect you participate in complex POC as well nut then what happens is you are taken as architect and then you are given a work profile of a team lead in how many of you guys are taken as architects and
56:52
suddenly you are allocated work as a team lead if that has happened with please put down in the comments below how did you handle this situation What did you do and how did you overcome the situation or did you just resign and go away let me know that in the comments below that many other people will also benefit now the next question the next series of question is on GUI architecture MVVC, MVP and MVVM let us get start it if you are getting this question that means
57:23
that the interviewer who is interviewing you is a veteran he understands software architecture He has read lot of literature on architecture because I have rarely seen only I have seen good architecture using this word GUI architecture pattern what exactly GUI architecture pattern
57:41
if you look at your code you have a view and you have components at the back when I say components means I am talking about model I am talking about business logic I am talking about lot of other things what GUI architecture pattern does it it actually It refers to How you can organize this interaction code this interaction code between the view and the components structurally structurally means do you want to go and move this code into a
58:15
controller then you have the MVC pattern do you want to go and move that interaction code into a presenter then you have a model view presenter do you want to move that interaction code into a model view view model then you have a MVVM pattern GUI architecture pattern refers to how to organize structurally the interaction between the user the view and the components in a software application
58:40
also this helps you to maintain clear separation of concerns if you look at MVC in MVC what do we have we have a controller, we have a view, we have a model now you have separation of concerns out here saying that the view will do the look and feel the model will have the business logic And the controller will do all the interaction between the view and the model in the same way it goes for presenter MVP and the same way it goes for MVVM remember whenever you are answering this
59:12
question try to take out this word separation of concerns you can see now here is a typical code which a developer can write inside a view you can see that this is a simple button click event out here in this button click event you can see that The developer is doing a lot of things first is interacting with the model and he is incrementing the value of the counter here the model is a counter it’s a simple counter which we are incrementing second the developer
59:40
can do things like reading from the model and updating the UI now this can be as simple as taking the value and updating the label or taking the value and updating the text box or it can be as complex as binding a grid he can also write some UI manipulation logic like enabling and disabling And some aesthetics like colour Etc. if the value is greater than 10 than go and make the colour red you can see this UI code over here is quite complex the GUI architecture
1:00:12
pattern what it does is it says that let us go and move this code into a controller and this controller will decide once the hit comes to the controller will decide what to do Etc. and then the view will have the look and feel this This colour red Etc. will go inside this view
1:00:35
this calling of this can go over here GUI architecture pattern actually helps you to organize the code behind the UI interaction code into separate layers whenever you are answering questions which are around. GUI architecture patterns like MVC, MVP, MVVM one of the things which you would like to emphasize is that all of this architecture pattern implement a very important design principle which is called as separation of concerns or we can say
1:01:16
SOC what is separation of concern, separation of concern is a design pattern principle which advocates which promotes that we should break our software system into distinct section And each section will be addressing a separate concern or separate aspect of the software functionality for example when you say MVC you will say in the MVC the view is for look and feel it is for positioning the model will do the work of business logic and then you have controller
1:01:50
which will do the connection between the view and the model it will act like a mediator it will take the user input when you are putting The concerns or the logic into separate, separate buckets out here you get a much better organized code and much better understandable code whenever you’re doing a hand overwrite these kind of codes are much easier to understand remember that whenever you are defining the interviews or whenever you’re defining MVC, MVP, MVVM one of the
1:02:23
words you should emphasize is that or one of the benefit you should emphasize is that separation of Concerns now this question is one of the most asked question when it comes to architecture interviews and when you get questions around explain MVC or MVP or MVVM any architecture pattern what you can do is that you can divide your answer into three pieces see remember at the end of the day everyone knows MVC everyone knows MVP the most important thing is that how are you
1:02:58
Presenting the answer during the interview I would suggest that divide your answer into three sections when somebody asks you architecture explanation first one is talk about the different layers of that architecture second one is every layer what it does explain that and third one is if you can try to make understand the flow of that architecture for example in MVC the way I will answer this question is that the MVC architecture is divided into three sections one is the
1:03:28
controller one is the model another is the view In the controller what happens is we take the user inputs we load the model and we invoke the view and so on controller is the front facing to the user input it is the first thing which is triggered in MVC after that the model has the business logic it has the business logic it has a calculation logic and so on and the view is for look and feel for positioning and alignment in the second section try to talk about
1:03:59
The concerns what every section has and finally then talk about the flow if you look at the flow of MVC is the first thing which is hit is the is the controller, controller goes and takes the request it takes the user request and then this user request is then depending on the user request it goes and loads the appropriate model you can see it loads the appropriate model once the model is loaded it will take that model and invoke the appropriate
1:04:30
View and the view will punch the model in the UI it will say that ok stick this data here stick that data in the div tag bind that grid and then finally the response comes out remember that in case of MVC the first thing which hit is the controller, controller goes and loads the model that model is passed to the view controller is like a mediator it is like a traffic police between this three things if I am supposed to answer
1:04:57
this question this is how it will go in MVC. What we do is that we divide our project into three layers controller view and model the controller is which gets invoked first it takes the user inputs it loads the model it invokes the view and so on model is where we have the business logic view is where we have the look and feel and positioning and the flow is that the first it comes to the controller, controller loads the model and then model is passed to the view
1:05:22
and the view is then displayed on the browser or on the UI let us go and see a demo you will say shiv why do we have to see the demo Well by seeing the demo what happens is that fundamental gets impinged in your mind and the most important thing is that when you are getting cross during the interview a demo really helps you to give a good picture to him seeing a practical definitely helps out and remember that my goal here is not to just
1:05:55
make you pass some architecture interview or something my goal here is dual purpose I also want to increase your knowledge I want to see that you understand that fundamental well here it is it’s a very-very simple UI and the same UI I will the same project I will be using fro MVP and MVVM ahead there’s a simple button out here if I click on increment it goes and it updates a counter the counter is the model I have tried to keep it very simple out here you can see here the
1:06:24
first hit will go to the controller when I click on this increment you can see the first hit goes to the controller this is the controller out here At this moment I am using ASP.NET MVC but for other MVC architecture also this is quite valid you can see the first thing is the operation is done on the model remember that diagram which I had flashed the first the operation happens on the model for example here you would load the data you will make a call to the repository or
1:06:49
whatever at this moment I am just incrementing the counter and then this value then this object this model is passed to the view you can see now And what happens inside the view inside the view this model this is the model out here at this moment this model just has a value the counter is one it takes that value and sticks it to the UI at this moment the scenario is very simple but think about it if you have a grid if you have a div tag then accordingly this thing
1:07:23
can become more complex but if you look at the view the what the view does is the view actually looks at the feel it looks at the UI controls It looks at the positioning and so on but it does not get into handling the user input and then once this view is punched in you can go and you can see the output very quickly this is what that diagram was you can see the diagram here at the right hand
1:07:53
side just to revise that first hit the controller, controller loads the model it takes the model and Gives it to the UI the UI punches that model or sticks the model data at appropriate places and then you get the response for implementing MVC you need to have some kind of an automation for example in Microsoft we use the ASP.NET MVC template by using the ASP.NET MVC template it becomes quite easy to write the MVC code you can see here in case of ASP.NET MVC they
1:08:31
have separate folders of controller View and models and developers can go and write code accordingly again this is an architecture level question out here explain the MVP architecture and remember as I have said in the previous video always try to answer this question in three sections First one talking about what are those sections second one talking about the responsibility of each section and third one talking about
1:09:08
the flow in MVP architecture what happens is the project is divided into three pieces out here one is a presenter second is a view and third one is a model what does the view does here the view does exactly what was happening in MVC it has user controls it handles the look and feel it looks at positioning it looks at alignment But here the view is completely dependent on the presenter what the view does is when it has any user interaction anything happens with the view
1:09:40
it just goes and calls the presenter and says the presenter that tell me what to do the presenter does all the hard work the presenter is like a mediator between the view and model what does the presenter do presenter takes the input from the view loads the model and updates the view accordingly you can think about presenter Here does most of the work and model is having the business logic how is the flow out here the flow goes like this the first hit comes to the view
1:10:10
remember in case of MVC if you are remember the first hit was coming to the controller the first hit was coming to the controller he was loading the model and passing to the view but here it is very different the first hit comes to the view and what the view does is he passes a reference to the presenter and says to the presenter saying that you have to tell me what to do I am completely dependent on you once he passes the reference after that whenever view makes a
1:10:36
call or whenever the user makes a call like a button click or a grid click or whatever
1:10:43
that event the view passes to the presenter, presenter talks with the model he goes and takes the model and updates the UI and then the response comes back that means in the view is completely dependent on the presenter out here This view over here is not aware at all what is the model because he is going through the presenter he has no idea of the model as such let us go ahead and see the code out here because once we see the code we can understand
1:11:14
it better let us try to demonstrate the same by using a code here is a code base for MVP now remember that to demonstrate MVP I am using win form out here because MVP is more suitable for old technologies like Win form or Java applets or ASP.NET Web-forms ASPX code behind at that time MPPP was used a lot you can see out here this is a Win-form again what I have done is I have just kept it very simple this is the counter model out here
1:11:44
and this counter model will be incremented I have just kept a very simple model at the back if you look at without MVP what happens is the UI takes up all the load he has to go and update the model he has to take the value of the model and update the UI and depending on the value If he wants to go and update the look and feel of UI that also all he has to do but if you are using MVP that means if you are having a presenter then things are different in case of
1:12:13
a presenter what happens is the first thing is if you look at the code with MVP in case of with MVP if you see he just goes and passes if you call increment out here he does not do anything he says ok this is not my job what I will do id I will just go and pass everything To the presenter and presenter will update me with what to do with the UI if you see out here over here the label black colour or black colour and the label value he was updating
1:12:42
it but look at it with MVP he is just listening he is saying that ok the MVP will tell me what is the colour the MVP will tell me what is the value you can think about in case of MVP the view Is like a is completely dependent on the presenter that’s why a lot of time we say that this is a passive view a passive view means the view is not doing anything it only has the user controls out here but rest of all the things is done by the presenter let me go and run this if I go and run
1:13:16
this the first thing we can see what happens is he this is the from out here he is actually going and calling the presenter the first thing what he does is he submits himself completely to the presenter you can see the current instance of the view and Completely passing it to the presenter out here and the presenter says ok fine he will get reference of the view and he will keep this reference with him this is the first thing which happens after that when i go and say
1:13:45
now go ahead and increment the counter now what he does is he says you want to increment the counter I am going to go and call the presenter it goes to the presenter and what does the presenter do the presenter says ok let me go and first increment the model After that he says now I have to go and tell the UI what is the current value you can see he is calling the show value out here if you see the show value this is the show value he
1:14:13
goes and he makes a call back through the view remember he has a view reference this underscore view is a view reference please note which has been passed previously from here he makes a call back to the view and says ok this is the value and view only goes and takes the value And updates it to the text box to the label second again like when it comes to updating the colour you can see again he says ok for red colour what we have to do we have to first check
1:14:44
in it is greater than 10 if it is not greater than 10 he is not doing it now if you see out here let us go and increment it greater than 10 let me go and remove all this debug points
1:15:04
As soon as it says 4, 5, 6, 7, 8, 9 and 10 it is about 10 now and we have to apply the red colour again what he does he goes back here and he says call back the view and say the colour is red and what he does he is just listening he says ok what is the colour red he goes and updates it to the red colour and there it is red in case of model view presenter the view Submits himself to the presenter you can think about presenter is like a guru and the view is
1:15:37
like a student of the guru and he says ok you tell me what to do I have submitted myself to you that’s what the model view presenter is and remember that in case of a model view presenter the first hit comes to the view and the view whenever you make a call he will go and call the presenter and the presenter will go and Make a call back via the reference this reference is out here now one more question which comes out here is that what is the
1:16:20
importance of the interface in MVP if you see here I did not discuss about this is a interface here called as I counter view You can see this is interface out here this interface represents that what kind of action the view will do for example the view will actually go and call increment or decrement the view we have to go and update the view back with the value of counter value we have to go and change the colour if the value changes these
1:16:49
are all the actions which the view wants and this I counter view is implemented it is implemented over here in the form And when you pass the reference now please hear me very clearly out here and also please go and see this code out when you pass the reference you are passing the reference of the form but the presenter is not having the reference of the form he is having the reference of the I view the I counter view
1:17:19
you can see here I am not saying your from it is a I counter view and through this he makes a call back you can think about this interface sits in between the view and the presenter And the presenter makes a call back via using this interface reference he does not reference directly the form but he reference this interface out here when you pass this over here this gets type casted or I will say because of polymorphism the form is type casted into a interface and via the interface
1:17:57
you can start making call back of apply colour Show value and so on now one more connected question which can come around here is that what exactly is a passive view in case of an MVP this view what you see out here is a passive view why because he is not doing anything he is completely dependent on the presenter that’s why it is called as a passive view because over here what are you doing we are just having the user controls the text box and the labels he is just forwarding
1:18:30
All the request to the presenter and he is listening to the presenter the view is not doing anything all the whatever jugglery or whatever the hard work is done by the presenter out here that’s why in case of MVP lot of people lot of developers also say that this is a passive view architecture where the view is submitting itself to the presenter and as I have given you a example saying that the view is like a student who just Submits himself to the presenter and presenter
1:19:02
updates back with whatever value and logic which the view is needing that’s why sometimes it is called as a passive view as well here I have tried to answer three questions first think what is MVP that we have looked into also one question which can come around MVP which I have addressed out here is that what is the importance of the interface remember I said this interface what you see out here it acts like a mediator between the presenter and
1:19:28
the view pass back the call back messages And the third one why it is called as a passive view because we are submitting the view is submitting himself completely to the presenter and the presenter is doing all the hard work that’s why it is called as a passive view now this MVVM architecture is same like MVP here again we have three sections We have a view we have a model and we have a view model which acts like a bridge between the view and the
1:20:08
model it acts like a mediator between the view and the model again same like MVP the view here takes the care of look and feel for positioning alignment the view model is like a mediator and the model has the business logic now one of the questions over here the interviewer can ask you is that what is the difference the biggest difference between MVVM and MVP is That they have automated binding they have declarative binding and commands in other
1:20:36
words in case of a presenter we have to write code to update the UI or to take the data from the UI over here the technology for example like WPF they support automated binding they have declarative bindings this is absolutely same like MVP but in this case There are automated bindings and here the view is not a passive view means the view does not go and submit himself to view model but rather it talks through these bindings let us go and
1:21:11
see an example of WPF and how this MVVM looks like here is an example of MVVM architecture now please note that one of the important things in the interview which you should highlight is that for MVVM it is very important that the technology should have automated bindings For example angular is one of the technologies which has bindings like NG model and so on WPF has bindings you can see that this is WPF out here it’s again the same project what we had
1:21:41
the same project what I have demonstrated for MVC and MVP when you click on this button the counter will get incremented we can see here over in this button out here this is the XML file if you first go and look at the code behind there is nothing in the code behind actually I mean like you can happily go and remove this button as well over here it is empty There is nothing, nothing out here but if you go and look at the XML file out here
1:22:07
this is the button in this button click this is a command, command is the binding which is binding with the BTN click and the counter view model has the BTN click automatically this will get binded with that for example you have the label and you want to bind the value of that counter object the value we can say binding again and this will get binded with The value is nothing but this one in the same way look at the background colour also I have put up
1:22:38
a background colour out here this background colour is binding with the colour converter what is this colour converter this colour converter is this code out here this code will go and check if the value is greater than 10 it will give out the red brush or the white brush you can see here when it comes to MVVM pattern You need to have some kind of an automation of binding let us go and run this if I go and if I run this and let us go and debug and see how it
1:23:11
looks like that it is you can see first the RGB colour has fired it checks for the value you can see again it is checking for is valid this is valid is for the button click if the button can be enabled or not when I click on the button you can see it first checks for the valid Saying that are there any negative values nothing as such this just a validation check and then
1:23:42
you can see then it calls the increment it increments the value and the then it sends out a event out here saying that the value has changed and then what happens is also the colour gets evaluated saying that ok is this value greater than 20 the value is still one nothing And you can see the value one because of bindings all this code at the back end is firing all the automation is done out here and once the colour increments you can that is shows a red colour
1:24:15
as well when it comes to MVVM architecture we have the view remember here the first hit comes to the view both for MVVM and MVP first hit comes to the view the hit comes to the view The view talks to the view model by automated bindings by command or by event binding or text bindings and then the view model uses the model if you look at the view model is using the model at the back this is the model at the back which is used and it operates on the
1:24:53
model and updates the UI again via the bindings Now this concepts of view model we have discussed in MVVM in MVVM we have said that view model stands between the model and the view but remember that this view model class is also discussed generically also it is used generically also in MVC, MVP or in a three layer architecture or in a three tire architecture definitely the view model which is present in MVVM Does the same thing but it has those
1:25:32
extra bindings in it but in general if the interviewer is asking what is a view model class a view model class is nothing but it is a class which actually encapsulates the model it provides everything that is needed for the view I am trying to emphasize this answer it provides everything that is needed for the view for example now in case our counter thing can see now this is the counter model this counter view model is encapsulating the counter model
1:25:59
And what does a view need the view needs the data of the counter that is present in the model it also needs a background colour depending on the value it is red or green you can see here for this view it is providing the data it is also providing the back colour the background colour it can aso provide the foreground colour it can also provide enabling disabling and lot of other things when we say a view model a view model class provides the data as well as any kind of
1:26:30
Aesthetics or logic which is needed for the view to be driven like colours or styles or enabling disabling loading the grid and so on or even captions it provides both the data as well as the Aesthetics now please note that when you are talking about the view model class in case of the MVVM pattern it is again the same thing you can see out here this is the view model class in the MVVM it is encapsulating The model but it is providing everything that is
1:27:02
needed for the view what does the view need the view needs the value the view needs the increment to increment the value the view needs a colour we can see that there is a colour also which is provided out here by this RGB colour basically this again here it is the same thing but remember that here bindings are also present in case of MVC or in case of MVP or in case of three layer probably we don’t have the bindings But still a simple class can also be termed as
1:27:32
a view model just summarizing view model class is nothing but a class which provides everything that is needed for the view which can be a data which can be Aesthetics which can be enabling disabling or any kind of business logic now this is a little bit of a tricky question how will you make a choice of MVP or MVC or MVVM if you get a project what will you choose
1:28:02
Till my at least to my best experience really choosing these three architecture is not in your hand it is actually dictated mostly by the technology means what for example if the technology is supporting loading of the view first if the technology is supporting loading of the view first means for example when we talking about WPF or Winform these technologies actually load the view first If you are loading the view first then you don’t
1:28:32
have too many options you have to either go with MVP of you have to either go with MVVM now if the technology supports automated binding for example WPF has automated bindings angular has automated bindings then you mostly go with MVVM and if it a legacy technology like Winform or ASP.NET Webform code behind then again there are no bindings out there then you have to actually go with MVP now
1:29:00
If the technology is not loading the view first it is loaded through a controller or so on then you have to go with MVC for example spring or laravel or our ASP.NET MVC all of these technologies don’t load the few first you have to go via the controller frankly which architecture to use it is dictated by the technology and for that technology that architecture always suits
1:29:33
When do you choose what depends on the technology if the technology is supported automated bindings MVVM if the technology does not support automated binding MVP if the technology supports loading of the loading of the view later on through the code then you can go with MVC When this question comes up to say the difference between MVC, MVP and MVVM I would suggest at least talk about two things one
1:30:12
is first talk about the flow how each one of the architectures actually execute and flow and second talk about where to use at least these two things should come what happens in case of MVC in case of MVC the first hit comes to the controller, controller loads the model and the view Over here you have the controller the first hit comes to the controller, controller goes and loads the model and then passes this model to the view but in case of both MVP as well as
1:30:41
MVVM the first hit comes to the view this is the important thing which you should be speaking in case of MVP you have the view and the model and in between stands the presenter in case of MVVM also same the first hit comes to the view and then you have the view model in between And then you have the model now the biggest difference in case of MVP and MVVM is that in case of MVVM remember that we have automated bindings we have bindings in between in case
1:31:13
of MVP what happens this presenter is a class the view submits himself to the presenter lot of time MVP is also termed as passive view why because he submits himself to the presenter and the presenter does everything for him over here we don’t have any kind of automated bindings
1:31:32
First hit comes to the controller then to the model and the view here the first hit comes to the view here also the first hit comes to the view and then the presenter and the model and the view model and the model but here you have automated bindings In this case you don’t have automated bindings and where to use it as I have already said that the technology dictates it for example for spring laravel and the ASP.NET MVC angular it is MVC by default
1:32:00
But in case legacy technologies like Webform and Winform and GWT and VAADIN all these are legacy once over there the first hit comes to the view and there is no automated binding you will go for MVP and then when you have automated bindings like for example WPF and angular and knockout and react and or and all it is MVVM now one very important thing to note out here is you can see that some technologies support both of them you can see For example angular is supporting both of them
1:32:33
what happens in case of angular in angular the first it comes to the component the component goes and loads the model and talks with the view and so on but also there are automated bindings as well you can think about some of the technologies try to take both of the best part they take best part of loading from the controller As well as they have bindings as well which makes them also fall into the category of MVVM third thing this is not important one but
1:33:12
still I think it’s a brownie point the biggest difference which separates MVVM from MVC and MVP is declarative bindings, declarative bindings of automated bindings are present in MVVM but not in MVC and MVP whenever you get this question First explain the flow very important second talk about where to use it and always emphasize the point that it is technology dependent at the end of the day then talk about automated bindings and also try to
1:33:43
highlight that some of the technologies can mix MVC and MVVM like angular like knockout some of the technologies can mix both of them Now some architecture terminologies have a very thin line means they look very similar but they do have a subtle difference what happens is in case of interviews for some of the interviewer it is ok that if this thin line is not understood but for some of the interviewer it is oh like he does not know that one of those terminologies where there
1:34:25
is a very thin like is the difference between layer and tier what is the difference between A three layer and a three tier first thing both of these things actually emphasize one very important point which we have discussed in one of the previous question is separation of concern that means every layer or every entity will do only his thing like when you say three layers that means that your project is divided into three layers the view which is the presentation the business logic
1:34:53
which has the model and other things and the data access layer which talks with the database when you say three layer that means that your project Is organized in logical layers like this this is more of a logical layers internally but it is very much possible that when you’re deploying this into an infrastructure it is possible that you will run the view or you will run the presentation in
1:35:19
a different box you will run the business logic in different box you will run the data access layer and database in a different box and must be the communication between these layers will can happen through HTTP rest or TCPIP or Queues Or some other mechanism which the architect decides when you say three tier it is about how these layers will get deployed into the infrastructure will they get deployed into the same computer or will they get deployed into
1:35:52
different computers if they are getting deployed into different computers then you talk about tier And when you want to just talk about the logical thing saying that how is my project organized then you talk about the word layer three layer means the logical way of your project how the project is organized and three tier means how these layers are later on deployed into the infrastructure and it is very essential to understand that as soon as say three tier complexity increases
1:36:26
because now you have to take into account How will you communicate through the network you have to write extra code for HTTP and or for TCPIP or the Web API calls and so on definitely the time you use the word three tier that means that we are also talking about now communication complexity when you say three layer that means that you have the three layers and must be they can be deployed on the same box three layer is a logical view a logical thought process
1:36:59
When you look at the separation of concerns and three tier is more of the infrastructure deployment or physical representation that brings us to the end of 25 questions we have covered 25 questions and very quickly let us see what we have covered I am flashing it on my screen you can see out here we have covered we started with explain your project architecture and I explained that how you should explain your project architecture we talked about the difference
1:37:35
between architecture style, architecture pattern, design pattern, different types of design pattern and I talked about how you should answer which design pattern have you used in your project and then t took one of the patterns singleton pattern and we saw some question around singleton pattern like why does it need a private constructor static versus singleton thread safety double null check
1:38:00
Lazy keyword and so on and then we deep dived into GUI architecture pattern where I talked about MVC, MVP and MVVM and also talked about passive view and then I discussed about layered architecture and tiered architecture now in my next lesson my plan is to focus on solid principles solid is one of those asked questions at least I feel that personally I don’t think that you become architect by knowing solid but it is one of the asked questions what my plan is in the
1:38:33
next lecture that is lab two my plan is to cover what is solid SRP, OCP LISKOV principle how to fix it interface segregation principle connection between LISKOV and ISP and dependency inversion dependency inversion we discuss about higher level modules and lower level modules dependency inversion benefit and so on at least nice 20-30 questions which is around solid and then Lesson three and four and five must be i will dedicate to design pattern remember in this
1:39:04
lecture I just talked about singleton pattern but definitely at least you should know gang of force and as well as non- gang of force at least five or six pattern to be comfortable I will be covering at least 10 patterns in this two or three lessons No architect interview is complete without DDD and Microservices I not say one or two lectures but must be three or four lectures which I dedicated
1:39:32
to DDD and Microservices and also now a days what is happening is many of the architect interviews are asking scenario based questions those like they are not asking what is what and why they will say here is the scenario and design it we will try to go through some important scenario based questions if possible if you guys can put down on the comments that what kind of scenario based questions have come to you guys that will help me we look into UML document we
1:39:58
look into some questions around technical document And so on and I have more other plans let me know what I should more add in this syllabus now very, very quickly remember I talked about the gift here it is the next lecture that is the solid principle video I am giving it to you but I am giving it to you if you can help me to share this video because I want that many people should see this
1:40:26
video and they should get benefits from it right If you can go to my LinkedIn profile here It is I am flashing my LinkedIn profile if you can go to my LinkedIn profile and if you can share this video the architecture interview question video and if you can send me a mail at questpond@questpond.com I will send you the solid principle video is almost of 1 hour I am sure that you will enjoy it for the rest of the videos as I have said that I am
1:40:53
planning the other videos as well that is design patterns and the DDD and Microservices and so on Those videos you can buy it from Questpond if you buy from Questpond I can give you support as well or else if you say no, no, no, not from Questpond are you on Udemy yes we are on Udemy as well you can buy from us from Udemy as well third you can buy from our YouTube channel itself inside the YouTube channel subscription you can go ahead and you can pay the monthly subscription and
1:41:22
in that the good thing is that you get access to everything for that monthly thing you can go and access these videos from there Now please note that I am still in the process of creating the videos please do ask and questpond@questpond.com are the videos completed that we can tell you till what syllabus we have completed I hope that you enjoyed this video remember just very quickly every year 12th march, 12th march is my birthday 12th
1:41:50
march I record suck kind of videos and put on my channel if you really think that you like this channel and you should get update of this contents please go and hit the like button please go and hit that follow button that next time a video comes in you are aware of it Happy Learning Happy Job Hunting… I hope that you get a Job I hope that seniors out there who are struggling for getting a Job I hope that you land up in a good Job and I
1:42:18
hope that you have a good life and good family Happy Learning Happy Job Hunting Thank you!!!
Here to help you learn
Sign in to keep a private conversation with your course tutor.
Ask me anything about the material…
Sign in to chat