Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 41305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:09:36+00:00 2026-05-10T15:09:36+00:00

I really enjoyed Jeff’s post on Spartan Programming . I agree that code like

  • 0

I really enjoyed Jeff’s post on Spartan Programming. I agree that code like that is a joy to read. Unfortunately, I’m not so sure it would necessarily be a joy to work with.

For years I have read about and adhered to the ‘one-expression-per-line’ practice. I have fought the good fight and held my ground when many programming books countered this advice with example code like:

while (bytes = read(...)) {    ... }  while (GetMessage(...)) {    ... } 

Recently, I’ve advocated one expression per line for more practical reasons – debugging and production support. Getting a log file from production that claims a NullPointer exception at ‘line 65’ which reads:

ObjectA a = getTheUser(session.getState().getAccount().getAccountNumber()); 

is frustrating and entirely avoidable. Short of grabbing an expert with the code that can choose the ‘most likely’ object that was null … this is a real practical pain.

One expression per line also helps out quite a bit while stepping through code. I practice this with the assumption that most modern compilers can optimize away all the superfluous temp objects I’ve just created …

I try to be neat – but cluttering my code with explicit objects sure feels laborious at times. It does not generally make the code easier to browse – but it really has come in handy when tracing things down in production or stepping through my or someone else’s code.

What style do you advocate and can you rationalize it in a practical sense?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:09:36+00:00Added an answer on May 10, 2026 at 3:09 pm

    In The Pragmatic Programmer Hunt and Thomas talk about a study they term the Law of Demeter and it focuses on the coupling of functions to modules other than there own. By allowing a function to never reach a 3rd level in it’s coupling you significantly reduce the number of errors and increase the maintainability of the code.

    So:

    ObjectA a = getTheUser(session.getState().getAccount().getAccountNumber());

    Is close to a felony because we are 4 objects down the rat hole. That means to change something in one of those objects I have to know that you called this whole stack right here in this very method. What a pain.

    Better:

    Account.getUser();

    Note this runs counter to the expressive forms of programming that are now really popular with mocking software. The trade off there is that you have a tightly coupled interface anyway, and the expressive syntax just makes it easier to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The reason why you shouldn't always use nullable types is… May 11, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer They are not the same thing. A function in C… May 11, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure what order these events occur but the… May 11, 2026 at 4:26 pm

Related Questions

I really enjoyed Jeff's post on Spartan Programming . I agree that code like
One of the articles I really enjoyed reading recently was Quality Control by Last.FM
In the past I have really enjoyed using Trac with subversion repositories hosted on
I will be entering my third year of university in my next academic year,
How would you test this scenario? I've just started looking into NHibernate and having

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.