Q16. Can a static class contains non static members like variables, methods and properties?
Q17. Can a normal class contains static members?
Q18. What are the difference between MVC and angular? which to choose which one?
Q17. Can a normal class contains static members?
Q18. What are the difference between MVC and angular? which to choose which one?
Q19. What are the differences between MVC and MVVM?
Q20. How to implement Custom filters in MVC?
===================================================================================
Q16. Can a static class contains non static members like variables, methods and properties?
Answer:
No Static class has only static members like variables, methods and properties.
===================================================================================
Q17. Can a normal class contains static members?
Answer:
Yes. normal class can have static members. eg singleton
for ex. for below code.
public class normalclass{public static void staticmethodofnormalclass(){Console.WriteLine("this is static method of non static class");}}
We can call the method staticmethodofnormalclass directly with class name ie normalclass.staticmethodofnormalclass()
===================================================================================
Q18. What are the difference between MVC and angular? which to choose which one?
Answer:
MVC 5 or MVC core
1. MVC gives you a flavor of full flashed full stack layer. All you need is database for storage.
1. MVC gives you a flavor of full flashed full stack layer. All you need is database for storage.
2. No as such AOT concept.
3. Testing is kind of mixed for UI and service layer because with bad architecture you might have tight coupling between these two layers.
4. No SPA concept.
5. Might be good choice in case of Rapid development as it gives easy templates creation. Scaffolding saves lots of time.
6. Less maintenance cost as we have easy and less code.
Angular
1. This is only for Frontend application. you need service layer as well for this.
2. Angular has its optimized AOT. Ahead of time compilation which boots speed.
3. Simplified testing for UI.
4. Better performance because of SPA.
5. Little more tricky to learn for new developer and usually takes more time to develop.
6. More maintains cost for both UI layer and service layer.
===================================================================================
Q19. What are the differences between MVC and MVVM?
Answer:
MVVM - Model, View, ViewModel
>> Angular is more of MVVM model, not MVC
MVVM:
1. Supports two way binding of data between view and viewmodel.
2. View is the entry point.
MVC:
1. Does not suppot two way binding by default.
2. Controller is the entry point.
===================================================================================
Q20. How to implement Custom filters in MVC?
Answer:
There are two ways by which we can have custom filter.
1. Simply implementing the interface of any particular filter.
2. By creating Global filter. This can be done by inheriting Attribute class and overriding its methods. [remember Interface is not used]
Global filter example --
class MyErrorHandler : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
Log(filterContext.Exception);
base.OnException(filterContext);
}
private void Log(Exception exception)
{
//log exception here..
}
}You can now apply the MyErrorHandler attribute at the global level or controller or action method level, the same way we applied an HandleError attribute.
[MyErrorHandler]
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}==================================

No comments:
Post a Comment