raghav singh wrote:How can one create a well-encapsulated class?What are the principles to be followed?
If there are a lot of ways to do so, please list some?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Hope it helps - and I've probably left out several things - but I'm not sure that a mere list will help you much.
Winston
Winston Gutkowski wrote:
If you have any more specific questions, feel free to come back.
Winston
raghav singh wrote:Yeah i got another one: What does a bad-encapsulated class contain or look like? This might help me avoid common mistake.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:Also, I think the designers of library classes have the idea that you should provide as many methods as possible just in case somebody ever needs them.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
but until raghav replies...
Winston
Winston Gutkowski wrote:
Campbell Ritchie wrote:Also, I think the designers of library classes have the idea that you should provide as many methods as possible just in case somebody ever needs them.
Which is the absolute antithesis of what I was taught (having been a "library" bod - or "toolmaker" - for many years). IMO, it's even more important for a "library" class to provide ONLY those methods needed to "use" it.
Jesper de Jong wrote:I was just talking about this with my colleagues during lunch: the YAGNI principle.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
raghav singh wrote:Maybe in a year or two i will reply....for now you are the man...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Have we answered your question?
Winston
Campbell Ritchie wrote:I would have thought contains would be faster than index when it runs in constant time (hash collections, but they don't have an index) or when it runs in logarithmic time (trees, where you can probably find indices depending on the traversal you use). An index method would run in linear time.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
raghav singh wrote:Enough to get me started.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Consider Paul's rocket mass heater. |