Posts

As Java Programmer, "Where has C# been when I was programming In Java "?

As a certified Java programmer I have been living in the Object world maintaining my states, favoring composition over inheritance and using design patterns until multicore CPU's came into the market. You maybe asking why did multicore cpus disrupt my object oriented world? Here is why -  It's time to get good at functional programming . The main thing in the article is the parallelism of functional programming to take advantage of those multi core cpus. Variables and data in functions will not have the side effects (deadlocks, race conditions) that we see in an object oriented language like java because functions only depends on inputs and not on any global state (translation - they only have local variables which is always thread safe).  So how does this relate to C# ? Well the designers of the C# language was heavily influenced by Haskell (functional programming language.  Erik Meijer  worked on LINQ in C#).  I am liking, favoring and talking about C# because of this (eve

MyBatis Multiple Query Parameters - property of an Object Type

MyBatis Multiple Parameters I have been using ibatis (now mybatis) for quite sometime now. It is really quite a powerful ORM. It has come a long way and there are a lot if improvements from the xml configuration based version to the new annotations. Here are some things that i like the most: 1. the SQL builder class ( SQL Builder Class )     I was looking at other ways to use SQL in my projects like JOOQ ( JOOQ DSL ) because it offers generating SQL via typesafe way using DSL. I am so glad that myBatis has this typesafe way of creating SQL too. 2. the typeHandler - you never know when you are going to need one specially in java type to jdbc type conversions. For example time formats ( joda-time ) 3. the provider annotations (InsertProvider, SelectProvider, etc..) - gives you a flexible way of generating your SQL statements dynamically. Recently used a 'MERGE' statement in Oracle. I wonder if i could have used that with JOOQ ? 4. the SQL statement parameters - Did

Recursion and Sort - should be asked everytime

I am surprised with my new manager because he is so technical (He can code). He is trying to come up with interview coding questions to test candidates and has asked me to look at it. If I don't know any better he is trying to test me too. I did an interview with coding questions before and most of the questions that i have encountered are mostly about recursion and sort. Recursion and sort questions are very reasonable to ask a candidate who is going to code because recursion and sort  will be mostly all over any code base. So when my manager asked me to look at his coding test in the back of my mind i would suggest a question about recursion and sort. When i was preparing myself for such an interview (the one with a coding question) I have found this  http://codingbat.com/  as a great place for practice..much like crossword puzzle.  After trying a few questions at codingbat.com , I thought i can come up with questions like that too. Here is a sample question that i came up

AMD - totally unrelated to processors

AMD  I have used javascript a lot and still can not fathom the messy selectors and callbacks. Being a part of a team that probably has millions of javascript code scattered in every page (before the rise of the SPAs (single page applications)) it is a real pain, not to mention dealing with browser support (don't get me started on this). I try to minimize my involvement in having to deal with javascript issues. But javascript tools are getting better thanks to  Chrome, FireBug and now WebStorm  javascript is now becoming a language of choice for web development. Javascript filled the gap of a much more responsive web ui. It vanquished having to wait for a response from  a web server. This responsiveness is now being utilized in mobile development as well. There is a lot happening in the javascript world Node.js, D3 just to mention a few and a lot more will happen. As javascript becomes a necessary tool in any software development, patterns and best practices emerges that ad

JAXBContext - ClassCastException

I was recently working with REST like APIs (e.g. text/xml content type response from a web request). In order to consume or use the response i need to parse the xml response .We usually use an ordinary STaX ( SAX Vs. STAX ) parser because it performs really well and we usually parse really huge XML files that contains thousands of elements. In the API that i am consuming the XML is really small about ~10 elements. So i decided to use JAXB (comes standard with Java 1.6) because XML is really small and I have to display the result of the service to a UI. After creating my javabeans ( javabeans ) and annotating it with JAXB. I initialized my jaxbContext this way (Code 1.1) and tried unmarshalling an xml. As you notice below i have the same root element for Foo and Bar xml . This is causing the JAXBContext to parse the Foo xml to a Bar class that is why i get a ClassCastException. I have to change the root elements for the xml and the JAXB @XMLRootElement annotation as well so that i

APE: Author Publisher Entrepeneur -- the Author

APE - Author Publisher Entrepreneur  APE Website I will be reviewing, commenting and sharing my feelings about the book. My plan is to read each section of the book [Author, Publisher, Entrepreneur] and posts my review on this blog. Author - The first seven chapters deals with the realities of what an author faces trying to publish a book.This is the section that help you answer the question "Should i write a book ?". If after reading this section and you answer is still yes, then it gives you a little bit of guidance on how to start things off. [The Art of the Start - Guy Kawasaki]. I liked that the authors pointed out the mountain that you have to face publishing a book the traditional way because it takes away the fantasy that once you are done writing your manuscript you are on your way to selling a bestseller.The authors also pointed out how self-publishing can start a revolution that everybody can publish a book. Everybody can be an author as long as you are wil

Hadoop - a Big Data Sneak Peek (part 2)

Image
Here is the next installment for Hadoop. I hope this gives you an idea of what HDFS and MapReduce in Hadoop is. Please leave a comment if you find this useful. HDFS Architecture The diagram below shows the main components for the Hadoop File System (HDFS). Name Node - This is the central piece of HDFS. The Name Node tracks all the  file system's metadata (e.g. directory tree of all files, where the file is kept in the cluster). It does not store the data itself. The Name Node is the SPOF (Single Point of Failure in HDFS). Here is a link to a more detailed definition -> NameNode Secondary Name Node - optional component of the HDFS. Creates checkpoints of the namespaces Data Node - Stores data in large blocks in the filesystem. Reports the blocks of data it holds to the Name Node. MapReduce MapReduce is a programming model on a distributed processing platform that is scalable. It is actually as three step process. 1. Map - this steps creates a map (key-val