A factory pattern is a creational pattern. A strategy pattern is an operational pattern. Put another way, a factory pattern is used to create objects of a specific type. A strategy pattern is use to perform an operation (or set of operations) in a particular manner. In the classic example, a factory might create different types of Animals: Dog, Cat, Tiger, while a strategy pattern would perform particular actions, for example, Move; using Run, Walk, or Lope strategies.
In fact the two can be used together. For example, you may have a factory that creates your business objects. It may use different strategies based on the persistence medium. If your data is stored locally in XML it would use one strategy. If the data were remote in a different database, it would use another.
Q:Difference between dependency injection and factory pattern
When using a factory your code is still actually responsible for creating objects. By DI you outsource that responsibility to another class or a framework, which is separate from your code.
Q: Returning IEnumerable
The difference is that IQueryable is the interface that allows LINQ-to-SQL (LINQ.-to-anything really) to work. So if you further refine your query on an IQueryable , that query will be executed in the database, if possible.
For the IEnumerablecase, it will be LINQ-to-object, meaning that all objects matching the original query will have to be loaded into memory from the database.
In code:
IQueryableThat code will execute SQL to only select gold customers. The following code, on the other hand, will execute the original query in the database, then filtering out the non-gold customers in the memory:custs = ...; // Later on... var goldCustomers = custs.Where(c => c.IsGold);
IEnumerableThis is quite an important difference, and working on IQueryablecusts = ...; // Later on... var goldCustomers = custs.Where(c => c.IsGold); can in many cases save you from returning too many rows from the database. Another prime example is doing paging: If you use Take and Skip on IQueryable, you will only get the number of rows requested; doing that on an IEnumerable will cause all of your rows to be loaded in memory.
Click Here
Q: Understanding Garbage Collection in .NET
Wonderful link
http://msdn.microsoft.com/en-us/magazine/bb985010.aspx
Q protected internal
'protected internal' does not mean protected *and* internal - it means protected *or* internal. So a protected internal member is visible to any class inheriting the base class, whether it's in the same assembly or not. The member is also visible via an object declared of that type anywhere in the original assembly.
Q:What is internal set property in c#?
If you have a property with an internal set accessor (and public get accessor) it means that code within the assembly can read (get) and write (set) the property, but other code can only read it.
You can derive the above information by reading about the internal access modifier, the public access modifier and properties.
Also, you can read about Restricting Accessor Accessibility.
Flushing the Session simply gets the data that is currently in the session synchronized with what is in the database. However, just because you have flushed, doesn't mean the data can't be rolled back.Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.Commit does flush the session, but it also ends the unit of work.
Difference between .Net 4.0 and .Net 3.5, 2.0
As we all know, ASP.NET 3.5 has introduced with the following main new features
1) AJAX integration
2) LINQ
3) Automatic Properties
4) Lambda expressions
I hope it would be useful for everyone to know about the differences about asp.net 3.5 and its next version asp.net 4.0
Because of space consumption I’ll list only some of them here.
1) Client Data access:
ASP.NET 3.5: There is no direct method to access data from client side. We can go for any of these methods- Pagemethods of script manager
http://randomactsofcoding.blogspot.com/2007/10/introduction-to-pagemethods.html
2) ICallbackEventHandler interface
http://www.codeproject.com/KB/aspnet/ICallbackEventHandler.aspx
3) XMLHttphanlder component
1) Client data controls
2) Client templates
3) Client data context
i.e we can access the data through client data view & data context objects from client side.
2) Setting Meta keyword and Meta description:
Meta keywords and description are really useful for getting listed in search engine.ASP.NET 3.5: It has a feature to add meta as following tag
<meta name="keywords" content="These, are, my, keywords" /> <meta name="description" content="This is the description of my page" />ASP.NET 4.0: Here we can add the keywords and description in Page directives itself as shown below.
< %@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" Keywords="Keyword1,Key2,Key3,etc" Description="description" %>
3) Enableviewstage property for each control
ASP.NET 3.5: this property has two values “True” or “false”ASP.NET 4.0: ViewStateMode property takes an enumeration that has three values: Enabled, Disabled, and Inherit.
Here inherit is the default value for child controls of a control.
4) Setting Client IDs
Some times ClientID property creates head ach for the programmers.ASP.NET 3.5: We have to use ClientID property to find out the id which is dynamically generated
ASP.NET 4.0: The new ClientIDMode property is introduced to minimize the issues of earlier versions of ASP.NET.
It has following values.
AutoID – Same as ASP.NET 3.5
Static – There won’t be any separate clientid generated at run time
Predictable-These are used particularly in datacontrols. Format is like clientIDrowsuffix with the clientid vlaue
Inherit- This value specifies that a control’s ID generation is the same as its parent.
New features in ASP.net 4
http://www.simple-talk.com/dotnet/asp.net/asp.net-4.0-features/