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

  • SEARCH
  • Home
  • 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 385293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:27:56+00:00 2026-05-12T15:27:56+00:00

I’ve been coding on and off my whole life. I’ve mostly coded Perl, but

  • 0

I’ve been coding on and off my whole life. I’ve mostly coded Perl, but also some Java, PHP, C, C++. I’ve even took a stab at Emacs Lisp, and I’ve done the occasional shell script. However, I’ve never actually engaged the subject to gain any kind of expertise – other things have had higher priorities for me. I don’t consider myself to be really proficient in any language but Perl, and also now Haskell which I’m taking a course in right now.

Lately, I’ve been thinking about my style of coding. Not the style of the actual code; as a CS student I only do projects for fun or for school, which enables me to write what in my opinion is beautiful code almost always. One question in particular has been troubling me. It’s a rather curious thing, but still something I would like to hear other opinions about.

Here’s the thing: I find myself taking a fair amount of time to name my functions and variables to the most easily understood names I can possibly think of. Sometimes this task can be very tedious, even when not taking into account the difficulty of finding a variable name that conveys the meaning of a piece of code. For example, right now I’m making a function that looks like this.

This is Haskell code but the meaning should be quite clear. (It’s exact meaning isn’t that important so if you want to, just skip the code and read on.)

-- return the row with least number of Nothing values
bestRow :: [[Maybe Int]] -> Int -> Maybe (Int,Int)
bestRow [] _ = Nothing
bestRow (row:rows) thisIndex
   | nextRow == Nothing && thisFilled > 8 = Nothing
   | nextRow == Nothing       = Just (thisIndex,thisFilled)
   | thisFilled >= nextFilled = Just (thisIndex,thisFilled)
   | thisFilled <  nextFilled = nextRow
     where thisFilled             = length $ filter (/= Nothing) row
           nextRow                = bestRow rows (thisIndex + 1)
           (nextIndex,nextFilled) = fromMaybe (-1,-1) nextRow

I couldn’t decide on the variable names. The function did it’s task well but it wasn’t as clear as it could be. Once I settled on a solution, I spent 15 minutes on naming and renaming the variables. Should I go with curIndex, nextIndex || index, nextIndex || ind, indN etc? 15 minutes after I decided I was done, I realized this function wasn’t needed after all: I found a much better solution to my problem. BOOM I had lost a lot of time simply cleaning code to no use to anyone, least of all to me. Or at least it felt that way.

This is something which has happened to me more than once, and is quite frustrating, mostly because it makes me feel dumb. What are your thoughts on this subject? Is this something you’ve experienced, something wrong with my way of doing things or simply something unavoidable?

Are there “perfect” variable names, or is it “ok” if they at least doesn’t obfuscate your code?

Thanks,

Stefan Kangas

  • 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. Editorial Team
    Editorial Team
    2026-05-12T15:27:57+00:00Added an answer on May 12, 2026 at 3:27 pm

    Read the book Clean Code by Robert C. Martin

    One thing he goes into detail on is naming. Variable and function names should be as exact as possible. If you require a comment to describe it, the function is either doing too much, or the name can be clearer.

    The goal, is to have code that reads like a story. Changing variable and function names and breaking them down into several functions or variables if necessary to achieve this goal.

    Great book, worth every penny

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer How about adding a 3rd column for a clarifying int?… May 13, 2026 at 12:37 am
  • Editorial Team
    Editorial Team added an answer I would consider what has been done by x12.org for… May 13, 2026 at 12:37 am
  • Editorial Team
    Editorial Team added an answer You can do something like: [JsonFilter(Param="content"), JsonDataType=typeof(Content)] public ActionResult SaveJson(Content… May 13, 2026 at 12:37 am

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS
I want use html5's new tag to play a wav file (currently only supported

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.