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

I need to create an iso-8859-1 encoded URI (java.net.URI)
How to create a Jcache in Spring Java config?
Incompatible nullness constraints in java class hierarchy with generics
Can't run java from PHP's exec
I cant understand this Applet and Thread code in Java
Java- get user home on user machine not on server
Retrieving data from ArrayList
Universal Image Loader image scaling distortion
Handling on Jersey (JAX-RS) on XMLHttpRequest abort
Apache Spark and MongoDb Date issue
Why am I getting the exception - java.lang.NoClassDefFoundError: com.google.android.gms.R$string?
Media Player crash
Android Gradle Build Error With Parse SDK
How to convert ArrayList into JList object? java [duplicate]
Android application crashes every other compilation/launch
Java Error: Ubuntu - And OS X - Java -v command throws errors, .jar files not running properly

Categories

HOME
mediawiki
hp-exstream
yahoo-oauth
maven-3
cakephp-2.5
retrofit
alpha
fingerprint
azure-media-services
windows-azure-storage
spring-tool-suite
progressive-web-apps
tostring
transformation
nhibernate-envers
alpine
plunker
visjs
clickonce
graphicsmagick
restful-authentication
crosstab
selectedindexchanged
url-scheme
filezilla
applozic
buck
dbclient
webkitspeechrecognition
libssl
file-rename
preg-match
key-value-observing
catel
webtest
overriding
libraries
android-browser
android-fingerprint-api
preconditions
mapzen
avro4s
isbn
no-www
import-from-excel
menuitem
network-flow
filepicker
revapi
jedis
logparser
paxos
gcsfuse
hittest
sonarlint-vs
adxstudio-portals
fuzzy-search
sdf
ipconfig
javax.sound.midi
execute
retina
simple-framework
feedback
security-testing
emailrelay
responsive-images
graph-api-explorer
npapi
geonetwork
tween
jscript.net
xcode-6.2
terminfo
comexception
rtmfp
android-2.2-froyo
mcts
pushbackinputstream
orchardcms-1.7
mqx
ember-app-kit
limejs
free-variable
simba
quickdialog
rdoc
dsn
asyncfileupload
custom-backend
horizontal-accordion
asp.net-mvc-areas
digest-authentication
icanhaz.js
w3wp
wsdl.exe
ntvdm.exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App