What are benefits and Limitation of using View state for state management in asp.net?
Following are the benefits of using View state:-
. No server resources are required because state is in a structure in the page code.
. Simplicity.
. States are retained automatically.
. The values in view state are hashed, compressed, and encoded, thus representing a higher state of security than hidden fields.
. View state is good for caching data in Web frame configurations because the data is cached on the client.
Following are limitation of using View state:-
. Page loading and posting performance decreases when large values are stored because view state is stored in the page.
. Although view state stores data in a hashed format, it can still be tampered because it is stored in a hidden field on the page. The information in the hidden field can also be seen if the page output source is viewed directly, creating a potential security risk.
Below is sample of storing values in view state.
Interview Questions: Which are the three main categories of design patterns?
Creational Patterns
• Abstract Factory:- Creates an instance of several families of classes
• Builder: - Separates object construction from its representation
• Factory Method:- Creates an instance of several derived classes
• Prototype:- A fully initialized instance to be copied or cloned
• Singleton:- A class in which only a single instance can exist
Note: - The best way to remember Creational pattern is by remembering ABFPS (Abraham Became First President of States).
Structural Patterns
• Adapter:-Match interfaces of different classes .
• Bridge:-Separates an object’s abstraction from its implementation.
• Composite:-A tree structure of simple and composite objects.
• Decorator:-Add responsibilities to objects dynamically.
• Façade:-A single class that represents an entire subsystem.
• Flyweight:-A fine-grained instance used for efficient sharing.
• Proxy:-An object representing another object.
Note : To remember structural pattern best is (ABCDFFP)
Behavioral Patterns
• Mediator
efines simplified communication between classes.
• Memento:-Capture and restore an object's internal state.
• Interpreter:- A way to include language elements in a program.
• Iterator:-Sequentially access the elements of a collection.
• Chain of Resp: - A way of passing a request between a chain of objects.
• Command:-Encapsulate a command request as an object.
• State:-Alter an object's behavior when its state changes.
• Strategy:-Encapsulates an algorithm inside a class.
• Observer: - A way of notifying change to a number of classes.
• Template Method
efer the exact steps of an algorithm to a subclass.
• Visitor
efines a new operation to a class without change.
Interview question, state pattern
State pattern allows an object to change its behavior depending on the current values of the object. Consider the figure ‘State pattern example’. It’s an example of a bulb operation. If the state of the bulb is off and you press the switch the bulb will turn off. If the state of bulb is on and you press the switch the bulb will be off. So in short depending on the state the behavior changes.
Figure: - State pattern example
Now let’s try to implement the same bulb sample in C#. Figure ‘State pattern in action’ shows both the class and the client code. We have made a class called as ‘clsState’ which has an enum with two state constants ‘On’ and ‘Off’. We have defined a method ‘PressSwitch’ which toggles its state depending on the current state. In the right hand side of the same figure we have defined a client which consumes the ‘clsState’ class and calls the ‘PressSwitch()’ method. We have displayed the current status on the textbox using the ‘getStatus’ function.
When we click the press switch it toggles to the opposite state of what we have currently.
Figure: - State pattern in action
(I) Can you explain strategy pattern?
Strategy pattern are algorithms inside a class which can be interchanged depending on the class used. This pattern is useful when you want to decide on runtime which algorithm to be used.
Let’s try to see an example of how strategy pattern works practically. Let’s take an example of a math’s calculation where we have strategies like add and substract. Figure ‘Strategy in action’ shows the same in a pictorial format. It takes two numbers and the depending on the strategy it gives out results. So if it’s an addition strategy it will add the numbers, if it’s a substraction strategy it will give the substracted results. These strategies are nothing but algorithms. Strategy pattern are nothing but encapsulation of algorithms inside classes.
Figure: - Strategy in action
So the first thing we need to look in to is how these algorithms can be encapsulated inside the classes. Below figure ‘Algorithm encapsulated’ shows how the ‘add’ is encapsulated in the ‘clsAddStatergy’ class and ‘substract’ in the ‘clsSubstractStatergy’ class. Both these classes inherit from ‘clsStratergy’ defining a ‘calculate’ method for its child classes.
Figure: - Algorithms encapsulated
Now we define a wrapper class called as ‘clsMaths’ which has a reference to the ‘clsStatergy’ class. This class has a ‘setStatergy’ method which sets the strategy to be used.
Figure: - Strategy and the wrapper class
Below figure ‘Strategy client code’ shows how the wrapper class is used and the strategy object is set on runtime using the ‘setStatergy’ method.
Figure: - Strategy client code
Thank You Letter for Job Interview
Your Name
Your Address
Your City, State, Zip Code
Your Phone Number
Your Email
Date
Name
Title
Organization
Address
City, State, Zip Code
Dear Mr./Ms. Last Name:
It was very enjoyable to speak with you about the assistant account executive position at the Smith Agency. The job, as you presented it, seems to be a very good match for my skills and interests. The creative approach to account management that you described confirmed my desire to work with you.
In addition to my enthusiasm, I will bring to the position strong writing skills, assertiveness and the ability to encourage others to work cooperatively with the department. My artistic background will help me to work with artists on staff and provide me with an understanding of the visual aspects of our work.
I understand your need for administrative support. My detail orientation and organizational skills will help to free you to deal with larger issues. I neglected to mention during my interview that I had worked for two summers as a temporary office worker. This experience helped me to develop my secretarial and clerical skills.
I appreciate the time you took to interview me. I am very interested in working for you and look forward to hearing from you about this position.
Sincerely,
Your Signature
Your Typed Name
Interview Questions for ASP.Net
- We can add a crystal report in aspx page using two techniques, what are these?
- What is Cache?
- What is AJAX?
- Is AJAX a language?
- What is the difference between syncronus and asyncronus?
- what do you mean by HTTP Handler?
- What is the purpose of Global.asax?
- What is the difference between stroed procedure and stored function in SQL?
- Can we have an updateable view in SQL?
- What is connection pooling? how can we acheive that in asp.net?
- What is DataSet?
- What is the difference between typed and untyped dataset?
- What is the difference bewteen accessing the data throgh the dataset and datareader?
- Any idea of Data Access Component provided by Microsoft?
- Any idea of Enterprise library?
- What is web service?
- What is WSDL?
- Can a web service be only developed in asp.ent?
- can we use multiple web services from a single application?
- can we call a web service asynchronously?
- Can a web service be used from a windows application?
- What do we need to deploy a web service?
- What is the significance of web.config?
- Can we have multiple web.config files in a sigle web project?
- Can we have more then one configuration file?
- Type of Authentications?
- Can we have multiple assemblies in a single web project?
- What is the difference between the inline and code behind?
- what is side by side execution?
- can we have two different versions of dot net frameworks running on the same machine?
- What is CLR? Difference b/w CLR and JVM?
- What is CLI?
- What is GAC?
- What is View State?
- Can you read the View State?
- What is the difference between encoding and encryption? Which is easy to break?
- Can we disable the view state application wide?
- can we disable it on page wide?
- can we disable it for a control?
- What is provider Model?
- What is machine.config?
- What different types of session state Management we have in asp.net?
- What are cookies?
- What is the significance of Application_Start/Session_Start/Application_Error?
- What is CTS?
- What is .resx file meant for?
- Any idea of aspnet_regiis?
- Any idea of ASP NET State Service?
- Crystal report is only used for read only data and reporting purposes?