oop

Class Design Question

This is a super newbie question, I've been programming for a while, but am just learning OOP. I have a class that works with user input via the C# console. There are different methods in this class to gather different input sets. I have another class that takes these input sets and puts them in a database. What is the best way to pas...

Object Oriented Design Questions

I am going to develop a Tic-Tac-Toe game using Java(or maybe other OO Languages). Now I have a picture in my mind about the general design. Interface: Player, then I will be able to implement a couple of Player classes based on how I want the opponent to be, for example, random player, intelligent player, etc. Classes: Board class, ...

Handling incremental Data Modeling Changes in Functional Programming

Most of the problems I have to solve in my job as a developer have to do with data modeling. For example in a OOP Web Application world I often have to change the data properties that are in a object to meet new requirements. If I'm lucky I don't even need to programmatically add new "behavior" code (functions,methods). Instead I can de...

How can I sync three classes?

class Foo { Bar b; List<Foo> Neighbours; } class Bar { Spam s; List<Bar> Neighbours; } class Spam { List<string> Neighbours; } Each of these classes have AddNeighbour,RemoveNeighbour methods. User can add/remove Neighbours from any of the class at random. I want these three objects to be in sync. How can I do ...

string variable not able to get thevalue

hi, i have an variable declated as an object Object obj =e.Row.DataContext; when i go to immediate window and check the value i get like this ?Object obj =e.Row.DataContext; {TempTypeMinus1487405295} People: "7,556,930" Name: "India" string strcounty =obj .Tostring(); now in strcounty i should get as India but i...

OOP/MVC advice on where to place a global helper function

Hi, I have a couple of controllers on my site which are handling form data. The forms use AJAX and I have quite a few methods across different controllers which are having to do some specific processing to return errors in a JSON encoded format - see code below. Obviously this isn't DRY and I need to move this code into a single helper f...

Zend Framework Codes

what is below codes for?(in Zend Framework) i mean what is the job of these? $this->view->default $this->view->action ...

Does String inherit from Object in Javascript?

Is Object the base class of all objects in Javascript, just like other language such as Java & C#? I tried below code in Firefox with Firebug installed. var t = new Object(); var s1 = new String('str'); var s2 = 'str'; console.log(typeof t); console.log(typeof s1); console.log(typeof s2); The console output is object object string ...

To Wrap or Not to Wrap: Wrapping Data Access in a Service Facade

For a while now, my team and I have been wrapping our data access layer in a web service facade (using WCF) and calling it from the business logic layer. Meanwhile, we could simply use the repository pattern where the business logic layer consumes the data access layer locally through an interface, and at any point in time, we can switc...

use of assertions for type checking in php?

I do some checking of arguments in my classes in php using exception-throwing functions. I have functions that do a basic check ( ===, in_array etc ) and throw an exception on false. So I can do assertNumeric($argument, "\$argument is not numeric."); instead of if ( ! is_numeric($argument) ) { throw new Exception("\$argument is not ...

How should I handle expected errors? eg. "username already exists"

I am struggling to understand how I should design the error handling parts of my code. I recently asked a similar question about how I should go about returning server error codes to the user, eg. 404 errors. I learnt that I should handle the error from within the current part of the application; seem's simple enough. However, what shou...

Java Program Design Layout Recommendations?

I've learned enough to begin writing programs from scratch, but I'm running into the problem of not knowing how to design the layout and implementation of a program. To be more precise, I'm having difficulty finding a good way to come up with an action plan before I dive in to the programming part. I really want to know what classes, met...

C++ Typing and OOP child classes

I'm a bit confused: If I have a base class A, and a class B which extends A, can a variable of the type A hold a value of the type B and vice versa? If yes, why? Aren't they completely different even if B is derived from A? How about type-safety? If this is possible, what things do I have to mind when taking use of this? How would ...

access a property via string with array in php?

I have a big list of properties that I need to map between two objects, and in one, the value that I need to map is buried inside an array. I'm hoping to avoid hard-coding the property names in the code. If I have a class like this: class Product { public $colors, $sizes; } I can access the properties like this: $props = array(...

Is there any way to achieve multiple inheritance in php?

Lets say I have a parent class class parent { } ..... This parent has three sub class class child1 { } class child2 { } class child3 { } and these child classes have further smaller parts like class child1subpar1 { } class child1subpar2 { public function foo() { echo "hi"; } } class child2subpar1 { }...

Call empty() on private attributes

I'm using the __get() and __set() magic methods in order to intercept external calls to some private attributes without the need of writing a setter and a getter for each attribute. So far so good: <? class Foo{ private $id; private $info = array(); private $other; public function __set($name, $value){ switch($...

Is it possible to create an enum whose instance can't be created but can be used for readonly purpose

I created an enum where I stored some table names. I want it to be used to get the name of the table like ds.Tables[BGuestInfo.TableName.L_GUEST_TYPE.ToString()]. public class a { public enum TableName : byte { L_GUEST_TYPE = 0 ,L_AGE_GROUP = 1 ,M_COMPANY = 2 ...

Custom Class to store the properties and to pass its instance across the pages - ASP.NET

Hello I've a requirement where i need to pass some objects across the pages. So i created a custom class with all the properties required and created a instance of it and assigned all the properties appropriately. I then put that object in the session and took it the other page. The problem is that even when i set the properties values...

PHP Object Oriented - Best way to implement multiple user roles

I have three types of users: A, B, C .. Hence a user base class and then we have 3 derived classes. However it is possible for a user to be of 2 types at the same time. How would we go about dealing with this in a decent fashion, keeping in mind the type(s) of the user will define the kind of access they have in an application. ...

How to Execute Base Class's Method Before Implementors's Method?

I have the following page public partial class GenericOfflineCommentary : OfflineFactsheetBase { } where OfflineFactsheetBase is defined as public class OfflineFactsheetBase : System.Web.UI.Page { public OfflineFactsheetBase() { this.Load += new EventHandler(this.Page_Load); this.PreInit += new EventHandler(t...