A cache is the most valuable feature that Microsoft provides. It is a type of memory that is relatively small but can be accessed very quickly. It essentially stores information that is likely to be used again. For example, web browsers typically use a cache to make web pages load faster by storing a copy of the webpage files locally, such as on your local computer.


Caching is the process of storing data into cache.Working. Caching with the C# language is very easy. System.Runtime.Caching.dll provides the feature for working with caching in C#. In this illustration I am using the following classes:


ObjectCache: The CacheItem class provides a logical representation of a cache entry, that can include regions using the RegionName property. It exists in the System.Runtime.Caching.

MomoryCache: This class also comes under System.Runtime.Caching and it represents the type that implements an in-cache memory.

CacheItemPolicy: Represents a set of eviction and expiration details for a specific cache entry.

namespace CachingWithConsoleApplication  
    class Program  
        static void Main(string[] args)  
            StockItems PS = new StockItems();  
         List<string> Pizzas= (List<string>)  PS.GetAvailableStocks();  
         Pizzas = (List<string>)PS.GetAvailableStocks();  
    public class StockItems  
        private const string CacheKey = "availableStocks";  
        public IEnumerable GetAvailableStocks()  
            ObjectCache cache = MemoryCache.Default;  
            if (cache.Contains(CacheKey))  
                return (IEnumerable)cache.Get(CacheKey);  
                IEnumerable availableStocks = this.GetDefaultStocks();  
                // Store data in the cache  
                CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();  
                cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddHours(1.0);  
                cache.Add(CacheKey, availableStocks, cacheItemPolicy);  
                return availableStocks;  
        public IEnumerable GetDefaultStocks()  
            return new List<string>() { "Pen", "Pencil", "Eraser" };  

Advantages of Cache vs Session

One important difference is, that items in the cache can expire (will be removed from cache) after a specified amount of time. Items put into a session will stay there, until the session ends.

ASP.NET can also remove items from cache when the amount of available memory gets small.

Another difference: the session state can be kept external (state server, SQL server) and shared between several instances of your web app (for load balancing). This is not the case with the cache.

Besides of these differences (as others have noted): session is per user/session while cache is per application.

Another important difference, Session State will be blocked if concurrent async Ajax requests are executed, it will effect performance

Cache is in the Application scope with the purpose of reducing the number of times a piece of data is obtained. Session is in a user's session scope with the purpose of giving a particular user state.

Difference Between Unit Testing and Test Driven Development

Unit Testing refers to what you are testing, TDD to when you are testing.

The two are orthogonal.

Unit Testing means, well, testing individual units of behavior. An individual unit of behavior is the smallest possible unit of behavior that can be individually tested in isolation. (I know that those two definitions are circular, but they seem to work out quite well in practice.)

You can write unit tests before you write your code, after you write your code or while you write your code.

TDD means (again, kind of obvious) letting your tests drive your development (and your design). You can do that with unit tests, functional tests and acceptance tests. Usually, you use all three.

The most important part of TDD is the middle D. You let the tests drive you. The tests tell you what to do, what to do next, when you are done. They tell you what the API is going to be, what the design is. (This is important: TDD is not about writing tests first. There are plenty of projects that write tests first but don't practice TDD. Writing tests first is simply a prerequisite for being able to let the tests drive the development.)

Difference between “Layers” and “Tiers”?

layers refer to logical seperation of code. Logical layers help you organise your code better. For example an application can have the following layers.

1)Presentation Layer or UI Layer 2)Business Layer or Business Logic Layer 3)Data Access Layer or Data Layer

The aboove three layers reside in their own projects, may be 3 projects or even more. When we compile the projects we get the respective layer DLL. So we have 3 DLL's now.

Depending upon how we deploy our application, we may have 1 to 3 tiers. As we now have 3 DLL's, if we deploy all the DLL's on the same machine, then we have only 1 physical tier but 3 logical layers.

If we choose to deploy each DLL on a seperate machine, then we have 3 tiers and 3 layers.

So, Layers are a logical separation and Tiers are a physical separation. We can also say that, tiers are the physical deployment of layers.

Definition - What does Annotation mean?

Annotation is a term used in computer programming to refer to documentation and comments that may be found on code logic. Annotation is typically ignored once the code is executed or compiled.

Sometimes programmers will anticipate that those learning a programming language such as HTML, or those who may be modifying the programming at a later date, will require an explanation of the rationale behind the logic or even an explanation of how the logic accomplishes its purpose or goal. Thus, an annotation, or explanation, will be included within the code.

using Statement

 using (Font font1 = new Font("Arial", 10.0f)) 
            byte charset = font1.GdiCharSet;

File and Font are examples of managed types that access unmanaged resources (in this case file handles and device contexts). There are many other kinds of unmanaged resources and class library types that encapsulate them. All such types must implement the IDisposable interface.

As a rule, when you use an IDisposable object, you should declare and instantiate it in a using statement. The using statement calls the Dispose method on the object in the correct way, and (when you use it as shown earlier) it also causes the object itself to go out of scope as soon as Dispose is called. Within the using block, the object is read-only and cannot be modified or reassigned.
The using statement ensures that Dispose is called even if an exception occurs while you are calling methods on the object. You can achieve the same result by putting the object inside a try block and then calling Dispose in a finally block; in fact, this is how the using statement is translated by the compiler. The code example earlier expands to the following code at compile time (note the extra curly braces to create the limited scope for the object):

              Font font1 = new Font("Arial", 10.0f);
                byte charset = font1.GdiCharSet;
                if (font1 != null)

The Agile Movement

What Is Agile?
Not a methodology! The Agile movement seeks alternatives to traditional project management. Agile approaches help teams respond to unpredictability through incremental, iterative work cadences and empirical feedback. Agilists propose alternatives to waterfall, or traditional sequential development.

What is Scrum?
Scrum is the most popular way of introducing Agility due to its simplicity and flexibility. Because of this popularity, many organizations claim to be “doing Scrum” but aren’t doing anything close to Scrum’s actual definition. Scrum emphasizes empirical feedback, team self management, and striving to build properly tested product increments within short iterations. Doing Scrum as it’s actually defined usually comes into conflict with existing habits at established non-Agile organizations.

Scrum has only three roles: Product Owner, Team, and Scrum Master. These are described in detail by the Scrum Training Series. The responsibilities of the traditional project manager role are split up among these three Scrum roles. Scrum has five meetings: Backlog Grooming (aka Backlog Refinement), Sprint Planning, Daily Scrum (aka 15-minute standup), the Sprint Review Meeting, and the Sprint Retrospective Meeting.

No comments:

Post a Comment