Measure twice cut once carpenter theory <br /> <br />Baiju <br />SCJCP, SCBCD, IBM-486, IBM-484, SCEA Part I
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
TellDontAsk ... (link)
www.classic-and-class.com - www.evalulearn.com
Interfaces are the glue of OO.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by vu lee:
Using reflection, a private variable can be modified. Is private variable really encapsulated?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Originally posted by Tim Holloway:
Maybe I drifted off into the Twilight Zone and didn't realize it, but experiences with ORM have made me divide the concept of JavaBeans into two types: Data Beans, which hold values, and Logic Beans, which have functionality. Whenever I've attempted to mix the two concepts in a single JavaBean, I've usually regretted it.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Originally posted by Tim Holloway:
1. Entity EJBs, which can have business methods in them, but if they do, start confusing the persisted data with how its internals can be manipulated.
2. Generic JavaBeans. Problem here if I start exposing internal fields in a logic component, I get sucked into a situation where as the guts of the system churn, external callers get impacted. I do a lot more heavy refactoring in the development and maintenance of software than most people do. So I prefer to push the properties off to a data JavaBean and use the logic JavaBean for logic and, secondarily as a facade for the properties. YMMV, but it seems to keep me more honest.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
So if I understand correctly, the problem arises when you have to expose fields for the persistence framework that would otherwise be hidden?
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Originally posted by Tim Holloway:
I prefer to push the properties off to a data JavaBean and use the logic JavaBean for logic and, secondarily as a facade for the properties.
www.classic-and-class.com - www.evalulearn.com
Interfaces are the glue of OO.
Originally posted by Thomas Taeger:
In general I would prefere one single object along with its interface being responsible for its data _and_ behaviour.
Thomas.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Originally posted by Tim Holloway:
It was EJBs that turned me off on that idea.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Vladas Razas:
Oh I remembered someone said in this forum: "code that is not changing is probably not being used at all". Still how they design JDK?
![]()
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
I've often heard people say that mixing EJBs and OO design is really hard. Fortunately, I don't have enough experience with EJBs to comment...![]()
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Originally posted by Vladas Razas:
Oh I remembered someone said in this forum: "code that is not changing is probably not being used at all" .
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Tim Holloway:
Well, to me, one of the foundations of OOP is separation of concerns
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
Another one is encapsulation: putting operations and the data they operate on together.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Originally posted by Vladas Razas:
Back to C++ days you remember there were clear distiction of what HAS what. This distinction became not so obvious with garbage collector. Now we can have multiple classes referencing same object which does not have to be deleted so ownership is not so obvious.
I think only class that is considered Owner of an object should ever return it with it's true type (i.e. ArrayList, not List) if and only if it is not bound to do otherwise by interface it implements.
That means, we do not write getter for every reference we have in our class, but only those that are really owned by class plus those that are not supposed to be hidden.
Now I have a question. What about I write class that can be inherited just I didn't think anyone would do that. Should I mark such class final?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Wasn't the same already true with C++ pointers?
Why should you want to do that? Doesn't that unnecessarily expose an implementation detail?
What is the reasoning for writing getters for references that are "owned" by the class? Wouldn't it be even better to not have getters for those either?
So what are you more afraid of: that others will be misusing your class by inheriting for it, or that you might also prevent valid uses by making it final?
Originally posted by Vladas Razas:
I wanted to say in C++ there were distinction between having pointer and actually owning pointer. Not in the language itself, but someone has to delete that object. Usually the one that is considered real Owner.
I skip writing interface if I have a class that I do not need to switch with any other implementation. If I have such class returning something not through interface, I would return it by real type.
Let's say I have: A has B has C. A shouldn't have shortcut getter for C, because the real owner of C is B.
But aren't private constructors and singletons alike to "final" class? Is their purpose to limit use of class, isn't it?
Investigations wherever class can be derrived or not take time. Final would be a statement "this class is not supposed to be derrived, because I did not have to check if that is usefull/work".
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Vladas Razas:
I say if one don't expect class to be derrived then make it final. Also I say if one is not sure if some field may be used, write getter. You say don't make class final, but if not sure - do not write getter. Isn't that the same? We both limit the user in different way![]()
The choice is between "give user everything he might want to use" and "give him only bare minimum". "Bare minimum" would be ideal. But the problem is I don't know what the bare minimum is.
View is bunch of UI widgets plus layout. I am not sure how someone will want to use that View.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
So why did you write it at all?
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Originally posted by Vladas Razas:
But aren't private constructors and singletons alike to "final" class?
www.classic-and-class.com - www.evalulearn.com
Interfaces are the glue of OO.
No.
- _Singleton_ along with private constructors ensures that only one _instance_ can exist at runtime.
There is no relationship Class-1--N-InstantiatingObject anymore.
- Declaring a class _final_ cuts off the chance of _polymorphism_ at compiletime [and runtime].
There is no relationship Class-1--N-InheritingClass anymore.
Originally posted by Vladas Razas:
Making code re-usable takes time and effort (some or most code will never get reused). But making un-reusable code reusable may take even more effort later on (fixing existing code that depends on original code).
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Making reusable code *really* reusable also might take considerable effort, as most often before you really *do* reuse something, you can only guess at what makes code reusable.
Making un-reusable code reusable only takes much more effort later if your code isn't well decoupled. So my preferred strategy is to have code that is well decoupled (design patterns help here, too), but doesn't do more than is needed now.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |