EDIT: I figured it out. Just did not understand notation.
Hello,
Hopefully someone out there is familiar with the clustergram in the bioinformatics toolbox. I am interested in the graphical aspects of the function (the dendrogram/heat map), but am currently handicapped as it requires me to use Matlab's cluster() function. I would prefe...
As stated in many places in SO "hardware/software is cheap, people is expensive".
Tools, like the ones listed here can really make a difference. Now I am stepping out of the cave and I am realizing that i must update myself.
I started studying "theory", I have a busy schedule for reading books on Refactoring, UnitTest, OOP Patterns. Bu...
I've got 3 classes:
class Super
{
virtual int getType() { return 1; }
}
class Special : public class Super
{
virtual int getType() { return 2; }
}
class SpecialSpecial : public class Special
{
virtual int getType() { return 3; }
}
And I've got a function which takes an std::vector<Super*> as argument:
void handleClasses...
I have a situation in which A has a reference to a class C defined inside B, and C has an instance of class B.
When I try to compile the code below, I get "field a has incomplete type". I assume this is because the compiler does not know how much memory it should allocate for an instance of A.
class A;
class B {
public:
class C {
...
Most design patten books say we should "Favor object composition over class inheritance."
But can anyone give me an example that inheritance is better than object composition.
...
I'm trying to understand the concepts of polymorphism and overloading. I have the following code as a sort of experiment. I cannot figure out, however, why this program does not run (it fails because of mobj.foo(str). mobj is defined using polymorphism, and from what I can gather, should be of type MyDerivedClass. If that were true thoug...
I've been getting into OOP javascript recently and more and more I've been hearing about closures. After a day of twisting my brain I now understand them* but I still don't see the advantage over using an object. They appear to to do the same thing but I suspect I'm missing something.
*i think
Edit
I've just spent 20 minutes trying to...
I'm struggling to come up with a good way of adding a bidirectional relation in OO model. Let's say there is a Customer who can place many Orders, that is to say there is a one-to-many association between Customer and Order classes that need to be traversable in both directions: for a particular customer it should be possible to tell all...
Today I read a book and the author wrote that in a well-designed class the only way to access attributes is through one of that class methods. Is it a widely accepted thought? Why is it so important to encapsulate the attributes? What could be the consequences of not doing it? I read somewhere earlier that this improves security or somet...
I found a thesis on forums:
If you have a type with "Manager" in
the name, it's a candidate for
refactoring.
One answer:
I know it's considered a code "smell"
So... Why? Is this thesis correct?
There are many managers out there. For example, Ogre3d uses them a lot, and this engine really has a clean architecture.
...
I have recently been trying to learn about basic design principles and the OCP has me a bit confused. It makes sense that when a change happens it is preferable to extend the system rather than modify existing and working parts. But isn't this more of a principle for how to implement changes in a system rather than how to design one? Isn...
There is this famous quote that says
Procedural code gets information then
makes decisions. Object-oriented code
tells objects to do things. — Alec
Sharp
The subject of the post is precisely about that.
Let's assume we are developing a game in which we have a Game where there is a Board.
When facing the problem of deciding ...
I've seen some people writing Python code by creating one class and then an object to call all the methods. Is there any advantage of using classes if we don't make use of inheritance, encapsulation etc? Such code seems to me less clean with all these 'self' arguments, which we could avoid. Is this practice an influence from other progra...
I've never tried OO PHP before so I decided to make a simple CMS to learn more. I am having a problem loading values into a multi-dimensional array.
class Article {
private $index = 0;
private $article;
public function Article() {
$get_articles = mysql_query("SELECT * FROM `articles`");
while ($result = mysql_fetch_array($g...
in this code :
public class Main{
private void method()
{
System.out.println("inside method");
}
public static void main(String[] args) {
Main obj = new Main();
obj.method();
}
}
Why we can access the private method using an object from the class when we are in the class , while we cann't do that o...
I was studying the Model-View-Controller design pattern and i understand the concept behind the pattern theorotically, but I wanted to get a peek at how one would actually put it to practice.
Wikipedia mentions Wt - Web toolkit, CppCMS and some other standard implementations which use the pattern however I have not been familiar with the...
I am a C++ programmer myself and trying to make the transition to being a designer. I was just wondering does being a programmer helps in being a good OO designer or just that one can learn OO principles and the design principles and become as good a designer. The question may sound lame or pretty much obvious but i have seen some pretty...
Hello All,
Firstly, this is just an Object Oriented Programming question and does not apply to any Language in particular.
This is quite embarassing for me. This incident happened @ work and I was too shy to clarify this with my colleagues as it would indicate a poor understanding of Object Oriented Programming on my part. So here is t...
The LOD description I've seen (for example, Wikipedia, C2 Wiki) talk about not calling methods. To quote Wikipedia:
The Law of Demeter for functions requires that a method M of an object O may only invoke the methods of the following kinds of objects:
- O itself
- M's parameters
- any objects created/instantiated within M
- ...
We have very strange errors occasionally popping up in our php logs: Trying to get property of non-object.
This exact error seems to be caused by the access to the member $shortName in the following if statement:
class MyLocaleWrapper {
…
protected static $system = NULL;
public static function getSystemLocale() {
if...