Wednesday, October 30, 2013

XtraGrid : Use more specialized event for better code in handlers

DevExpress's XtraGrid is quite a complex beast. It's a library with tons of features and it can be overwhelming to use it optimally at first. So you might get your job done with certain way but overtime you find something new that you didn't notice at first that actually a better way than how you did previously.

That is the case when I just notice that XtraGrid has RowCellClick event that fires on specific cell click. I have been using Click event previously. Click event work just fine, however within it I need to have numbers of code to filter out cases that is not relevant to what I am trying to achieve. On the other hand, RowCellClick already comes with RowCellClickEventArgs with all the relevant info has been nicely parsed for use. The code get much cleaner when I adapt the code from handling Click event to RowCellClick.

So, the lesson is to use the most specific event that fit your case instead of the more general one. It can be a good guideline for using other parts of DevExpress library too. DevExpress components do a lot of inheritance from .Net components and with it inherit lots of pre-defined functions too. So, it has to do some specialization to extend the functions. Hence, it has some functions that is quite similar but slightly specialized.

Springpad + Evernote, Revisited

I wrote about using Springpad and Evernote sometime ago. My use of them since has evolved following the progress of those two services/apps. For example, Springpad note support was quite basic at that time but now it has become quite consistent and enjoyable to use. So, some of my setup has follow suit.

I now use mainly Springpad while Evernote is more for exceptional things like on the cases below :

  • Need things offline
  • Long writing
  • More "sticky" stuff like resources for projects
  • Scans and documents
Springpad has now can fulfill most of my needs. It's better not to have too much tools and have things duplicated so I cut down my Evernote uses. It still an important part of my system though within its scope. As for Springpad, here's ans example of how I use it for :
  • Manage and track media : movies, series, books, games, etc. It is really useful on this
  • Checklists : Springpad checklist support is quite advanced and it's what I have been looking for sometime
  • Project research and resource collection : Springpad has various type of content, not just notes, that makes collecting resources for projects really
  • Random notes, items and collections : for collecting interesting item from either online or offline that has not yet fit anywhere yet. I can search or organizing it easily later on

Friday, October 11, 2013

Visual Studio Deployment Project : Make Single Executable Installer using WinRAR

I wrote a while back of making a single executable installer for Visual Deployment Project (which output two file : setup.exe and setup.msi).  It was done using IExpress that comes with Windows installation itself. However, it feels quite outdated now. Even the page that I refer to in that post is no longer works :). It require some scripting and the use of IExpress is not exactly intuitive nor friendly.

So, comes more straightforward solution using WinRar. I stumbled upon this post on stackoverflow. It basically intend to do the same thing using self-extracthing-archive feature in WinRar. It works much better and more maintainable. It does not require external scripting and you can add logo, title, description for the bootstrapper. I find the resulting installer looks cleaner to run with helpful info/logo.

You can checkout the post above for some description and screenshot (hopefully stackoverflow link is more long-lasting). In summary, the steps are :

  • create New Archive
  • set to SFX mode
  • go to advanced tab
  • click SFX options button
  • customize things to your needs
The rest is about experimenting until you got the setting that suits your needs. After that,  you can save the setting (Tab General -> "Save current settings as default") and later when you create self-extracting-archive it will be done according to your last setup.


Tuesday, October 08, 2013

Note from "The Lean Startup"

I have recently finished reading "The Lean Startup" by Eric Ries. It takes an experimental (as in scientific method of testing hypothesis) approach to make the work more efficient (does not waste valuable time/cost) and efficient (working on the right thing).  It emphasize on the importance of rapid learning and adjustment based on that learning. In this aspect, it seems to use the same foundation of Agile Software Development i.e: make small iterations and adjust/improve process/prediction after each iterations.

Below is summary of the process on Lean Startup:

  • Make leap of faith. Make your hypothesis that you think is true, just make your best guest what will be useful and interesting to user so they will use it. Assume for now that it is true.
  • Develop Minimum Viable Product. Work on smallest possible set of feature that will have significant effect first. The smallness is important for having rapid feedback for learning
  • Validated Learning. Review the reesult of the above using actual/verifiable data
  • Pivots. Decide based on the learning above what is the best course to take next. This could be improving things, discarding things or drop it and do something else entirely
In essence, the process actually useful in many areas of life. Having a rapid feedback can minimize our accumulated errors.

Friday, October 04, 2013

Accurate and Consistent Naming, the simplest yet has the most beneficial discipline in programming

I think if you have to name one discipline that is the most simple but give the most return in term of maintainability, it's probably proper naming. You can do any fancy pattern or coding practice but if you are lazy in maintaining consistent naming of variables, functions, classes, your code will soon rot and unmaintanable. Ironically, it probably the simplest practice to do, especially with powerful capabilities in todays IDE and text editor in doing search/replace and rename-refactoring.

When you don't consistently naming everything properly in your code, you'll obscure your code intention thus making the maintenance hard even for yourself, let alone others. I prefer to write code that I can forget, meaning the code that when I visit it again in the future, it will take the least effort for me to remember what it is that I intent to express with it. Ideally, looking at the naming, structure and perhaps some external notes and diagram should be enough for  us get an understanding into the code again.

There is now a lot of guideline how to do consistent and proper in naming in codes. There might also some variation of guidelines between  languages, framework, platform. Whatever standard you use, any naming guideline/standard is better than none, I guess. Do yourself, and others, a favor and properly and consistently naming things on the code.

Thursday, October 03, 2013

xUnit : Low Cost/Commitment Unit Testing

I have been having love/hate relationship with Unit Testing so far. I understand the need and rationale behind it and often times I even enjoy doing it and makes programming more fun. However, when the tests has hit certain large  numbers and you accumulated significant cases where it just hard, if not impossible, to test (despite decoupling the code heavily and usage of patterns in high-dose), unit tests becomes a chore and annoying burden to maintain. You start to question yourself it's worth the trouble and should you just going forward without TDD.

I find the test framework that I use is a significant factor whether I keep unit-test the code. Having found xUnit sometime ago, I can now say again unit testing is functional, useful and fun again. Unit tests is support/driving activity of the main activity (coding), so the simplest possible support code/framework is the way to go.  xUnit has minimal "accessories" which make writing test code quick and straightforward. So far, it fits my need of unit test framework. For example, it get rid of Setup and Teardown and use very minimal set of attributes.

One important thing, psychologically for me, of having simple unit test framework is it makes my attachment to my unit tests relatively low. This means I can throw away, rewrite, change my unit test anytime and anyway I want with very minimal guilt. I can throw away large number of any unit tests that no longer serve any purpose and start over with the tests progressively. I can do architectural level changes with more freedom without unit test maintenance becoming too much of a burden. My focus now back to the main logic of program with unit test to support it.

Of course, at some level, unit test framework can be very personal choice like choices of your favorite text editors or OS. Personally, I like xUnit for my (.Net) testing framework. If you have been throwing unit testing from your development arsenal lately, you might want to try xUnit and see if it can interest you to get back to unit testing your code again.

Wednesday, October 02, 2013

Free solution for .Net Profiler : Slimtune

When it comes to profiling and performance tuning of application for .Net application, the proprietary solution can be quite expensive. However, I stumble upon SlimTune recently. It's a free .Net profiler and I find it quite sufficient for common profiling needs.



If you just interested to see your application performance hotspot, it already does that quite well. It's not fancy, sure, and the GUI need getting used to initially, but it does it's job fine. I can spot and tune the performance issue quickly with it.