oop

Javascript: How to access a class attribute from a function within one of the class's functions

Within my a certain function of a class, I need to use setInterval to break up the execution of the code. However, within the setInterval function, "this" no longer refers to the class "myObject." How can I access the variable "name" from within the setInterval function? function myObject() { this.name = "the name"; } myObject.pr...

BlitzMax - Object Oriented Basic language

What is your opinion on BASIC programming languages? BlitzBasic began on the Amiga (wikipedia). BlitzMax, designed on fasm and gcc (cross-platform, use C/C++ code in Max), is Object-Oriented (with inheritance and polymorphism), but still holds that same BASIC nature, which was ever so pleasant with the previous languages. BlitzMax is d...

Domain Driven Design question

Hi, I would like to ask for a reccomended solution for this: We have a list of Competitions. Each competition has defined fee that a participatior has to pay We have Participators I have to know has a Participator that is on a Competition paid the fee or not. I am thinking about 2 solutions and the thing is it has to be the most a...

How can I assign a new class attribute via __dict__ in python?

I want to assign a class attribute via a string object - but how? Example: class test(object): pass a = test() test.value = 5 a.value # -> 5 test.__dict__['value'] # -> 5 # BUT: attr_name = 'next_value' test.__dict__[attr_name] = 10 # -> 'dictproxy' object does not support item assignment ...

Fluent interfaces and leaky abstractions

What is a fluent interface? I can't find a good definition of this, but all I get are long code examples in a language I am not very familiar with (e.g. C++). Also, what is a leaky abstraction? Thanks ...

Logical versus physical design

I have a very general design question, but I'll frame it in concrete terms with an example. Suppose you're working on embedded software for a digital printer. The machine has 4 print heads (for each of the C, M, Y, K colors). Each print head performs the same task: fetching toner and putting it on the page. At runtime, we could organ...

Is class being called from another class

Suppose I have the following code: class siteMS { ... function __CONSTRUCT() { require 'config.php'; $this->config = new siteMSConfig; ... } ... } From inside the siteMSConfig class can I determine weather or not it is being called from inside the siteMS class? ...

How to go from bad to good OOP design?

I'm reading a lot about good and bad practices in OOP design. It's nice to know your design is bad, or good. But how do you get from bad to good design? I've split the interface (xaml) and codebehind from the main businesslogic class. That last class is growing big. I've tried splitting it up into smaller classes, but I'm stuck now. Any...

Ruby style question : blocks or inheritance ?

I have some classes that will do something based on some conditions . The conditions are sent as parameters to some methods . My questions is related to ruby coding style : should the conditions be sent as lambdas/blocks , or as some objects that inherit from a condition class ? which is more efficient in terms of OOP ? Thanks ! ...

How to setup an Object Creation Interface "rule" in C#?

The general rule is that I want to say, "T has a method with a String parameter which will return List." Put verbosely, we might call the interface ICanCreateListOfObjectsFromString. A possible application might be search. It feels like it'd be nice to have a static method in my interface, but I know that's not allowed in C#. What is...

How to be master in C# and object oriented technology ?

I'm newbie of C# developer. I have a little knowledge of C# and OOP. My goal in this year is "To be master in programming and object oriented technology" I have set my learning path as follow. (order by learning step) C# and OOP OOAD UML Requirement Management Design Pattern Is my learning path is good? If not please suggest me for b...

Service-Orientation vs Object-Orientation - can they coexist?

There's been a lot of interest in Service-Oriented Architecture (SOA) at my company recently. Whenever I try to see how we might use it, I always run up against a mental block. Crudely: Object-orientation says: "keep data and methods that manipulate data (business processes) together"; Service-orientation says: "keep the business proce...

How many variables are too much for a class?

I want to see if anyone has a better design for a class (class as in OOP) I am writing. We have a script that puts shared folder stats in an csv file. I am reading that in and putting it in a Share class. My Boss wants to know information like: Total Number of Files Total Size of Files Number of Office Files Size of Office File...

Object Oriented questions in Javascript

I've been using javascript for a while, but have never learned the language past the basics. I am reading John Resig's "Pro Javascript Techniques" - I'm coming up with some questions, but I'm not finding the answers to them in the book or on google, etc. John gives this example in his book: Function #1 function User( name, age ){ th...

How will I know when to create an interface?

I'm at a point in my development learning where I feel like I must learn more about interfaces. I frequently read about them but it just seems like I cannot grasp them. I've read examples like: Animal base class, with IAnimal interface for things like 'Walk', 'Run', 'GetLegs', etc - but I've never been working on something and felt lik...

How Many Static Methods is Too Many For One Class?

UPDATE: Rephrasing the question to ask, 'are there too many' static methods (I realize that right now there are only 4 but I originally started with 2) in this class structure? If so, any suggestions on how to refactor these classes to use some sort of Finder class so that I can remove the static functions from the Model classes? I have...

do you put your calculations on your sets or your gets . .

which is better ??? public class Order { private double _price; private double _quantity; public double TotalCash { get { return _price * _quantity; } } or public class Order { private double _totalCash; private double _price; private double _quantity; private void CalcCashTotal() { _tot...

PHP best design practices

Ok, have a bunch of questions that I have been thinking about the past few days. Currently I have a site that is just a bunch of PHP files with MySQL statements mixed in with PHP, HTML and CSS, basically a huge mess. I have been tasked with cleaning up the site and have made for myself, the following requirements: The site needs to be ...

Is type checking ever OK?

Is type checking considered bad practice even if you are checking against an interface? I understand that you should always program to an interface and not an implementation - is this what it means? For example, in PHP, is the following OK? if($class instanceof AnInterface) { // Do some code } Or is there a better way of altering ...

Calling virtual method in base class constructor

I know that calling a virtual method from a base class constructor can be dangerous since the child class might not be in a valid state. (at least in C#) My question is what if the virtual method is the one who initializes the state of the object ? Is it good practice or should it be a two step process, first to create the object and th...