oop

Why C# allows methods/members to be public when the class is internal

I have a class which I marked as internal and I marked fields and methods as public. It compiled without errors or warnings. Is there any specific need to have methods as public and class as internal (except when they are being implemented from interfaces or classes)? ...

How do I access "this" with a nested class, in Java?

Consider this example. public class myclass { public void... public int ... private class my_nested_class { Intent i = new Intent(this, List.class); } } I would like "this" to be myclass. How can I do that? "this.super"? But that doesn't work. ...

Looking for a tutor to ease the OO learning curve

I'm not sure if I'm asking this in the right place, so apologies if I am not. I have been studying OO javascript in a variety of texts, but I am finding it difficult to make the jump from theory to practical design problems. I am hoping to find a tutor who would be willing to spend a little bit of time looking over a small chunk of m...

Javascript function organization

I am not exactly sure the differences between saying "function x(){}" or "this.x=function(){}", but I had to make an object oriented JavaScript which is laid out like this: function PROJECT(){ ... ... ... this.main_call=function(...){ return this.recursive_call(...); } this.recursive_call=function(...){ ... var local,...

Unusual OO behavior?

here is some php code: class A { private function action(){ echo 1; } public static function callAction(A $a){ $a->action(); } } $a = new A; A::callAction($a); can someone explain me why does object method is vissible from static method context how does following code works in other languages ??? ...

In Perl, what is the right way for a subclass to alias a method in the base class?

I simply hate how CGI::Application's accessor for the CGI object is called query. I would like my instance classes to be able to use an accessor named cgi to get the CGI object associated with the current instance of my CGI::Application subclass. Here is a self-contained example of what I am doing: package My::Hello; sub hello { ...

PHP: Get class name of passed var?

I have a function that gets a class passed to it as a parameter. I would like to get the class name of the passed class as a string. I tried putting this method in the passed class: function getClassName() { return __CLASS__; } but if the class is extended I assumed this would return the name of the subclass but it st...

AS3 Listener across object instances - possible / good or bad practice?

I have a question regarding as3 listeners, and instances of a class. The main question: is there a way to dispatch an event from the button instance in such a way that the other button instances can listen (without the need for a listener in the document class) Lets say i have a document class and a button class. The document will have...

Have a variable available for class __construct()

I am trying to pass a variable into a class so the __construct() can use it however the __construct() is called before any variables are passed to the class. Is there any way to send the variable before the __construct()? Here is the code: class Controller { public $variable; function __construct() { echo $this->variable; } } $ap...

Static Method of a Static Class vs. Static Method of a Non-Static Class ( C# )

I was asked the above question in an interview. Could you please explain the differences? ( performance - memory - usage - when to use which ? ) Thank you, Erkan ...

How do I copy objects into ivars for later use?

Objective c | xcode | iphone question Im building a model(data) class for a monetary transaction and have kind of a basic/noob question regarding pointers and object copying. The Transaction class I'm creating contains 4 or 5 ivars/properties that represent object type variables. now when I get the user entered data from the view contro...

Domain Model Financial Trading application

Hello; my company is thinking about implementing a new financial compliance trading application which is an application that would check all trades that would be executed by the company. A very simple check might be "Don't Invest in Stocks that sell Alcohol" for example. We need to define a financial business object model and then d...

Type - Subtype relation. Something seems unclear.

I'm reading some slides of a class on object oriented programming languages and stepped into the type-subtype definition: Barbara Liskov, “Data Abstraction and Hierarchy,” SIGPLAN Notices, 23,5 (May, 1988): What is wanted here is something like the following substitution property: If for each object o_s of type S there is ...

What to pass? Reference Object or Value Type?

Guys I have a "best practice question" For example I have this classes: class Person { public int age {get; set;} } class Computer { public void checkAge(Person p) // Which one is recommended THIS { // Do smthg with the AGE } public void checkAge(int p) // OR THIS { //Do smthg with the age. } }...

What is the better approach to compare a collection with another (architecturely speaking) ?

Here's an example of the architecture approach I favorited as for now: public abstract class CollectionComparer { public virtual SetEqual(IEnumerable enum1, IEnumerable enum2) { if(enum1== null && enum2== null) return true; if(enum1== null && !(enum2== null)) return false; if(!(enum1...

What is the best way to think about the order of programming?

Possible Duplicate: How to Think in OO I am sort of new to programming. I am working with Objective-C and iPhone app Dev. I am having some trouble wrapping my mind around the OOP mindset. Does anyone have any tips or tricks to think or visualize the programming process before you sit down and start it? ...

Critique – OO Design Flaws

Recently, I received some negative feedback about the design of a class that I had originally thought to be innovative. After reflection, however, I agree it is clearly more flawed than innovative. This post invited the community to join in the review and provide its thoughtful feedback on the design flaws and identify a fix. Backgr...

Put it or not? Modeling classes from DataBase tables.-

Guys I have another "best practice question" For example I have this tables on my Sql Server: -------------- Table: Client -------------- (PK) clientID long, clientName varchar(50) --------------- Table: Training --------------- (PK) trainingID long, (FK) clientID long, trainingName varchar(50) Now Im us...

Referencing an object to be augmented in javascript

I am trying to localize everything to a namespace in javascript. So I have objects that follow a naming convention like: myapp.utilities.file.spinner etc... My question is, is there a way to avoid repeating that big string everytime I want to augment the object with a property or a method. Currently my code looks like this... myapp...

What is the best way to incorporate simple, utility objects into more complex, specialized objects?

I am developing some basic utility objects in javascript. These are things like: spinner { // generates a spinner } dialog { // generates a dialog } wysiwyg { // generates a wysiwyg editable } etc. Once I have amassed a collection of basic utility objects, I would like to create more specific, complex objects for working on differ...