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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:39:41+00:00 2026-05-25T02:39:41+00:00

Its a pretty basic question but I am new to Java designing to please

  • 0

Its a pretty basic question but I am new to Java designing to please excuse me. 🙂

I want to know in which scenarios we need to separate the class behavior from the class itself.

for e.g.

If I have an class Employee, I will have some data in it like – name, age etc. Also this class will have some behavior like doWork() etc. Now in what scenario we can have data and the behavior inside once class (Employee) only and in which scenario we need to have 2 different classes for Employee data (EmployeeDTO) and behavior (EmployeeService)

Very subjective question but am looking for some inputs on a design of a small application where I am taking data from a text file. Should I put the data and behavior in different classes or same? What will be your reason to justify this decision?

PS: Any links to information on this will also be very useful 🙂

Thankyou

  • 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-25T02:39:42+00:00Added an answer on May 25, 2026 at 2:39 am

    Do the simplest thing possible. You can always make your code more generalized later and there’s a good chance you won’t even have to do it.

    Apply YAGNI principle every time you need to make a decision. Extreme Programming wiki is also a nice reading.

    Put everything into one class right now. When you see your Employee is getting too fat then you can do some refactoring – for example, move method to another class. In statically typed languages like Java it is super easy because compiler helps a lot and IDE support is great.

    Reading from file, for example, looks like an obvious candidate to extract to a separate loader class. On the other hand if you have a very common format as input such as XML or JSON you could just create static method List<Employee> Employee.loadFromFile(string fileName) and implement reading logic in a couple of lines of code. It’s good enough right now: simple, short and works fine.

    May The Real Ultimate Programming Power be with you!

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

Sidebar

Related Questions

I know this a pretty basic question, and already found another ones like mine,
This is a pretty common question, but I could not find this part: Say
When writing manual SQL its pretty easy to estimate the size and shape of
PHP, for all its warts, is pretty good on this count. There's no difference
I can read the MySQL documentation and it's pretty clear. But, how does one
I have a side project I do = in Java. It's a pretty straight-forward
Well I know it's not evil just not as pretty in semantics as <strong>
I have this syntax which works (since it's from the API, pretty much) <%
I'm sorry if this comes through as a noob question, but I'm really stuck
So this is a rather basic question regarding the best way to sort an

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.