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 7494381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:30:34+00:00 2026-05-29T17:30:34+00:00

I tend put multiple lines of code that fullfill a certain task into blocks,

  • 0

I tend put multiple lines of code that fullfill a certain task into blocks, with a small comment on top, like this:

public void doSomething(){
    // common variables needed by all blocks

    { // comment for block 1
        ...
        ... about 5 to 30 lines of code
        ...
    }

    { // comment for block 2
        ...
        ... about 5 to 30 lines of code
        ...
    }

}

I do this because in my opinion, it’s easy to read, variables needed by one block won’t be able to do harm in another block and because I don’t want to make separate methods for block that won’t be needed somewhere else.

Would you say this is bad practice?
A lot of people I’ve coded with disagree with this style of coding.
I know there are regions in c# but they do not isolate variables.

edit:
because everyone is suggesting I make methods out of the blocks:
Sometimes I do but I don’t want to if the class already has 20+ methods, the blocks are not needed by any other method and the method with all the blocks is still small enough .

  • 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-29T17:30:52+00:00Added an answer on May 29, 2026 at 5:30 pm

    I don’t think this is bad practice, and I do it too, but I would encourage you to break the method into smaller ones. Do you really need a >50 lines method?

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

Sidebar

Related Questions

I tend to write my javascript as big blocks of code without many variable
At the time of development we tend to put lot of comments in the
I tend to get the feeling that most folks here think SVN is gold-plated
I am developing a C++ application that needs to be multiple platform compatible (Windows/Linux)
We have a non-standard subversion respository that we would like to convert to Git.
I'm using the WML function providelocalinfo to put location information into Short Messages send
I work on a project that uses multiple open source Java libraries. When upgrades
Out of habit I tend to put classes/structs/enumerations in separate files when not nested.
When structuring a visual studio solution I tend to structure it so that various
Are there any considerations that should be taken into account when designing a new

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.