Sunday, September 4, 2011

Other Acronym's

YAGNI - You Ain't Gonna Need It
means don't add functionality that you don't need.

DRY - Do not Repeat Yourself
means don't copy and paste the same bunch of code, try to abstract it out.

KISS - Keep it simple, Stupid!
simplicity should the key goal in design and unnecessary complexity should be kept out.

what is SOLID?

SOLID is OOP Principle terminology/acronym. It stands for the below

S - Single Responsibility Principle (SRP)
O - Open/Closed Principle (OCP)
L - Liskov Substitution Principle (LSP)
I - Interface Segregation Principle (ISP)
D - Dependency Inversion Principle (DIP)

S/SRP means a class should be responsible for one task/objective
O/OCP means software entities should be open for extension and closed for modification
L/LSP means objects in a program should be replaceable with sub-types without breaking the program
I/ISP means many client specific interfaces are better than one general interface
D/DIP means Depend on abstractions and not on concretions/implementations [Dependency Injection]

Monday, March 14, 2011

How to register custom user controls in Web.Config

Let's say you have a Custom User Control (Test.ascx) that you want to register, but you dont want to register on each and every page. There are multiple ways of doing:

1. You can register in Master page, then any page that inherits the master page, can reference the User Control. That way you only need to register once and use anywhere/any-page you want.

2. If you dont have a Master page (which was my case, in the application I have working). You can register in web.config and use it anywhere/any-page you want. Configuring in web.config also helps when you have multiple master pages.

To configure custom user controls in Web.config, just add a new element under <pages><controls>

Example:

<system.web>
<pages>
<controls>
<add tagPrefix="UC" src"~/Controls/Test.ascx" tagName="Controls" />
</controls>
</pages>
</system.web>

Once registered, you can use it on every page. Going with the example above,

<UC:Controls ID="Test1" runat="server" />