oop

Java - How to refresh knowledge? (2 years ago)

I have my first ever interview for a Java developer role, specifically RMI, Serverlets and JDBC. However, it has been a while (2 years) since I have done any Java coding. I am sure I still have it up there somewhere and I do remember the Java syntax I wanted to ask how can I re-fresh everything in 2-3 days specially the OOP concepts (p...

Beans, methods, access and change? What is the recommened practice for handling them (i.e. in ColdFusion)?

I am new to programming (6 weeks now). i am reading a lot of books, sites and blogs right now and i learn something new every day. Right now i am using coldfusion (job). I have read many of the oop and cf related articles on the web and i am planning to get into mxunit next and after that to look at some frameworks. One thing bothers m...

Using the object literal notation with jQuery

Hi, the other day I read this article by Alan Storm called "Using jQuery and the Object Literal Singleton/Module Pattern". Now I'm wondering if any of you are writing jQuery code using the object literal notation a lot? I'd be happy to check some code examples and/or get advise on when it actually makes sense to use this notation. Tha...

Finite State Machine in Objective-C

Does anyone have a solution for a basic, compact Finite state machine/automata written in Objective-C code? I am interested in reusable components so that the FSM have states added and actions defined that use reusable state classes. ...

Javascript calling public method from private one within same object ...

Can I call public method from within private one: var myObject = function() { var p = 'private var'; function private_method1() { // can I call public mehtod "public_method1" from this(private_method1) one and if yes HOW? } return { public_method1: function() { // do stuff here } }; } (); ...

What are the core concepts in functional programming?

In object-oriented programming, we might say the core concepts are: encapsulation inheritance, polymorphism What would that be in functional programming? ...

OOP fatal error

What am I doing wrong here folks? <?php include 'header.php'; /** * Display a user's profile */ $id = $db->real_escape_string($_GET['id']); $user_res = $db->query("SELECT * FROM users WHERE id = $id"); $user = $user_res->fetch_assoc(); ?> <h1><?php echo $user['username'] ?>'s Profile</h1> <?php include 'footer.php'; ?> Equals to: ...

Constructors in Javascript objects

Can Javascript classes/objects have constructors and how are they created? Any examples? ...

Dynamic Casting in C#

Picture the following situation. I have an XML document as follows, <Form> <Control Type="Text" Name="FirstName" /> <Control Type="DateTime" Name="DateOfBirth" /> <Control Type="Text" Name="PlaceOfBirth" /> </Form> I have an abstract class called Control with a single abstract method called Process which takes a single par...

Persisting complex configuration to a file (PHP)

I have a fairly large MVC PHP web app (custom, no framework) that uses a several-hundred-line XML file for configuration. The config data has a fairly complex structure, which is very elegantly represented in XML but not so easily read or written using the DOM. All reading and writing of config data goes through a Config class, which has...

Ambiguous Polymorphism?

In situations where two interfaces apply to an object, and there are two overloaded methods that differ only by distinguishing between those interfaces, which method gets called? In code. interface Foo {} interface Bar {} class Jaz implements Foo, Bar {} void DoSomething(Foo theObject) { System.out.println("Foo"); } void DoSomet...

Dealing with multiple input parameters using wrapper class

As a sort of continuation of this, I have the following newbie question: What difference is there in building a wrapper class that expects lots of inputs parameters and inputting those parameters directly into the final constructor? Don't get me wrong, I think the multiple input parameter thing is pretty ugly, and I'm trying to get aro...

private or protected variables?

I am currently reading Code Complete where McConnell strongly encourages making all variables private. Coincedentally I just so happened to be working on a project where I needed to change a private variable. The class had a private variable (a String) telling it where to load an image from to use in the system chrome. I needed to chang...

getting only name of employee by his ID. So one static class with only one method?!

Hi I need to get name of an employee by his ID by querying to DB. It seems that need a class. But a class with only one method.....is it good idea or what else do you suggest? ...

How can I have references between two classes in Objective-C?

I'm developing an iPhone app, and I'm kinda new to Objective-C and also the class.h and class.m structure. Now, I have two classes that both need to have a variable of the other one's type. But it just seems impossible. If in class1.m (or class2.m) I include class1.h, and then class2.h, I can't declare class2 variables in class1.h, if ...

PHP solution for creating a list of static value objects

I have a configurable report. For each field that can be included on the report, there's a key (stored in report preferences), a label, potentially an access level, and a SQL descriptor -- something like foo as my_foo. In a Java app, I would create a class called ReportField with each of the properties listed above. I'd use a private c...

Not object although var_dump() says otherwise?

Hello, I have a problem. When I create controller, I load model (AccountModel) to class variable "Model" and check if user is logged in: function __construct() { parent::__construct(); $this->loadModel("AccountModel", "Model"); $account = $this->getUserAccount(); ... } Fatal error occurs in getUserAccount(): ...

How do you cast an instance to a derived class?

I am trying to use a little inheritance in a Python program I am working on. I have a base class, User, which implements all of the functionality of a user. I am adding the concept of an unapproved user, which is just like a user, with the addition of a single method. The User class has some methods that return a User object. This wi...

c++ templatized interface

This is best described in pseudo-code: class Thing {}; interface ThingGetter<T extends Thing> { T getThing(); } class Product extends Thing {}; class ProductGetter<Product> { Product getThing() { // Some product code } } class SpecialProductGetter extends ProductGetter { Product getThing() { p = Produ...

C# / Object oriented design - maintaining valid object state

When designing a class, should logic to maintain valid state be incorporated in the class or outside of it ? That is, should properties throw exceptions on invalid states (i.e. value out of range, etc.), or should this validation be performed when the instance of the class is being constructed/modified ? ...