java


Is it okay to store all Data in an Data Class?


Is it okay for a school project to store all Data like Variables, Objects and other stuff in one "Data Class"? Because I have heard once that you should never do something like this. Are there any other and better approaches to this topic?
Thank you. (:
Is it okay for a school project to store all Data like Variables, Objects and other stuff in one "Data Class"?
Depends upon what that data is, but almost certainly not, because of the Single Responsibility Principle:
The single responsibility principle states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility. Robert C. Martin expresses the principle as, "A class should have only one reason to change."[1]
Only the data relevant to a specific class should be stored in that class. If it's not relevant to one class, it may be relevant to another, and so should be placed in there.
It also sounds a bit like you're describing a God object, which is considered an anti-pattern:
a God object is an object that knows too much or does too much

Related Links

How to get the pid of a Java subprocess? [duplicate]
Error calling rest service using eclipse and jersey [duplicate]
How to get the first 2 records from Access's Table and Add them to Jtable (Data filter)
Setting required length of a string
how to view http post result in a browser using java
Not applicable argument? [duplicate]
Getting input from users command and using .equals
JavaFX - Embedded File Navigation
i made a class to create a HashMap and am not being able to implement it form another class in the same package in java
Entering and exiting application with JavaFX
Possible lossy conversion from double to int?
How to return an array from JNI to Java in Android?
Java Unsupported major.minor version 51.0 running jar file
Find the first time that value in a list surpass a value in another list
Get folder and subfolder id Google Drive
Mock Future object [duplicate]

Categories

HOME
ibm-bluemix
twitter
pdf
osgi
image
date
keycloak
minimum-spanning-tree
google-play
angular-material
alfresco
youtube-api-v3
electronics
sqlite3
ebean
spring-kafka
wheelnav.js
flask-wtforms
finite-automata
invantive-sql
normalizr
oxyplot
autoconf
opencover
ehcache
pass-by-reference
zurb-foundation-6
icloud-api
blazemeter
android-widget
spark-jobserver
social-media
elasticsearch-net
windows-server-2000
quote
siesta-swift
fog
language-concepts
rotational-matrices
amazon-kinesis-kpl
environment-modules
overriding
revolution-slider
xcode-extension
reportbuilder
jna
splice
opshub
sas-visual-analytics
ibpy
password-encryption
modelmapper
reactive-cocoa-5
node-sass
btrace
pebble-watch
dotnetzip
knockout-components
directory-structure
font-size
nbconvert
titanium-android
eventkit
root-framework
time-and-attendance
url-pattern
passport-google-oauth
whois
dlna
fadeout
suffix-tree
thredds
intellij-14
jmeter-maven-plugin
content-length
embedded-code
ideamart
splash
cisco-ios
clicktag
jscript.net
gadt
coldbox
winddk
cctv
bitcoinj
heisenbug
mechanize-ruby
dealloc
ms-project-server-2010
plasma
lcs
enterprisedb
kyotocabinet
factory-method
cascalog
ocx
netbeans-6.9
work-stealing
gwt-ext
gnustep
spyware
subgurim-maps
krl
locate
google-friend-connect
fluent-interface
paster
brewmp
text-coloring
.net-1.0

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App