Keep Code Statements Simple

I don’t count my progress by the line of codes but at the same time I don’t take pride by over engineering a solution. Writing code is like writing for a publication, you have to know at what reading level you are writing for. That said, the one type of code statement that gets under my skin is what I call the run-on code statement. A Run-on code statement is one that has multiple method calls in one statement. Here is a made up example of a run-on code statement.

DataManager.getInstance().refreshData(obj.getAsInteger().toString());

In the above run-on code statement there are four method calls. I’ve seen worse. The reason whey run-on code statements are a pet peeve or mine is that if anyone method call fails because of a NullPointerException or some other error it’s difficult to quickly know what segment of the code statement failed. This is also annoying to debug if you want to step into one method out of the four.


2 Responses to “Keep Code Statements Simple”

  • Code optimisation « Coder buddy Says:

    […] Keep Code Statements Simple (juixe.com) LD_AddCustomAttr("AdOpt", "1"); LD_AddCustomAttr("Origin", "other"); LD_AddCustomAttr("theme_bg", "ffffff"); LD_AddCustomAttr("theme_text", "666666"); LD_AddCustomAttr("theme_link", "2089cc"); LD_AddCustomAttr("theme_border", "282828"); LD_AddCustomAttr("theme_url", "e2415b"); LD_AddCustomAttr("LangId", "1"); LD_AddCustomAttr("Autotag", "technology"); LD_AddCustomAttr("Tag", "c-net"); LD_AddCustomAttr("Tag", "c-net-code"); LD_AddCustomAttr("Tag", "code-readability"); LD_AddCustomAttr("Tag", "microsoft-visual-studio"); LD_AddCustomAttr("Tag", "program-optimization"); LD_AddSlot("wpcom_below_post"); LD_GetBids(); Share this:FacebookTwitterStumbleUponDiggMoreRedditEmailPrintLike this:LikeBe the first to like this post. […]

  • Year In Review 2011 Says:

    […] Run-on Code Statement […]

Leave a Reply