oop

inspect the parameters to "use", and pass on the rest?

I have a Perl module and I'd like to be able to pick out the parameters that my my module's user passed in the "use" call. Whichever ones I don't recognize I'd like to pass on. I tried to do this by overriding the "import" method but I'm not having much luck. EDIT: To clarify, as it is, I can use my module like this: use MyModule qw...

Is it OK to write a constructor which does nothing?

To use methods of a class I need to instantiate a class. At the moment the class has not constructor (so I want to write it). But than I have realized that the constructor should do nothing (I do need to specify values of fields). In this context I have a question if it is OK to write constructor which does nothing. For example: public...

How do I create a development tool to create custom object instances for iphone os

I'm setting out to create an app where it will use 7-10 instances of a custom class, lets call them "books" each class will consist of a number of pages, a title, a int of how many pages a book contains and possibly some notes of the author associated with a specific page. My question is what is the best way of creating these objects. i...

Tinyxml Multi Task

I have a single xml file and every new thread of the program (BHO) is using the same Tinyxml file. every time a new window is open in the program, it runs this code: const char * xmlFileName = "C:\\browsarityXml.xml"; TiXmlDocument doc(xmlFileName); doc.LoadFile(); //some new lines in the xml.. and than save: doc.SaveFile(xmlFileName);...

Help with a compiler warning: Initialization from distinct Objective-C type when types match

Here is the function where I get the compiler warning, I can't seem to figure out what is causing it. Any help is appreciated. -(void)displaySelector{ //warning on the following line: InstanceSelectorViewController *controller = [[InstanceSelectorViewController alloc] initWithCreator:self]; [self.navController pushViewContr...

Can I change class types in a setter with an object-oriented language?

Hello, Here is the problem statement: Calling a setter on the object should result in the object to change to an object of a different class, which language can support this? Ex. I have a class called "Man" (Parent Class), and two children namely "Toddler" and "Old Man", they are its children because they override a behaviour in Man cal...

Recommend an Appropriate Object-Orientated Design Pattern To Replace This Code....

I have a menu click event that looks something like this.... Public Sub ToolbarManager_ToolClick(sender as Object, e as EventArgs) Case "New" CreateNewFile() Case "Save" SaveCurrentFile() Case "Exit" ExitApp() Case....... etc... etc... End Sub This strikes me as being 'ugly' - but I'm un...

How do i free objects in C#

Hi, Can anyone please tell me how I can free objects in C#? For example, I have an object: Object obj1 = new Object(); //Some code using obj1 /* Here I would like to free obj1, after it is no longer required and also more importantly its scope is the full run time of the program. */ Thanks for all your help ...

What's the benefits of SOA over OO?

I want to know the differences between SOA and OO, and why SOA is going to popular? ...

File and Folder structure of a App/Project based in C.

Hi, What would be the general structure of a App/Project based in C Programming language. libs, includes, header files. etc etc. What would be the class structure. (in OOps) need to be scalable and other features. Something like main.cpp main.h does any one have any good links or images or pdf? ...

What question(s) does an object's behavior answer?

Reading a book I have found the following statement: (Object) Behaviors answer either of two questions: What does this object do (for me)? or What can I do to this object? In the case of an orange, it doesn’t do a whole lot, but we can do things to it. One behavior is that it can be eaten. In my understanding of object behaviour th...

Object Oriented PHP Best Practices

Say I have a class which represents a person, a variable within that class would be $name. Previously, In my scripts I would create an instance of the object then set the name by just using: $object->name = "x"; However, I was told this was not best practice? That I should have a function set_name() or something similar like this: f...

How objects (reference types- heap) communicate with variables stored on stack.

Hi all, as we know reference types are always stored on heap and value types are in stack memory. e.g. public Class A{ public int myInt=10; public void Display(){ } } here, if i create object of class A it goes in heap and myInt goes in stack right..? now, how class object (heap) interact with myInt public variable (stack)? ...

Need a single instance of an object using a factory with a way to reset the object's state.

I have used the abstract factory pattern to help with Dependency Injection and make my project more unit test friendly. A good couple of times I have come across the point that we should return objects in a ready-to-use state. Doing extra work like getting an object's state from a database makes it harder to test unless we can mock out t...

when creating custom class to be used by LINQ, does it matter if it pure variable or should it always be properties?

what would be the difference between this class Class1 { public string prop1 { get; set; } public string prop2 { get; set; } public string prop3 { get; set; } public string prop4 { get; set; } } and this class Class2 { public string var1; public string var2; public string var3; public string var4; } ...

How does PHP track created objects?

This may be a bit of daft question, but I don't come from an OOP background and although I'm reading and learning as I go I'm still struggling with a few concepts. Right now I'm working with PHP 5.3 and desiging a fairly simple login using a few different object classes: User which defines the user. Session which starts and maintains s...

Some solid OOP criticism?

Hi! I want to ask you to provide me with some articles (maybe books), which you possibly have found very convincing criticising the OOP methodology. I have read some in the WWW on this topic and I didn't really find a 'definitive demotivator'. It's not much about my personal attitude to the OOP, but I really would like to have somethi...

Object Oriented Metrics ?

Folks, Does anyone have a good understanding of Object Oriented Metrics; I am looking for some guidance on where can I start. I found the below resource: http://yunus.hacettepe.edu.tr/~sencer/oom.html Thanks, Amit ...

How to set a variable within a mock object

Is there any way to set a class level variable within a mock object? I have the mock object set similar to this: $stub = $this->getMock('SokmeClass', array('method')); $stub->expects($this->once()) ->method('method') ->with($this->equalTo($arg1)); Win the real class there is a variable that needs to be set for it to...

Implementation question regarding base classes and derived classes.

I have a question regarding the best way to implement this. I'm going to describe my current implementation and how I seem to have painted myself into a corner: I have an abstract class called Package: public abstract class Package { protected String description; protected String packagingCode; protected Dimension dimension...