Skip to main content

Featured

Ruby Tips - How to figure out where a method is defined

The other day when I was dabbling with the huge codebase, I was wondering where a particular method was being declared for a specific method. I wanted to know this because my greps didn't turn out to volatile and didn't return any results



The Solution The Ruby interpreter has certain methods that can be used for identifying under which module or class, the particular method is being defined. See the example below.

So using the .source_location you will be able to figure which file it has been declared.

Finding whether its Design Mode or Runtime Mode in VB.NET

Sometimes, while creating controls, either by Inherited Controls or UserControls, we will be required to skip a piece of code depending upon the design time or runtime mode. This can be done easily by the following code inside a control.









If Me.Site IsNot Nothing AndAlso Me.Site.DesignMode = True Then
    'Designtime code here
Else
    'Runtime code here
End If


Using this code in a control, we can find the mode and avoid certain errors when in Design Mode. This is mostly used in overridden event methods in Inherited Controls.

Comments

Popular Posts

You will receive wonderful short stories written by him and inspirational articles once every month.