• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Class Doing Too Much?

 
Daniel Simpson
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm beginning to wonder if my Data class is doing too much. It implements all of the methods from the DB interface and performs all of the reading and writing of the database file and the cache. I do have a DBDataAdapter class but that controls the booking method for the client. Has anybody else used just the Data class to do all of this, and passed the exam? Just curious.
 
Barend Garvelink
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the principles of object oriented design is to have a single responsiblity per class file, where possible. This helps promote object re-use. One other thing to consider is that breaking up large files might make your sourcecode easier to read.

I haven't submitted my own assignment yet, and I don't know what your sourcefile looks like. However, with the above in mind I suggest you see if you can find a sensible way to divide resposibilities over a number of classes.
 
Daniel Simpson
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Barend Garvelink:
One of the principles of object oriented design is to have a single responsiblity per class file, where possible. This helps promote object re-use. One other thing to consider is that breaking up large files might make your sourcecode easier to read.

I haven't submitted my own assignment yet, and I don't know what your sourcefile looks like. However, with the above in mind I suggest you see if you can find a sensible way to divide resposibilities over a number of classes.


My Data class is roughly around 650-700 lines of code for all of the DB interface methods that I implemented (including comments, class variables). I also have methods to read in the schema, cache records, test record validity by reading the cache. Is this wrong? Or should I think about having a class that only reads the schema. A class that Caches records? What do you think?
[ December 07, 2004: Message edited by: Daniel Simpson ]
 
Barend Garvelink
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Daniel Simpson:


My Data class is roughly around 650-700 lines of code for all of the DB interface methods that I implemented (including comments, class variables). I also have methods to read in the schema, cache records, test record validity by reading the cache. Is this wrong? Or should I think about having a class that only reads the schema. A class that Caches records? What do you think?


Should I read that as 650-700 for the entire source file, or "650-700 for the DB interface methods" (and some more for everything else)?

It's not "wrong" per se, but if the file is overly long you might lose some points in in the categories code clarity and OO design, which would be a shame. That's not for me to judge. In my opinion it would be safer to split up the class, e.g. into seperate classes for MetaData, Record, Validation, LockManager, CacheManager -- but the decisions are up to you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic