Results 1 to 2 of 2
Thread: classes, true purpose of
- 12-22-2009, 04:28 PM #1
classes, true purpose of
If variables store current state and methods implement behaviour and classes are basically a collections of methods grouped logically together ... i wonder how to better structure my classes content.
Say job is to take a look at 'n' files, read them into memory, do something and make a report - knowing that i will have to be reading more and more files in the future for other purposes, should i be placing method that actually reads a file and returns its contents into it's own utils.java class in my own com.mac.utils package so i can import it later into the main one?
In the industry, is this how things are done, or perhaps, you just make a local copy of that utils java and place it into the main package? To dwell more on this example a little bit - i don't know what type of return data my later code will need, so some overloading may be in order.
Am i thinking in the right direction? Please advise
Let me add that my current role in the organization has to do with supporting a large number of distributed applications. What this means is that master collection of tools is set to grow substantially over time. This means reusability is a must. And that begs the question, what should be reused? Should i concern myself with making a collection of reusable classes in my group's package com.group.utils?
Thanks for reading,
- 12-22-2009, 05:34 PM #2
- Join Date
- Sep 2008
- Voorschoten, the Netherlands
- Blog Entries
- Rep Power
Next, if you're certain that implementations of those interfaces can do the job, implement the classes. If an interface A depends on an interface B make an implementation of A depend on interface B, not an implementation thereof.
Don't make your interfaces too general or you'll end up with implementations of that interface that can be best described as 'God classes' or 'Swiss Army knifes'. You don't want to maintain those molochs.
But first of all: practice and study because designing interfaces is something that swings you back and forth between generalizations for the sake of it to the need to get something implemented. Finding a balance between those two opposing forces is the thin line you have to walk.
- By ravian in forum New To JavaReplies: 7Last Post: 06-29-2011, 07:05 AM
- By SirFalcon in forum New To JavaReplies: 3Last Post: 10-29-2009, 03:33 AM
- By makpandian in forum New To JavaReplies: 3Last Post: 06-30-2009, 01:23 AM
- By udayadas in forum New To JavaReplies: 7Last Post: 08-24-2008, 05:14 AM
- By frejon26 in forum New To JavaReplies: 4Last Post: 01-24-2008, 04:39 AM