Feed on
Posts
Comments

 

What is a Design Pattern?

Design Pattern is a re-usable, high quality solution to a given requirement, task or recurring problem. Further, it does not comprise of a complete solution that may be instantly converted to a code component, rather it provides a framework for how to solve a problem.

In 1994, the release of the book Design Patterns, Elements of Reusable Object Oriented Software made design patterns popular.

Because design patterns consist of proven reusable architectural concepts, they are reliable and they speed up software development process.

Design Patterns are in a continious phase of evolution, which means that they keep on getting better & better as they are tested against time, reliability and subjected to continious improvements. Further, design patterns have evolved towards targeting specific domains. For example, windows-based banking applications are usually based on singleton patterns, e-commerce web applications are based on the MVC (Model-View-Controller) pattern.

Design Patterns are categorized into 3 types:
Creational Patterns
Structural Patterns
Behavioral Patterns

What are Creational Design Patterns?

The Creational Design Patterns focus on how objects are created and utilized in an application. They tackle the aspects of when and how objects are created, keeping in mind whats the best way these objects should be created.

Listed below are some of the commonly known Creational Design Patterns:
>>> Abstract Factory Pattern
>>> Factory Pattern
>>> Builder Pattern
>>> Lazy Pattern
>>> Prototype Pattern
>>> Singleton Pattern

Whats the difference between Abstract Factory Pattern and Factory Pattern?

In an abstract factory design, a framework is provided for creating sub-components that inherit from a common component. In .NET, this is achieved by creating classes that implement a common interface or a set of interfaces, where the interface comprises of the generic method declarations that are passed on to the sub-components. TNote that not just interfaces, but even abstract classes can provide the platform of creating an application based on the abstract factory pattern.
Example, say a class called CentralGovernmentRules is the abstract factory class, comprised of methods like ShouldHavePolice() and ShouldHaveCourts(). There may be several sub-classes like State1Rules, State2Rules etc. created that inheriting the class CentralGovernmentRules, and thus deriving its methods as well.

Note that the term “Factory” refers to the location in the code where the code is created.

A Factory Pattern is again an Object creation pattern. Here objects are created without knowing the class of the object. Sounds strange? Well, actually this means that the object is created by a method of the class, and not by the class’s constructor. So basically the Factory Pattern is used wherever sub classes are given the priviledge of instantiating a method that can create an object.

Describe the Builder Design Pattern

In a builder design pattern, an object creation process is separated from the object design construct. This is useful becuase the same method that deals with construction of the object, can be used to construct different design constructs.

What is the Lazy Design Pattern?

The approach of the Lazy Design Pattern is not to create objects until a specific requirement matches, and when it matches, object creation is triggered. A simple example of this pattern is a Job Portal application. Say you register yourself in that site thus filling up the registration table, only when the registration table is filled, the other objects are created and invoked, that prompt you to fill in other details too, which will be saved in other tables.

What is the Prototype Design Pattern?

A prototype design pattern relies on creation of clones rather than objects. Here, we avoid using the keyword ‘new’ to prevent overheads.

What is the Singleton Design Pattern?

The Singleton design pattern is based on the concept of restricting the instantiation of a class to one object. Say one object needs to perform the role of a coordinator between various instances of the application that depend on a common object, we may design an application using a Singleton. Usage of Singleton patterns is common in Banking, Financial and Travel based applications where the singleton object consists of the network related information.

A singleton class may be used to instantiate an object of it, only if that object does not already exist. In case the object exists, a reference to the existing object is given. A singleton object has one global point of access to it.

An ASP.NET Web Farm is also based on the Singleton pattern. In a Web Farm, the web application resides on several web servers. The session state is handled by a Singleton object in the form of the aspnet_state.exe, that interacts with the ASP.NET worker process running on each web server. Note that the worker process is the aspnet_wp.exe process. Imagine one of the web servers shutting down, the singleton object aspnet_state.exe still maintains the session state information across all web servers in the web farm.

In .NET, in order to create a singleton, a class is created with a private constructor, and a “static readonly” variable as the member that behaves as the instance.

What are Structural Design Patterns?

A structural design pattern establishes a relationship between entities. Thus making it easier for different components of an application to interact with each other. Following are some of the commonly known structural patterns:

>>> Adapter Pattern - Interfaces of classes vary depending on the requirement.
>>> Bridge Pattern - Class level abstraction is separated from its implementation.
>>> Composite Pattern - Individual objects & a group of objects are treated similarly in this approach.
>>> Decorator Pattern - Functionality is assigned to an object.
>>> Facade Pattern - A common interface is created for a group of interfaces sharing a similarity.
>>> Flyweight Pattern - The concept of sharing a group of small sized objects.
>>> Proxy Pattern - When an object is complex and needs to be shared, its copies are made. These copies are called the proxy objects.

What are the different types of Proxy Patterns?

1 - Remote Proxy - A reference is given to a different object in a different memory location. This may be on a different or a same machine.
2 - Virtual Proxy - This kind of object is created only & only when really required because of its memory usage.
3 - Cache Proxy - An object that behaves as a temporary storage so that multiple applications may use it. For example, in ASP.NET when a page or a user control contains the OutputCache directive, that page/control is cached for some time on the ASP.NET web server.

What is a behavioral design pattern?

Behaviorial design patterns focus on improving the communication between different objects. Following are different types of behavioral patterns:
>>> Chain Or Responsibilities Pattern - In this pattern, objects communicate with each other depending on logical decisions made by a class.
>>> Command Pattern - In this pattern, objects encapsulate methods and the parameters passed to them.
>>> Observer Pattern - Objects are created depending on an events results, for which there are event handlers created.

What is the MVC Pattern (Model View Controller Pattern)?

The MVC Pattern (Model View Controller Pattern) is based on the concept of designing an application by dividing its functionalities into 3 layers. Its like a triad of components. The Model component contains the business logic, or the other set of re-usable classes like classes pertaining to data access, custom control classes, application configuration classes etc. The Controller component interacts with the Model whenever required. The control contains events and methods inside it, which are raised from the UI which is the View component.

Consider an ASP.NET web application. Here, all aspx, ascx, master pages represent the View.

The code behind files (like aspx.cs, master.cs, ascx.cs) represent the Controller.

The classes contained in the App_Code folder, or rather any other class project being referenced from this application represent the Model component.

Advantages: * Business logic can be easily modified, without affecting or any need to make changes in the UI.
* Any cosmetic change in the UI does not affect any other component.

What is the Gang of Four Design Pattern?

The history of all design patterns used in modern day applications derive from the Gang of Four (GoF) Pattern. Gang of Four patterns are categorized into 3 types:
1 - Creational
2 - Structural
3 - Behavioral

The term “Gang of Four” (or “GoF” in acronym) is used to refer to the four authors of the book Design Patterns: Elements of Reusable Object-Oriented Software. The authors are Erich Gamma, Ralph Johnson, Richard Helm and John Vlissides.

When should design patterns be used?

While developing software applications, sound knowledge of industry proven design patterns make the development journey easy and successful. Whenever a requirement is recurring, a suitable design pattern should be identified. Usage of optimal design patterns enhance performance of the application. Though there are some caveats. Make sure that there are no overheads imposed on a simple requirement, which means that design patterns should not be unnecessarily be used.

How many design patterns can be created in .NET?

As many as one can think. Design patterns are not technology specific, rather their foundation relies on the concept of reusability, object creation and communication. Design patterns can be created in any language.

 

 

http://www.dotnetuncle.com/Design-Patterns/dot-net-design-pattern-interview-questions.aspx

Usually this problem occur when we install iIs after installation of Visual studio or .net framework. For this purpose use aspnet_regiis.exe, it is located under %WindowsDir%\Microsoft.NET\Framework\vx.y.zzzz\ and you should call it with the -i parameter: aspnet_regiis.exe -i

 

very nice article about encription of cookies in asp.net

http://www.codeproject.com/KB/cs/CookieEncryptionModule.aspx

 

sunaa hai log use aa.Nkh bhar ke dekhate hai.n
so us ke shahar me.n kuchh din Thahar ke dekhate hai.n

sunaa hai rabt hai us ko Kharaab haalo.n se
so apane aap ko barbaad karake dekhate hai.n

sunaa hai dard kii gaahak hai chashm-e-naazuk us kii
so ham bhii us kii galii se guzar kar dekhate hai.n

sunaa hai us ko bhii hai sher-o-shaayarii se shagaf
so ham bhii mojaze apane hunar ke dekhate hai.n

sunaa hai bole to baato.n se phuul jha.Date hai.n
ye baat hai to chalo baat kar ke dekhate hai.n

sunaa hai raat use chaa.Nd takataa rahataa hai
sitaare baam-e-falak se utar kar dekhate hai.n

sunaa hai hashr hai.n us kii Gazaal sii aa.Nkhe.n
sunaa hai us ko hiran dasht bhar ke dekhate hai.n

sunaa hai din ko use titaliyaa.N sataatii hai.n
sunaa hai raat ko jugnuu Thahar ke dekhate hai.n

sunaa hai raat se ba.Dh kar hai.n kaakule.n us kii
sunaa hai shaam ko saaye guzar ke dekhate hai.n

sunaa hai us kii siyaah chashmagii qayaamat hai
so us ko surmaafarosh aa.Nkh bhar ke dekhate hai.n

sunaa hai us ke labo.n se gulaab jalate hai.n
so ham bahaar par ilzaam dhar ke dekhate hai.n

sunaa hai aa_iinaa tamasaal hai jabii.n us kaa
jo saadaa dil hai.n ban sa.Nvar ke dekhate hai.n

sunaa hai jab se hamaa_il hai.n us kii gardan me.n
mizaaj aur hii laal-o-gauhar ke dekhate hai.n

sunaa hai chashm-e-tasavvur se dasht-e-imkaan me.n
palang zaave us kii kamar ke dekhate hai.n

sunaa hai us ke badan ke taraash aise hai.n
ke phuul apanii qabaaye.N katar ke dekhate hai.n

vo sarv-qad hai magar be-gul-e-muraad nahii.n
ke us shajar pe shaguufe samar ke dekhate hai.n

bas ek nigaah se luTataa hai qaafilaa dil kaa
so rah_ravaan-e-tamannaa bhii Dar ke dekhate hai.n

sunaa hai us ke shabistaan se muttasil hai bahisht
makiin udhar ke bhii jalve idhar ke dekhate hai.n

ruke to gardishe.n us kaa tavaaf karatii hai.n
chale to us ko zamaane Thahar ke dekhate hai.n

kise nasiib ke be-pairahan use dekhe
kabhii kabhii dar-o-diivaar ghar ke dekhate hai.n

kahaaniyaa.N hii.n sahii sab mubaalaGe hii sahii
agar vo Khvaab hai taabiir kar ke dekhate hai.n

ab us ke shahar me.n Thahare.n ki kuuch kar jaaye.N
‘Faraz’ aao sitaare safar ke dekhate hai.n

When you have to send parameter form asp.net code behind to crystal report then kindly used this syntex or statement to achieve the task
for example
 ReportObjectVariable.SetParameterValue(ParmeterName,value)
for example if  rpt is my report and i send value to customer key and objCustomer is my business object then the sample will be as follow 
  rpt.SetParameterValue(REPORT_SP_PARAMETER_CUSTOMER_KEY, objCustomer.MasCustKey)
More real word examples are as follow
  rpt.SetParameterValue(REPORT_SP_PARAMETER_MONTH, CType(Request.QueryString.Item(“Month”), Integer))
 rpt.SetParameterValue(REPORT_SP_PARAMETER_YEAR, CType(Request.QueryString.Item(“Year”), Integer))
rpt.SetParameterValue(REPORT_SP_PARAMETER_CUSTOMER_KEY, objCustomer.MasCustKey, “StatementHead.rpt”)
 rpt.SetParameterValue(REPORT_SP_PARAMETER_CUSTOMER_KEY, objCustomer.MasCustKey, “StatementFoot.rpt”)

 

 

Inspirational

European english

The European Commission has just announced an agreement whereby English will be the
official language of the European Union rather than German, which was the other
possibility. As part of the negotiations, the British Government conceded that
English spelling had some room for improvement and has accepted a 5- year phase-in
plan that would become known as ‘Euro-English’. In the first year, ’s’ will replace
the soft ‘c’. Sertainly, this will make the sivil servants jump with joy. The hard
‘c’ will be dropped in favour of ‘k’. This should klear up konfusion, and keyboards
kan have one less letter. There will be growing publik enthusiasm in the sekond year
when the troublesome ‘ph’ will be replaced with ‘f’. This will make words like
fotograf 20% shorter. In the 3rd year, publik akseptanse of the new spelling kan be
expekted to reach the stage where more komplikated changes are possible. Governments
will enkourage the removal of double letters which have always ben a deterent to
akurate speling. Also, al wil agre that the horibl mes of the silent ‘e’ in the
languag is disgrasful and it should go away. By the 4th yer people wil be reseptiv
to steps such as replasing ‘th’ with ‘z’ and ‘w’ with ‘v’. During ze fifz yer, ze
unesesary ‘o’ kan be dropd from vords kontaining ‘ou’ and after ziz fifz yer, ve vil
hav a reil sensi bl riten styl. Zer vil be no mor trubl or difikultis and evrivun
vil find it ezi tu understand ech oza. Ze drem of a united urop vil finali kum tru.
Und efter ze fifz yer, ve vil al be speking German like zey vunted in ze forst plas.
If zis mad you smil, pleas pas on to oza pepl

In one case i have to right a method to remove duplication from array of strings. 
i write this code 

Public Function RemoveDuplicates(ByVal items As String()) As String()
    Dim noDupsArrList As New ArrayList()
    For i As Integer = 0 To items.Length - 1
        If Not noDupsArrList.Contains(items(i).Trim()) Then
            noDupsArrList.Add(items(i).Trim())
        End If
    Next
    
    Dim uniqueItems As String() = New String(noDupsArrList.Count - 1) {}
    noDupsArrList.CopyTo(uniqueItems)
    Return uniqueItems
End Function

Charles Dickens said the following about Imam Hussain (AS):

“If Hussain fought to quench his worldly desires, then I do not understand why his sisters, wives and children accompanied him. It stands to reason therefore that he sacrificed purely for Islam.”
Sir Muhammad Iqbal says:
Imam Husayn uprooted despotism forever till the Day of Resurrection. He watered the dry garden of freedom with the surging wave of his blood, and indeed he awakened the sleeping Muslim nation. If Imam Husayn had aimed at acquiring a worldly empire, he would not have traveled the way he did (from Medina to Karbala). Husayn weltered in blood and dust for the sake of truth. Verily he, therefore, became the bed-rock (foundation) of the Muslim creed; la ilaha illa Allah (There is no god but Allah).
Ronay wala hoon Shaheed-e-Kerbala key gham men main,
Kya durey maqsad na dengey Saqiye Kausar mujhey

I am one who weeps at the plight of the Martyr of Kerbala Won’t the reward be given to me by the Keeper of Kauser Allama Iqbal in his Baqiyat (in Urdu)

Thomas Carlyle has relayed this about the Tragedy of Karbala:

“The best lesson which we get from the tragedy of Karbala is that Hussain and his companions were the rigid believers of God. They illustrated that numerical superiority does not count when it comes to truth and falsehood.The victory of Hussain despite his minority marvels me!”

Dr. K. Sheldrake on Imam Hussain (AS) said this:

“Hussain marched with his little company not to glory, not to power or wealth, but to a supreme sacrifice and every member of that gallant band, male and female, knew that the foes were implacable, were not only readyto fight but to kill. Denied even water for the children, they remained parched under a burning sun, amid scorching sands yet no one faltered for a moment and bravely faced the greatest odds without flinching.”


BrownBrown in his `A Literary History of Persia’ writes:
As a reminder, the blood-stained field of Karbala’ where the grandson of the Apostle of God fell at length, tortured by thirst and surrounded by the bodies of his murdered kinsmen, has been at any time since then sufficient to evoke, even in the most lukewarm and heedless, the deepest emotion, the most frantic grief and the exaltation of spirit before which pain, danger, and death shrink to unconsidered trifles. Yearly, on the tenth day of Muharram, the tragedy is rehearsed in Persia, in India, in Turkey, in Egypt, wherever a Shiite community or colony exists; … As I write it all comes back; the wailing chant, the sobbing multitudes, the white raiment red with blood from self-inflicted wounds, the intoxication of grief and sympathy.

World famous Arab historian al-Fakhri has said this about Imam Hussain’s sacrifice:

“This is a catastrophe whereof I care not to speak at length, deeming it alike too grievous and too horrible. For verily, it was a catastrophe than that which naught more shameful has happened in Islam…There happened therein such a foul slaughter as to cause man’s flesh to creep with horror. And again I have dispersed with my long description because ofit’s notoriety, for it is the most lamented of catastrophes.”

KHWAJA MOINUDDIN CHISTI (RA)says

Shah ast Hussain, Badshah ast Hussain,
Deen ast Hussain, Deen Panah ast Hussain,
Sar dad, na dad dast, dar dast-e-yazeed,
Haqaa key binaey La ila ast Hussain
Hussain is the Master, Hussain is the King,
Hussain is Faith, Hussain is Refuge for the Faith,
He gave his head but not his hand in Yazeed’s hand
Hussain is the foundation of La’Illah.

reference : http://wajahatabbas.wordpress.com/2006/02/21/what-is-kerbala-in-the-eye-of-leaders-of-the-world-2/

Seasons Of Life

Life at any time can become difficult.
Life at any time can become easy.

Good or Bad, they are seasons of life.
It all depends upon, how you take on life and adjust to these seasons.

 

reference : http://pravstalk.com

Older Posts »