General Thoughts


30
Jan 12

Html.Partial vs Html.RenderPartial in ASP.NET MVC

Both functions used for rendering the partial view and use same logic to render the partial view, but their fundamental difference is in their return type.

@Html.RenderPartial returns void and that’s why its require following syntax. Html.RenderPartial output their content into the same TextWriter object as used in the current template. This is more efficient, because the view content is not buffered in memory.

@{
Html.RenderPartial("TestPartialView1");
}

Where Html.Partial return MvcHtmlString which you can keep in any variable for latter use. That’s why it require following syntax.


@Html.Partial("TestPartialView1")


19
Sep 11

Unusual but Achievable: Running 0 to 10K in 60 days

First of all it’s not difficult, if you are actively involved in some level of sports or other physical activity.

My background

My profession does not facilitate me to do any physical activity nor I was involved any kind of games in my life time. Before running I usually walk (3-4K) as exercise for few times in month.

How I started

My wrist size was increasing and it makes me worried, so I started doing walk in morning almost 2-3 days in a week. To cover 3-4K walk I have to spend around 1 hour.

First Month

I want some quick exercise, so I have started jogging. First few days was difficult.  Running was quicker so I keep running every day. After two weeks I started enjoying the whole process. Listening music while running was also great feel. I started  increasing distance and within one month I was able to complete around 3K.  I had a great feeling about my progress.

Second Month

I thought now I should have some target and practice it with some schedule.I discovered http://www.halhigdon.com/ and selected training for your first 10-K.

I never follow this because my schedule of going for running based upon lots of things. Having day job, father of a 2 year old daughter and staying with parents; all these does not allow me to follow the schedule.

But one thing was very clear from schedule that, if I have to do long run than only running will not going to help me. I have to do other exercises as well. So I created my own schedule according to my need. My schedule was 1) Having less time – Lets do some Stretch & strength through body weight or try to run 3-4 200m sprints.  2) Miss  – don’t worry today is a break ;) . 2) Enough time, do complete running with Stretch.  Idea was -  “keep going.

Every time I go for running I try to increasing my distance by 200-500 meter. After around one month I have reached the level of 10K though timing was not so great but who cares at this level (10K in 1 hour 6 mins). As a side effect I have loose around 5Kg weight and improved eating habits because it helps me in running.

Why running

It require nothing. You just need a pair of shoes and that’s it. You don’t need training, expensive gym membership, people etc. Except rain in morning there is no problem . There is no age  sex bar.

Running on treadmill

I have tried treadmill at gym for couple of days and believe me it sucks big time. 1) Its boring; running on same place every day is not going to motivate you for long distance running. Running on ground or on road keeps your mind engages with activity surround you. 2) It will not as effective as running on ground because your base is moving through motor and it makes running less effective. 3) Cannot enjoy morning freshness at gym.

Things you need for running

1. Shoe

I used basic nike jogger and I don’t think anybody need any expensive shoes until they are professional runner  So far I am not facing any problem with related to my shoes.

2. Body outfit

I used adidas running shorts and believe me these running shorts are worth. Before that I used normal shorts which have two side pockets and it was uncomfortable to keep your cell phone and keys in side pocket while running. Running shorts are design for running so they fit and there is only one small pocket with zip on the backside for cell phone and other small stuff.

3. Music

Initially I used music while running; latter I discovered running without music is more employable. Running without music helps me to think about various tasks. This whole blog post I have thought while running.

4. Running Track

Park where I run in morning having cemented 1400 meter track as well as 1600 meter grass track. I use grass track.

5. Time

Now as I am running 10K and I have to spend around 1.5 hours on park. I have changed couple of things in my lifestyle a) I Try to sleep on same time very night between 9:30 – 10:30. b) I have cut down all the time waste activity.
To satisfy both the condition I have stopped watching TV. Also promote my family members not to watch TV after 9pm. It works very well. It helps to go for sleep on same time. Second I get more time in my life to do running and spend with my family.

I try not to miss a single day. Some time when I have no time for running I just go to park run one 200 meter sprint and come back to home. It give me a feeling o f get going and not stopped.

I have read somewhere

If you miss today there is highly chance that you miss next day as well.


26
May 11

VSS to Mercurial

Note: I was using VSS around 2 year back and move to mercurial when i have started my own company. Few days back I had discussion with one one of my ex colleague who is still using VSS and does not feel they required to move to new source control. This blog post is all about the discussion I had with him about VSS, distributed source control especially mercurial (because I am using it) and people who are not using any source control.

Why to use source control

Do you know “The Joel Test” – The first requirement of good software development is source control. If you or your company are not using it then change that; either company or way of work.

Now a days people don’t ask “do you use source control?”. They ask which all source controls you have used so far and what is your workflow.

Some people argue that I am alone developer and I take backup every night to my code (through some automated system or manual) and I don’t need source control complexity in my life. This project can be in your organization or your pet project in your free time.

My argument is; any serious source code should be in source control otherwise it is not serious. Backup is not primary reason to use source control it is a bi product of using source control.

Around two year back we used VSS as a source control. Its seems nice because I never used any other source control system. I heard about CVS, SVN etc but never get chance to using it. VSS had lots of problems like

  • It damage often. Once In past we even lose all the history from VSS due to damage.
  • Lock – VSS work on lock mechanism; where developer have to locked the file before start the work. So developer have to keep in mind before doing any changes with the code base. In locking mechanism no two developer can work on the same file at same time. There are lots of time when developer goes on leave and he locked couple of file in VSS.
  • Over internet VSS (Till the time i used) is not reliable. We use paid third party plugin to use VSS over the internet.
  • VSS required IT guy to manage the server.

When I have started in new organization, one of the first few things which I required is source control. My wish list for source control was

  • Free or less license fee
  • Reliable
  • Easy manageable (Till date we don;t have any server administrator guy.)
  • Work well on over the internet.
  • Good support on windows.
  • Reliable hosted solution.

I had couple of options a) SVN, b) Git (A big buzz word in source control due to github) c) mercurial.

All above are free and open source. github.com (for git) and bitbucket.org (for mercurial) was my favorite one because of distributed source control buzzword. After little bit of research I found that mercurial have better support on windows, bitbucket.org have option to create free account with private repository for life time and 5 users allowed with free account.

So I have decided to use mercurial because

Using distributed source control require only mental shift from client server source control system and that shift is really worth.

In distributed source control every developer holds complete repository on his local machine. so every time developer commit any change it commit on his local repository. Once he finish his changes then he push his changes to other repository. Because every developer holds copy of repository on his machine it gives following advantage.

  • Speed -It makes day to day task very speedy because it holds complete repository on his had drive and there are no network latency. He required network only for pull or push the changes form other repository. So It can be used online and offline. Distributed source control was design with the mind set that developer not necessary connected to internet/internet every time.
  • Separation of work by branching and merging - Branching is another reason to use mercurial. I never use SVN and there are no concept of branching in VSS. Consider the scenario- You and your team have just release the code base to QA and then you have start working on future version of app and same time QA is raising bugs. I don’t know about the SVN but in VSS handling these type of situation is not possible. In VSS days we all are not allowed to write new code until QA have finished all the testing and there are no more bugs. Once everything is fixed we label the codebase in VSS and start working on new version. In mercurial we create new branch and start working on new version with other team mates. If QA raised any bug we simply switch to main branch and fix the bugs. Once QA done with testing we marge newly created branch with main branch. Switching between branch in mercurial is super easy and pain less.
  • Reliability – Due to distributed nature it really hard to destroy. As each developer machine have complete repository creating new centerlize repository is pretty easy.
  • Easy to learn – I have started using mercurial after 2 hour of learning.
  • Collaborative – Distributed source control allows developer to communicate directly without affecting the central server.

Only mental shift you require while working with team in organization is; you need to have one centralize repository. Every team member will pull or push changes from centralize repository when they are ready to. It don’t mean that you can’t pull or push changes with your team mate. Centralize repository will don’t have working directory because nobody will going to work on centralize server. Every team member will only push his latest finish changes to centralize server and take latest changes from centralize server. Just as we do with VSS or SVN . So distributed source control have all the advantage as client/server source control with addition to speed, reliability and high level of celebration with other team mate without affecting the central server.

Our setup

We have pretty simple setup. Every developer machine have configured a free account of dropbox (2 GB is so far sufficient for source code backup). We use bitbucket.org as a central repository. Every developer have it own repository and working directory in dropbox folder.

Resource

I have used http://hgbook.red-bean.com/ for mercurial.

http://hginit.com/ is also a nice tutorial about mercurial and distributed source control.


29
Sep 10

What we can learn from Babies.

Image by kretyen

Image by Kretyen

Being as a parent I closely notice each and every movement of my daughter and i found that there are some fundamental differences between our lifestyle and lifestyle of my daughter.

1. Baby doesn’t stay ideal on bed.
As far as I know babies they don’t stay ideal on bed. As soon as they wake up they start crawling or walking. Every time my daughter wake up she start making movement towards to door or start playing  with toys around her.

Opposite to her some time I wake up but stay on bed lying ideal and lazy. It’s totally wastage of time. Every time I regret it whenever this happened to me, but at least once in month this happened to me.

2.    Touch the world

Yes, go and check with any baby around you. Babies don’t sit ideal on the front for TV and Internet and kill their time. Babies want to touch, see, and feel each and everything which they can feel through their senses.

Oppose to this we adult sit on the front of TV and internet and waist hours and hours.

3.    Everything is new.
This is killer one. For babies everything is new. Whenever my daughter goes to any place she starts staring everything with open mouth. I analyze this with other babies as well their behaviour is also more or less same.

We also have same behaviour but due to repeatable life style we are not in situation to watch new things in our life. As we grow with repeatable life style we start fearing with change and stop learning new things.

Bottom line is babies ability to explore and experiment make them different from us (adults). As we get older, we start making decisions based on what we know & works, and we stop exploring and experimenting.

See the video – Remember when you were a kid



22
Aug 10

Talent vs Attitude – Harsha Bhogle

I just watched this video where Harsha Bhogle argues that attitude is more important than talent (~4 min talk).

I am pretty convincing that attitude that actually creates the difference and attitude is all about your love and passion about that work which we do.

So, if we do what we love to do, will increase our success rate as well as we don’t feel like doing hard work.

Even if you look around in your office, family or friends that there are lots of people who are talented i.e. have better IQ, score better at their colleges but not have as much as successful as much as people with bit lower latent but have better attitude towards work.

To test this case there is only one ideal scenario we have with is we.

Just compare yourself with your past (5-10 years back) and you will find you are better with skills where you worked harder and if it’s your desired or lovable skills then your loves towards your work was definitely  increased, right?