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

The Archive Base Latest Questions

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

Hey I am new java so forgive me if what I am about to

  • 0

Hey I am new java so forgive me if what I am about to ask is obvious, but I will try to explain as best as I can.

Its just a project that has been set for university so its not in a serious manner.

I have a class called MarsRoom which holds the attributes say for all the dimensions of the room like the totalheight and width of the walls in order to calculate the heat loss that the room will suffer in order to adjust the amount of solar energy that is needed to keep the room at the room temperature set.

The problem I am having is what is better practice or solution, to pass the attributes of the size of the room in a constructor(but this could get quite long in size, as the ones below are not only the ones that I may need) or create a whole different class specifically for that room like ROOM TYPE U? and set the attributes in there.

As it stands I can create a whole new room just by instantiating the room with the new values, but its going to get a little long, whereas I would rather not create a whole new class for a different room which may only differ from another room by a few meters on one of the walls!.

So what I am really trying to get at it, is is it ok to pass that many attributes to the constructor on instantiation?

//the instantiation in the runnable
MarsRoom room1 = new MarsRoom("RoomU", 40, 40, 20, 20, 8, 2, 4);

//the constructor in the MarsRoom class
public MarsRoom(String roomname, int windowsH, int windowsW, int wallsH, int wallsW, int windowC, int heaters, int lights){
    name = roomname;
    TotalWindowHeight = windowsH;
    TotalWindowWidth = windowsW;
    TotalWallHeight = wallsH;
    TotalWallWidth = wallsW;
    windowCeiling = windowC;
    numheaters = heaters;
    numlights = lights; 
    roomheaters = new Heaters[numheaters];
}
  • 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-30T17:06:41+00:00Added an answer on May 30, 2026 at 5:06 pm

    I’d say that you should be adding factory methods here.

    Basically, keep your constructor, but add methods like

    static Room createLaundryRoom(laundryRoomParameters) {
      return new Room(...laundry room parameters plus defaults
        common to all laundry rooms...);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I am new to java and wondering where to learn about JDBC, any
Hey I'm new to java servlets and I am trying to write one that
Hey, i have some experience with MVC. but I'm new to rails. I'm using
hey all, I'm new to Java and was wondering if I define a method
Hey,firends,This is my first post. I'm just begin to using Gcc to compile java,and
Hey, everyone. I'm new to Java and I have 2D LinkedList like this: LinkedList<LinkedList<String>>
Hey guys, sorry I'm kind of new to programming, but I had a small
Hey this may be a somewhat simple question, but I'm new to Eclipse and
Hey everyone! I am new to blackberry programming although I do have some java
Hey stupid question but I'm having a hard time connecting my java program to

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.