Skip to main content

Posts

Showing posts from August, 2011

Notes on Castle MonoRail

  Sometime back I was doing a small POC on Castle MonoRail. So here are my quick notes on this. MonoRail is an MVC Framework from Castle inspired by ActionPack. MonoRail enforces separation of concerns with Controller handling application flow, models representing data and View taking care of the presentation logic. To work with MonoRail you need Castle Assemblies. It also utilizes nHibernate You can use Castle MonoRail Project Wizard or create the project manually. Project structure – Content Css Images Controllers HomeController.cs Models Views Home \ index.vm Layouts \ Default.vm ...

Notes on C#–Part - I

1. Covariant and Contravariant? a. Covariant is converting from wider (double) to narrower (float) b. Contravariant is converting from narrower (float) to wider (double) c. Invariant is not able to convert. 2. Immutable Objects are objects whose state cannot be altered externally or internally. 3. In C# 4.0 you can now do the following – If Manager inherits from Employee then IEnumerable<Manager> mgrs = GetManagers(); IEnumerable<Employee> emps = mgrs; This is because CLR now supports defining IEnumerable<out T> This is called Covariance. Next in-case of IComparable IComparable<Employee> empComparer = GetEmployeeComparer(); IComparable<Manager> mgrComparer = empComparer This is because CLR now supports defining IComparable<in T> This is called Contravariant. 4. C# 4.0 now has dynamic built in type. This is not resolved by the compiler but it left for resolution until run time. So C# now supports dynamic late binding. T...

Notes on Multi-Threading

1. System.Threading namespace provides classes and interfaces that enable multithreaded programming. 2. How to initiate new Thread?     a. Create an object of a Thread class        i. Argument should not be null        ii. Should have permission to create thread.        b. Its constructor takes an instance of a ThreadStart Class     c. ThreadStart Class requires the method that needs to be run on new thread.     d. Call the Start method of the thread class to initiate execution on this new thread. 3. Important points on Threading –     a. Thread function can be static or non-static     b. You can have multiple threads with same thread function.     c. You should always assign a name to the thread using its Name property. (This was pointed out to me by Kalyan Krishna. He said it invaluable...