0% found this document useful (0 votes)
561 views3 pages

MVC Concepts and Design Patterns

ViewBag is a collection used to share data between actions and views. TempData maintains data for the entire request while ViewBag only shares data between the action and view. Models represent business logic and data. Razor is a view engine that helps create pages and display UI using ASP.Net MVC. Entity Framework is an ORM that maps objects to a relational database. The SOLID principles - single responsibility, open-closed, Liskov substitution, interface segregation and dependency inversion - are good practices for object-oriented design.

Uploaded by

Suraj Mahajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
561 views3 pages

MVC Concepts and Design Patterns

ViewBag is a collection used to share data between actions and views. TempData maintains data for the entire request while ViewBag only shares data between the action and view. Models represent business logic and data. Razor is a view engine that helps create pages and display UI using ASP.Net MVC. Entity Framework is an ORM that maps objects to a relational database. The SOLID principles - single responsibility, open-closed, Liskov substitution, interface segregation and dependency inversion - are good practices for object-oriented design.

Uploaded by

Suraj Mahajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • MVC Overview
  • ASP.Net / OOPS
  • OOPS Details

MVC

What is View Bag


ViewBag is collection of viewData.
When I use TEMP DATA?
If you want to maintain data for complete request
ie. Action to action , or action to view
Then you will use TEMP DATA
Temp Data is for only one request.
When I use ViewBag ?
If you want to maintain data just from action to view then you will use ViewBag
What Is Models?
Models are nothing but modern c sharp classes, Which have business logic and
which provides data.
What is Razor ?
Razoris noting but it is new kind of view engine to display pages which helps us
to create pages and display UI using MVC [Link] .
What Is Modal Binders ?
Model binder is
What Is Entity Framework ?
Entity Framework is ORM , Object relational mapping.

[Link] / OOPS

What us IOC (Inversion of control)


o Where we move unwanted work for example work will affects to
class & some other class who will takes this responsibility in more
better way it termed as Inversion of control
o IOC (Inversion of control) is a general parent term while DI
(Dependency injection) is a subset of IOC. IOC is a concept where
the flow of application is inverted. So for example rather than the
caller calling the method.
o The Inversion of Control (IOC) and Dependency Injection (DI)
patterns are all about removing dependencies from your code.
What is dependency injection?
o Dependency injection is a software design pattern that implements
inversion of control for resolving dependencies.
IOC is an principle.

What is Factory Method?


o Provide an interface for creating families of related or dependent objects without
specifying their concrete classes

What
o
o
o
o
o

What is builder pattern?


o Separate the construction of a complex object from its representation, allowing
the same construction process to create various representations.

What is faade pattern?


o Provide a unified interface to a set of interfaces in a subsystem. Facade defines a
higher-level interface that makes the subsystem easier to use.

What is Single Responsibility Principle (SRP)?


o the single responsibility principle states that every class should
have responsibility over a single part of the functionality provided by the
software, and that responsibility should be entirely encapsulated by the class.

What is open closed principle


o software entities (classes, modules, functions, etc.) should be open for extension,
but closed for modification"; that is, such an entity can allow its behaviour to be
extended without modifying its source code.

What is Liskov substitution ?


o Liskov substitution principle(LSP) is a particular definition of a subtyping relation

OOPS

is solid ?
Single responsibility,
Open-closed,
Liskov substitution,
Interface segregation
Dependency inversion

Class
o It is a collection of objects.

Object
It is a real time entity.
An object can be considered a "thing" that can perform a set of related activities.
The set of activities that the object performs defines the object's behaviour
Destructor
o Destructor in c# is a special method of a class which will invoke automatically
when an instance of the class is destroyed
o
o

Private Constructor
o Private constructor in c# is used to restrict the class from being instantiated when
it contains every member as static.
o Private Constructor used for to restrict user to create object of class.

Static Constructor.
o Static constructor in c# is used to create static fields of the class and to write the
code that needs to be executed only once.

Copy Constructor.
o Copy constructor in c# is used to create new instance to the values of an existing
instance.
Constructor overloading
o In c# we can overload constructor by creating another constructor with
same method name and different parameters.
What is Interface
o An interface is not a class. It is an entity that is defined by the word
Interface. An interface has no implementation; it only has the signature or
in other words, just the definition of the methods without the body.
What is Generalization?
o

Question: What is application variable ?


Answer : application variable they help you to share the global data across all of
the users of the site.
Question: Synchronise process
Answer : Synchronise process is sequential process.

Common questions

Powered by AI

The Interface Segregation Principle (ISP) is part of the SOLID principles in software development, emphasizing that clients should not be forced to depend on interfaces they do not use. ISP contributes to cleaner and more robust software design by advocating for the division of a large, monolithic interface into smaller, more specific ones. This gives clients the ability to depend only on the functionalities they need, reducing the risk of changes in unrelated functionalities affecting clients’ code. By promoting this segregation, it leads to decoupled and modular code, simplifying testing and maintenance, and enhancing the adaptability of software systems .

Model Binders in ASP.NET MVC are used to map HTTP request data to action method parameters efficiently. They abstract away the complexity of retrieving form data, URL data, or query strings and converting it into CLR types, streamlining the development process. By simplifying data handling from client to server, Model Binders allow developers to focus more on business logic and application features rather than low-level data parsing, thus improving developer productivity and reducing boilerplate code .

The Facade Pattern simplifies complex systems by providing a unified, higher-level interface that encapsulates interactions with subsystems, thus reducing dependencies and complexity for clients needing to interact with those systems. It streamlines usage for clients by hiding the intricate details and operations of underlying subcomponents. The application of the Facade Pattern is most beneficial in software projects where clients require simplified interactions with complex subsystems, such as in systems integration tasks or when aiming to decouple clients from subsystem services, thereby facilitating easier maintenance and improved scalability .

Destructors in C# are special methods that are automatically called when an instance of a class is destroyed. They are primarily used to release unmanaged resources held by an instance, such as file handles or database connections, ensuring efficient resource management. Destructors are not called manually by developers; instead, the garbage collector invokes them as part of its memory management process to clean up resources, preventing resource leaks and ensuring a stable application performance .

In ASP.NET MVC, TempData is used for passing data from one controller action to another (or across redirects) within a single request-response cycle, storing data temporarily and removing it once accessed. It utilizes the session state to store information persistently for the life of the request. ViewBag, however, is a dynamic container used to pass data from a controller to a view in the same request, being valid only for the duration of that request and losing its value after the view is rendered. ViewBag is suited for simpler, transient data passage, while TempData is appropriate for more persistent data that needs to survive multiple requests .

Dependency Injection (DI) is a subset of Inversion of Control (IOC), which is a general principle in software design where the flow of control of a program is inverted. Instead of the caller having to instantiate a component it needs, an external entity supplies the required dependency, reducing the coupling between software components. DI facilitates a more modular and easily testable system by promoting loose coupling and enhancing code maintainability and flexibility .

The Builder Pattern and the Factory Method Pattern are both design patterns used for object creation, but they serve different purposes. The Builder Pattern separates the construction of a complex object from its representation, allowing the same construction process to create various representations. This pattern is particularly useful when an object needs to be constructed in a step-by-step approach or requires configurations. Conversely, the Factory Method Pattern provides an interface for creating an instance of a class in a superclass, but it allows subclasses to alter the type of objects that will be created. It is used when a class cannot anticipate the class of objects it must create. Thus, the Builder Pattern is used for constructing complex objects, while the Factory Method Pattern is used for allowing a class to delegate instantiation to subclasses .

The Open/Closed Principle is a guideline in software design suggesting that software entities should be open for extension but closed for modification. This means that an entity like a class or module should allow its behavior to be extended without altering its existing source code. Applying this principle involves using techniques such as interfaces and abstract classes to allow new functionality without changing existing code, thus increasing the system’s robustness and reducing the likelihood of introducing bugs .

The Single Responsibility Principle (SRP) states that a class should have only one reason to change, meaning it should have only one responsibility. This principle enhances software design by ensuring that each class is focused and cohesive, easing maintenance and enhancing readability. By adhering to SRP, developers can ensure that changes to a particular functionality will require modifying only the classes directly responsible for that functionality, thus reducing the risk of side effects across the codebase .

An Interface differs from a Class in that it cannot contain any implementation, only definitions of methods, properties, or events that must be implemented by classes. The primary benefit of using Interfaces is that they enable polymorphism by allowing different classes to implement the same set of methods, promoting a form of contract and enabling loose coupling between components. This results in more flexible and maintainable code where changes in implementation do not affect the system’s overall structure .

MVC
What is View Bag 
ViewBag is collection of viewData.
When I use TEMP DATA?
If you want to maintain data for complete requ
ASP.Net / OOPS

What us IOC (Inversion of control)
o
Where we move unwanted work  for example work will affects to 
class &

Class
o
It is a collection of objects.

Object
o
It is a real time entity.
o
An object can be considered a "thing" that ca

You might also like