Today I am going to list some of the commands that I use all the time while coding... You can type these commands in the Run Prompt.
1) For Windows Server 2003:
a) tsadmin (Terminal Services Manager) ---> Used to connect to a computer and see who has logged in, to logoff the users.. etc.
b) qwinsta /server:servername ---> to query windows station.
This is a command line tool that I use to see who has logged into a particular machine...
c) rwinsta ID /server:servername ---> Used to logoff an user from a particular server based on the ID.
First get the ID of a particular user using qwinsta and then logoff the user using rqinsta.
d) mstsc -- to launch the remote desktop connection.
e)inetmgr -- to launch IIS
f)devenv -- to lauch visual stuido 2005 and 2008.
g)lusrmgr.msc -- Used for adding a New User or adding a existing user to a group.
h)query --- to query a session etc..
2)Windows Server 2008
The only command that has changed from the windows server 2003 is
a) tsadmin.msc .... now you have to add the .msc extension to launch the Terminal Services Manager..
3)Visual Studio Commands
a) Control + "." to add the usings
b)Control + Alt + "D" --- to view all the breakPoints set in the application
c)Alt + Enter -- to view the properties window
d) Ctrl + Alt + "F" -- to search for some string in the entire solution
e)Ctrl + "F" -- to search for some string in the current file
f) shift + F12 -- to find all the references for a function.
g) Getting VisualStudio CommandPrompt -- Control + W + A
h)Go to LineNumber in code-- > Control + G
i) Open folder in VisualStudio -- > Control + O
j)Go to defition of a fucntion etc - F12
k)Formating Code - Control + K + D
4) windows general shortCuts I use
a) wins..Key + "R" to get the Run prompt.. very use full for me
b) wins..Key + "D" to get to the Desktop
c) Control Panel -- at the Run prompt type .. control
d) Add remove features -- at the Run prompt type control appwiz.cpl
5)VisualStudio Command Prompt --
a)np -- add a new project
b)props - open Properties Window
c)View.SolutionExplorer -- for viewing solution explorer
d) open filename -- to open a file from command prompt
Happy Coding!!!
Yash
Saturday, October 11, 2008
Tuesday, October 7, 2008
Implementing Factory Pattern using Reflection and Singleton Pattern
Today I want to demonstrate how to implement Factory pattern using Reflection...
Important point that should be considered whenever you write code
1) Keep the coupling between components as low as possible --
what this means is when you write components, you should always try to keep the code independent of the other components. It should be testable by itself. It should be reusable without the need of other components.
One of the standard technique that lot of people use to reduce the coupling is by using the Factory Pattern.
Generally use the "new" keyword to instantiate a class, but my doing so we make our code dependent on that object.
Factory pattern separates the creation and initialization of object.
To demonstrate this,
Lets see the class diagram

PS: Please click on the image to see the image contents.
Computer is an abstract base class and different computers like (BrandXComputer or ConcreteComputer) inherit from this interface. Computer as an abstract property called Mhz. Different derived classed will override this property.
Similarly, there is an Abstract class called ComputerFactory, it has an abstract method called "GetFactory". Every class you create will have a corresponding concretefactory class which will return an instance of the corresponding Concrete Computer class. Each concrete factory has a Singleton implementation i.e only one instance of these classes are created. This make sense here as we dont want to instantiate the Factory class everyone.. which will be a wastage of memory.
Alright, till now what we have done is standard factory implementation. It gets interesting when you actually get an instance of the factory. The way this is implemented is through Reflection.
All the concrete factories that you need are kept in the App.Config Files...

PS: Please click on the image to see the image contents.
In the config file bascially we keep all the entries of the concrete factory along with their types i.e class names.
There is one more class which is very important in this whole setup and that class is -- ComputerFactories.
Computer factories has one Static method GetFactory which will take the factoryname (i.e key from the app.config file) , from that it will get the type of the factory and using FieldInfo class it will get that singleton instance we created. Reflection is a very powerful and it has been extensively used in the .Net Base Class Library.
As you can see we, the client code doesnt need to know anything about the Computer Object instantiation or initialization. The code is not tightly coupled.
To download the SourceCode -- Click Here
Happy Programming!!!
Yash
Important point that should be considered whenever you write code
1) Keep the coupling between components as low as possible --
what this means is when you write components, you should always try to keep the code independent of the other components. It should be testable by itself. It should be reusable without the need of other components.
One of the standard technique that lot of people use to reduce the coupling is by using the Factory Pattern.
Generally use the "new" keyword to instantiate a class, but my doing so we make our code dependent on that object.
Factory pattern separates the creation and initialization of object.
To demonstrate this,
Lets see the class diagram

PS: Please click on the image to see the image contents.
Computer is an abstract base class and different computers like (BrandXComputer or ConcreteComputer) inherit from this interface. Computer as an abstract property called Mhz. Different derived classed will override this property.
Similarly, there is an Abstract class called ComputerFactory, it has an abstract method called "GetFactory". Every class you create will have a corresponding concretefactory class which will return an instance of the corresponding Concrete Computer class. Each concrete factory has a Singleton implementation i.e only one instance of these classes are created. This make sense here as we dont want to instantiate the Factory class everyone.. which will be a wastage of memory.
Alright, till now what we have done is standard factory implementation. It gets interesting when you actually get an instance of the factory. The way this is implemented is through Reflection.
All the concrete factories that you need are kept in the App.Config Files...

PS: Please click on the image to see the image contents.
In the config file bascially we keep all the entries of the concrete factory along with their types i.e class names.
There is one more class which is very important in this whole setup and that class is -- ComputerFactories.
Computer factories has one Static method GetFactory which will take the factoryname (i.e key from the app.config file) , from that it will get the type of the factory and using FieldInfo class it will get that singleton instance we created. Reflection is a very powerful and it has been extensively used in the .Net Base Class Library.
As you can see we, the client code doesnt need to know anything about the Computer Object instantiation or initialization. The code is not tightly coupled.
To download the SourceCode -- Click Here
Happy Programming!!!
Yash
Subscribe to:
Posts (Atom)
