Short vs. Long variable names
For a long time, I haven’t written any post. I was a looking for a good topic. Now I came across a post by Isaac Schlueter in “YCombinator”. So thought of sharing it.
There’s a lot of “short vs long” going on in the comments here. That seems silly to me.Code should be written so as to completely describe the program’s functionality to human readers, and only incidentally to be interpreted by computers. We have a hard time remembering short names for a long time, and we have a hard time looking at long names over and over again in a row. Additionally, short names carry a higher likelihood of collisions (since the search space is smaller), but are easier to “hold onto” for short periods of reading.
Thus, our conventions for naming things should take into consideration the limitations of the human brain. The length of a variable’s name should be proportional to the distance between its definition and its use, and inversely proportional to its frequency of use.
Global config setting that gets specified once and used in 4 places throughout the program? 10-20 characters is probably appropriate. Might wanna go with UPPER_SNAKE_CASE to make it stand out a bit more, even.
Iterator variable that you define in a 3-line for loop and then never see again outside of it? Call it “i”.
Another way to look at this: The first time you meet someone, you learn their full name. When discussing them with someone else who knows them, you use just a single name. If they’re standing right there, you don’t bother using their name, but just make eye contact, and maybe a “Hey”. Should be the same way with variables.
Read the full post and reader comments in “http://news.ycombinator.com/item?id=840331“
Happy Reading!!
Back again after a year
I was busy working with a Project and was not able to update the blog for around one year.
As I am returning back, I have updated the wordpress template for the site. The WordPress look and feel has been changed and I have seen a lot of changes in other sites also including Joel On Software.
Let us see how much I can write this year
Happy Coding…
NewsGator RSS tools are free now
I love Google Reader, but I love NewsGator FeedDemon, because of its online/offline synchronization feature.
Most of the RSS products of NewsGator are available for free now.
The Next Big Programming Idiom
We were talking about ”MapReduce, Functional Programming, Lisp” in my previous post. The question is the next big programming idiom.
In a post titled The Next Big Programming Idiom, Peter discussing this issue.
I’m not asking here which language will be the next popular language, but what programming style will be popular. Will functional programming make a comeback? Will OOP refuse to die? Or will it be something we haven’t seen before?
-Happy Reading,
Nubie
MapReduce, Functional Programming, Lisp
I have been hearing about functional programming these days.
In an article titled “Can Your Programming Language Do This?” Joel discusses about the MapReduce algorithm which makes Google so massively scalable.
According to Google,
MapReduce: Simplified Data Processing on Large Clusters
Jeffrey Dean and Sanjay GhemawatAbstract
MapReduce is a programming model and an associated implementation for processing and generating large data sets. Users specify a map function that processes a key/value pair to generate a set of intermediate key/value pairs, and a reduce function that merges all intermediate values associated with the same intermediate key. Many real world tasks are expressible in this model, as shown in the paper.
Programs written in this functional style are automatically parallelized and executed on a large cluster of commodity machines. The run-time system takes care of the details of partitioning the input data, scheduling the program’s execution across a set of machines, handling machine failures, and managing the required inter-machine communication. This allows programmers without any experience with parallel and distributed systems to easily utilize the resources of a large distributed system.
Our implementation of MapReduce runs on a large cluster of commodity machines and is highly scalable: a typical MapReduce computation processes many terabytes of data on thousands of machines. Programmers find the system easy to use: hundreds of MapReduce programs have been implemented and upwards of one thousand MapReduce jobs are executed on Google’s clusters every day.
But MapReduce can be implemented only using Functional Programming languages. Did I say “only”?? But how they implemented MapReduce in Google using C++?
Joel continues…
Without understanding functional programming, you can’t invent MapReduce, the algorithm that makes Google so massively scalable. The terms Map and Reduce come from Lisp and functional programming. MapReduce is, in retrospect, obvious to anyone who remembers from their 6.001-equivalent programming class that purely functional programs have no side effects and are thus trivially parallelizable. The very fact that Google invented MapReduce, and Microsoft didn’t, says something about why Microsoft is still playing catch up trying to get basic search features to work, while Google has moved on to the next problem: building Skynet^H^H^H^H^H^H the world’s largest massively parallel supercomputer. I don’t think Microsoft completely understands just how far behind they are on that wave.
The moral of the story is that there is a lot of interest towards functional programming. Many functional programming languages are getting attention. Some popular languages are Erlang, Microsoft F#, Haskell.
But the real hero among these languages is Lisp. Lisp is a programmable programming language which can support functional and object oriented programming. Read The Truth About Lisp by Secret Geek and Why Isn’t Everyone Using Lisp? by Peter.
-Happy coding
Manual Software Factories
Microsoft has coined the word software factories to describe the concept of creating a customizable and extensible baseline architecture for a project to start on.
They are expecting to leverage the domain expertise and experience of senior developers by creating software factories. The software factory is a software development tool that can automate a software solution addressing a well known and described specific problem. To know more on software factories, visit: Building software factories
Be sure to read the above post before make a decision on creating a software factory. Then get Software Factory Toolkit from clarius consulting.
A medium sized company can make the software factory concept without automating it if they feel it will be costly. They can set up a team of architects, senior software engineers, and domain expertees. This team will create an initial platform for all the projects in their company. So the developers can build onthis baseline architecture. Gradually this will create a feeling of re-usable components and many of the components can be reused in the next project. Then they can automate the creationof solution and reusable components.
I don’t know whether this is a good idea or not. Nor I don’t know whether this kind of practice already exists in software industry. Sorry if I posted anything wrong
-Happy Coding
IDs versus GUIDs
This week, I was trying to understand the architecture of Windows Workflow Foundation (WF). In most of the sample programs I saw, they have used WorkflowInstanceId (a Guid) as the primary key in the database. The main reason being the use of instance id in Passivation (Passivation is the term WF is using to describe the process of moving idle workflow instances to persisent storage medium like database so that the program need not be in memory while waiting for some external stimulus like user input or input from other programs). They need to know the instance id to get the program back to memory.
During that time I had situation where I need to get the data from database based on the primary key. What about writing a query statement with a where clause like “where userid=’{BAE7DF4-DDF-3RG-5TY3E3RF456AS10}’”?. It’s difficult to write like that. So I did a search to know whether I should use Guid or integer key as primary key.
No need to search it any more. Find the Coding Horror article on Primary Keys: IDs versus GUIDs
-Nubie
How much of your application is managed?
Does a solution written for Microsoft .NET have to be 100% .NET? Scott Hanselman looks at how hybrid managed-unmanaged solutions are really the norm.
Read his article that exposes the myth of .NET Purity on MSDN
The Windows platform has dozens and dozens of high-level system services exposed by literally thousands of APIs. This large library of functionality encompasses various levels of richness. A low-level API may open a file off a disk, while a high-level one might play an audio file. The designers of the .NET Framework wanted to create a consistent object-oriented face on a rich legacy of platform functionality. The CLR and .NET Framework work together to expose the capabilities within the Windows platform, including those that may have previously been hidden away in difficult or little known APIs.

