Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Tuesday, July 23, 2013

The bane of being a polyglot developer

In the recent months, there has been a bitter realization for me as I have given quite a few interviews as I was looking for a job. My resume was decorated with most of what I have been doing as part of my earlier job as well as what I did in my spare time. However where I failed were the areas that require mugging up the most. Consider the following questions:
  • What is the difference between get and load methods in hibernate?
  • What are the different active record validations?
  • What are the different types of active resource nesting?
  • What is different between event handling and event bubbling?
Answers to these are no far than a google search or documentation lookup away but in all these questions, I wore a blank look. The first one was a hibernate question and after searching for answers, I came to know that it was actually one of the most popular hibernate interview questions. The other two were rails questions, but since I have done very little professional ruby work, I could not explain the same. The last one was a jQuery killer, appearing after I had rated myself 5/10 in javascript and was again nothing, but technology buzzword.

Very few interviewers were interested in asking something challenging questions in scalability, design pattern or architectural issues. This really leaves me angry at recruiters only looking to fill up position involving technology X people and also at myself at allowing myself to stray. The real trouble that I feel is that I am maybe easily persuaded. I started with java, then moved over to j2ee and for a time felt that I had nailed it when I finally deployed a ejb 2.0 environment. However, then came spring and hibernate and I felt that they were the actual mecca and medina for me. However, later on I was sucked by the very vocal ruby community that said, 'wait a minute, you a java guy, we can make you 10X productive'. Duh!
Then came a string of languages, python, .net, scala, f# and whatever the titbits that I had left - from playing with arduinos at home to mainframes at work (and I still harbor desire to purchase a raspberry pi one day and do more cool hacks on it).
However, these plethora of languages and technologies have taken a trool on my confidence, especially when I come across people who only know or like a single technology and are comfortable in it.
But that's not for me as I thrive on change. For example I am writing this rant after 10 pm and today I've:
  • studied redis in the morning
  • tried to implement a scalable solution on redis to handel >10 million records
  • did AdWords and facebook api integration into a rails4 app in office in the day
  • will be writing/improving the draft chapters of the upcoming book that I am writing in robot framework.
I think Steve yegge captures some of my deficiencies clearly as I am an advance learner in a lot of technology that I have on my resume, and I guess that's the way it is going to be in the near future.

Wednesday, June 5, 2013

Musings on refactoring



I happened to be across the refactoring in ruby book, which is the
adoption of the refactorings book by fowler from java into ruby. On
reading, one thing which strikes you is the fact that refactoring is persistent across languages and platforms. Java is verbose and allows various coding styles and idiosyncrasies which is evident why lot of java programmers churn
out code that is unnecessarily complex. The proliferation of IDEs has also encouraged this malpractice of creating not just sub-optimal but also unnecessarily complex code.

However, finding the same in ruby has traditionally been difficult as ruby, like its japanese inventor has been neat and concise in its apporach, allowing basically for a lot of bang for a small amount of code. However, as the community grows, there is an acute need to maintain the standards in ruby as well as the developer base is exploding exponentially in ruby. In my opinion, refactoring is a practice that every developer needs to apply and enforce amongst their team as a cardinal rule in programming. Applying this context in the updated refactorings book, I feel while using ruby the answers have become more to the point, but at the cost of grossly sloppy code. It could have better demonstrated in a language that is equally neat and offers variety like java. Python obviously springs into mind where at one place there is a C like procedural code and at the other end there are python experts proclaiming the use of pythonic code.

Having the same refactoring into another language feels alien for a while, but then it is a bliss to realize that same problem existed into another language as well, it was just that a learner like me got carried away in the syntactic differences.

At the end of the day, it is the learner who needs to decide what to and more importantly what not to include in the changes to be made in the codebase.

Wednesday, October 31, 2012

An insight into sonar plugin development


In the recent months, I've been involved in developing a language plugin for sonar that displays different metrics for a specified language. I am writing this post as there is not much content available for this topic even when sonar is a widely popular tool.

Below are tips to avoid some of the common pitfalls in developing sonar:
  • Read the official documentation carefully, even when there isn't much of it.
  • Download the sources of all the open source plugins and try looking their code for proper understanding into plugin development.
  • Do read books available on the topic in addition to the blogs for proper understanding.
  • Use maven, this is a real lifesaver and focus on TDD while coding - as you cannot hope to debug the process otherwise.

If you've followed these steps diligently,  you'd have a basic understanding on the innards of sonar plugin development.
In very brief words, a sonar plugin comprises of a java based program that performs the heavy duty work of loading/populating the code metrics and a ruby based UI (embedded ruby pages(erb)) that helps in displaying of this data, in a nice manner and also uses view helpers to create eye-catching widgets that display these data. There is another provision for a complete rails based application to be created in place of this, but that's a different idea altogether.







In my case, I needed to Populate the data from a database , so in a class implementing Sensor interface, following method was present

  public void analyse(Project project, SensorContext sensorContext)
Inside this method, I can use Project object to read from project properties,etc as inputs to my process and SensorContext object as output in the form of  measures;

sensorContext.saveMeasure(new Measure(MyMetricAnalysisClass.MetricName, Double.valueOf(metricVal)));

One of the nice features of working with erb templates in the UI for widgets is that you can use a lot of helper methods to create slick effects with your data. One such example is a piechart:
<%= piechart( 'Field1 = '+var1.to_s+'; Field2 = '+var2.to_s+';'  , { :size => "500x200"}) -%>

One caveat present while transferring the data from server to views is that only text data works well, the information about using data structures is sketchy at best so we are left with using the data delimimted with ';' (See the first argument in piechart helper method above). Surprisingly, other data cause widgets to fail with no descriptive error messages. For larger data, it is more intuitive to use a GWT page instead of a widget as the users can focus more on the details provided in the page as opposed to the concise totals present on the widgets.
Hope this post helps the users developing plugins on this platform something to get started with.