oop

Should i definitely have a constructor in a derived class?

My problem is like this. I have a XMLUtility class public class XmlUtility { protected string FilePath; protected string XMLFileName; protected XmlDocument SettingsFile; public XmlUtility(string inFilePath, string inXMLFileName) { FilePath = inFilePath; XMLFil...

[PHP]: Use function return as array data in static class definition.

I'm having problems with this class definition because of the definition of $directories. Please help: <?php ..... class Config { public static $directories = array( "resources" => realpath(__DIR__), "root" => $_SERVER['DOCUMENT_ROOT'], "branch" => $_SERVER['DOCUMENT_ROOT'] . "/branch", "templates" => re...

Domain Driven Design question about Services

I'm reading Domain Driven Design Quickly and I'm having trouble understanding something. When the author speaks of Entities, Value Objects and Services, is he speaking of the Domain Model (I mean, the concepts), or already about the implementation? What is a Service? A Controller? A static class? On p38 one can read: When a signif...

How to make a class field [list] read-only in python?

i have self.some_field = [] in my class Im enquiring is there a way to make this list read-only like a property? ...

design workflow/flowchart representation in python ?

In my web application I have wizards with many next previous buttons and choices ( kind of flow chart with events and options ). Wizard do not run in one go, but may wait for external event, user come later or next day to carry on with that wizard. Currently I am manually writing code ( hard coded ) for each states of a wizard ( or a flo...

JavaScript Quiz?

Is this an equivalent 'JavaScript Quiz' site/book to things like : o Ruby Quiz : http://rubyquiz.com/ o Python Challenge o Perl Quiz of the Week I want to improve my object oriented JavaScript skills (i.e. more than striped tables or annoying popups that JavaScript is infamous for). More like 'proper' NodeJS style development. Tha...

[Ruby] How do I access the string name of the parent class from a class method in a extended class or included module.

My problem basically looks like this: module Foo class Bar def self.who self.class.to_s end end end class World < Foo::Bar end When I call World.who I don't get "World" as a result, I get "Class". Some quick Googling didn't yield anything useful, so hence I'm here hoping someone will know how to get the correct cla...

Polymorphism in Clojure

Suppose I have a bunch of Clojure data structures, all of the same type - for example an object type defined by defrecord. What is the best way to get polymorphic behaviour across these structures? Would it be good practice to embed a function within the structure so that I can do something like: ((:my-method my-object) param1 param2)...

Python object oriented model

I have something like the follwing. A person having many colors of cars of the same model belonging to some state. I have designed a person class as having attributes person name, car model, car year, car state, and car color as attributes. And color should be a list as a person can have many cars of different colors but of the same mo...

Return - Method Chaining ....

I have this code: $db->get()->query() Now i want the get method's return to depend on: $db->get() return $db->query var; but $db->get()->query() the get() method will return $this ...

Why this JavaScript OO is wrong?

I will put my code in a simple way, but if any good soul wants to help the code is |on Github| /lib/inmotion/editor.js(line 99) editor.js function Editor(){ var instance = this; this.key_frames = [] // a list of key frames this.kf = null // the current KeyFrame function notice_click( click ){ instance.kf.add_bone( 1 ) ...

how to do $class::function($data);

hi there, i have several classes that have the same function, the are called at different times, depending on different variables, so what i need is something like $class = 'test'; $return = $class::do_something(); but i get Parse error: parse error, unexpected t_paamayim_nekudotayim. which from the looks of it means unexpected :...

what object-based shells are there?

I am planning to write an object-oriented shell (based on Python). I have many ideas already. But before I am going to implement it, I want to inspire me by some existing shell. What I basically mean by object-oriented: Parameters are not just an array of strings but an array of objects. The return value is also an object. There is no...

What's is wrong with this piece of c++ code? I am practising object oriented programming.

#include <iostream> #include <math.h> using namespace std; class Point{ public: Point(int xx, int yy); ~Point(); int getX(); int getY(); void setX(int xx){ x = xx; } void setY(int yy){ y = yy;} private: int x; int y; }; Point::Point(int xx, int yy) { x = xx; y = yy; } Point::~Point() { } in...

Building a generic OO ACL using Doctrine...

I'm looking to design a doctrine-backed ACL system for my own use, although I'm struggling with some of the initial design considerations. Right now I'm looking at making it based on classes and unique identifiers, storing them in a table as such: Table: ACL ResourceClass ResourceKey RoleClass RoleKey Permission O...

How to implement a "function" to be performed on an array in C#

Coming from a non-OO background in Matlab, I'm looking to perform some of the operations I am used to in a best-practice manner for C#. I have a class, which imports data from a source, and formats it into, amongst other things, an array of ints. I am going to want to perform some operations on this array. To keep it simple, lets say ...

Single Responsibility and Mixins

Given that Mixins generally introduce new behaviour into a class, this generally implies that a class would have more than one behaviour. If a class has a single responsibility this is defined as the class having only one reason for change. So, I can see this from two different perspectives The class only has one reason for change....

is it possible to change method property from public to private and back on runtime from inside class ?

like this: if ($sth) make_private($this->method); or maybe there's some other way to affect accessibility of methods ? Problem is that I written a class where methods must be called once, so I need code to restrict access to given method from outside the class after this method was executed. ...

OO Design - Object asks question to class that indirectly holds it

I'm wondering whether an object asking a question to another object that indirectly holds it is "bad" design. For example... Requirements: Character (an object) moves on a grid. When it tries to move to another spot, it needs to know whether that spot is already occupied by something that blocks it, or if that part of the grid is comple...

How do I implement OO with Lua Metatables?

I've never been able to fully wrap my mind about how Lua uses metatables to implement Object Orientation in its programming. I've been reading over the online tutorial directory trying to understand, however the author wrote it with experienced programmers in mind, in which I am not. With abstract ideas and not-noob-friendly variables an...