oop

stdClass Object foreach PHP

Hi, Been searching for a solution for my problem. Seams meny has the same q as me, but still haven't got a solution for my problem. I have a stdClass Object that needs to be printed out in a foreach or somlike like that. Here is a cut of the result i get with a "print_r($result)". stdClass Object ( [ServiceGroup] => Array ...

What OOP concept deals with the following situation?

Hi All I'm just starting to learn Java and I'm struggling to find the correct way to implement the following. I have a Class called State. This Class has a field called stateCaptial. I create a State object. Then I want to create many Town objects that are linked to the one State object, If I query the town for its state capital it...

What are the must-have object oriented skills on a resume for a mid-level software engineer?

Have been working for over a year as a software engineer. I work with core Java and XML. I was thinking of beefing up my resume/acquiring object-oriented skills that would be nice must-have's on my resume. Any suggestions of what would be nice must-have's for a mid-level software engineer? Please be as specific as you can. Thanks! ...

Have I good sense of static method

I have class Country which has collections of Cities. At client I use webmethod [WebMethod] public void AddCity(string countryCode,string name) { MyFacade.AddCity(countryCode,name); } at Facade I have method public void AddCity(string countryCode,string name) { Country.AddCity(countryCode,name); <-in this method is simple sql opera...

How to call a variable in a object Objective-C

Hi, i have 2 class: main.m second.m. If i have in main.m - (void)ok { NSString *myString = @"OK!"; return myString; } How to call myString or "-(void) ok" function from second.m? Thanks. ...

Optimal way to store units of measure for Stock items

Hi all, Assuming a schema structure as such. ----------------------------------------- Stock (ID, Description, blah blah) ----------------------------------------- StockBarcode (ID, StockID, Barcode, Price, blah blah) ----------------------------------------- What is the optimal way of storing units of measure for your stock items? G...

call_user_func(array($this, $method), $par) from parent's constructor?

Hello, class Parent { public function __construct($method) { call_user_func(array($this, $method), 1); } } class Child extends Parent { public function __construct($method) { parent::__construct($method); } protected function call_me_on_construct($par) { echo $par; } } Creating instance of $child = new C...

Are there drawbacks to creating a class that encapsulates Generic Collection?

A part of my (C# 3.0 .NET 3.5) application requires several lists of strings to be maintained. I declare them, unsurprisingly, as List<string> and everything works, which is nice. The strings in these Lists are actually (and always) Fund IDs. I'm wondering if it might be more intention-revealing to be more explicit, e.g.: public class ...

How do you move an internal function to an external Actionscript 3 class file?

I have this catcher game, where soda bottles falls on to the stage, and we use a character as a cursor to catch it. But all the actionscript is built in already into the file internally. But I was asked to put the two classes I use (the cursor and the falling soda bottles) in an external classfile. And since I'm really new to OOP I real...

c++ singleton implementation : pimpl idiom for singletons, pros and cons

When implementing singletons in c++, I see two ways to store implementation data : (A) put all implementation data in the private section and implement class as usual (B) "pimpl idiom for singletons" : hide implementation data by placing it to the 'Impl' structure, which can be defined in the implementation file. Private section conta...

Developing an API layer. Need some advice and feedback about usage of Decorator pattern.

Hi, I am developing an api layer for my application. I have designed a structure and need some advice/feedback for it. You can find the basic implementation of the structure at the bottom. Here are my requirements for the structure: Response from API commands may need to be formatted in different formats (JSON,XML,etc.) Some API com...

How to transform this simple OOP program to a functional-programming language?

During the last months I have tried to code using the functional programming paradigm. Now I have a solution in OOP and I am trying to find a functional solution. The problem is simple. I have an algorithm, which produces two different arrays as result (a and b). Now, I want to check how good the results are. Therefore I write several ...

Need help with AS3 Class Design - Refactoring

Hi all, I have a "Course" class which contains collection of "CourseItems". Each CourseItem has a folder associated with it(for its files). I need to add the CourseItem to a Zip file and after zipping it encrypting. Using FZip and As3crypto I can do the zip and encrypt the zip file. Whether to do Encryption or not is upto the user . Cur...

Java: generics inheritence confusion

Hey, Imagine we have following classes: public interface MyInterface<T> { List<T> getList(T t); } abstract class BaseClass<T extends Number> implements MyInterface<T> { @Override public List<T> getList(Number t) { return null; } } class ChildClass extends BaseClass<Integer> { @Override public List<Inte...

Need help designing class factory

Hi, I have certain classes that have common feature - class factory that I need to put into base class. // This class needs to be designed public class Base { // this function is no good because it returns object, and needs to return derived class static object Create(byte[] data) { MemoryStream ms = new MemoryStrea...

Is there a benefit to creating a very generic data model for a Rails 3 Project?

A Product can have lots of things said about it, I'll call them Properties. It can have a brief description. But that description can be in multiple languages. Likewise, it can have multiple Prices, some which are specific to Customers. Given the following data: Product: identifier: 123-ABC Price: value: $1.25 currency: ...

Basic question about OOP Class Structure with LINQ

I have this situation: public class busOrder: IbusOrder { public Order vOrder { get; set; } MyDataContext db = new MyDataContext(); public busOrder(int pOrderId) { vOrder = db.Orders.SingleOrDefault(p => p.Id == pOrderId); } public int SaveNew() { ... } public int GetStatus() {...

Declaring vars in PHP class

Are there any consequences to not declaring variables at the start of the class declaration. I mean, I always do it because it is just neater and nicer, but my latest project is huge, and I have added loads of vars without declaration in the heat of the moment without consequence. I am now about to go and add them all to the opening decl...

How to use an IoC Container?? I don't get it

Here's what I know so far: DI lets me build reusable, unit-testable components DI is verbose because it requires that I explicitly set the dependencies (via constructor or method. I still don't understand the interface injection though). This is why a container or a service locator is needed. Container is better than service locator be...

DBAdapter design question

Hello. I'm developing an Android application with a database. That database will have more than three tables. Now I'm working on a class called DBAdapter to access the SQLite Database. DBAdpater will have five methods for every table on database (insertEntry, removeEntry, getAllEntries, getEntry and updateEntry). So, if I have five t...