oop

C# Console App Session/Storage

What would be the best way to implement a psuedo-session/local storage class in a console app? Basically, when the app starts I will take in some arguments that I want to make available to every class while the app is running. I was thinking I could just create a static class and init the values when the app starts, but is there a more e...

What is the alternative to excessive use of the dot operator in Obj-C?

See what you think of this line of code: if ([pickerViewController.picker.bvc.currentResolve.name isEqualToString:message]) ... Would you consider this to be excessive use of the dot operator? If not, I can leave it as-is. But if so, what's the preferred alternative? ...

Lua, C++, and poor man's subclassing

I'm lead dev for Bitfighter, and we're working with a mix of Lua and C++, using Lunar (a variant of Luna, available here) to bind them together. I know this environment does not have good support for object orientation and inheritance, but I'd like to find some way to at least partially work around these limitations. Here's what I ha...

correct use of 'construct' when designing classes

I am new to object oriented programming and writing some of my first classes for a PHP application. In some of the simpler classes, I declare a function __construct(), and inside of that function, call certain class methods. In some cases, I find myself instantiating the class in my app, and not needing to do anything with the resultant...

Overriding System.Diagnostics.Trace.WriteLine to log to a file

This may be more of an OOP concept question, but here's what I'd like to do. I have an application that outputs debug information using System.Diagnostics.Trace.WriteLine so it can be viewed with DebugView. I'd like to override/extend (not sure of the proper terminology) this method to log the text to a file instead, or maybe in additi...

Object to Object Mapping Utility

I like to cleanly separate public and domain objects (so, nHibernate isn't going to help here) from each other which ends up forcing me to write a lot of code to map one object to another. What tools/plugins are out there to take the tedium of having to do manually do this mapping in .NET?m Whenever I Google this, it thinks I'm wanting...

Why are Haskell algebraic data types "closed"?

Correct me if I'm wrong, but it seems like algebraic data types in Haskell are useful in many of the cases where you would use classes and inheritance in OO languages. But there is a big difference: once an algebraic data type is declared, it can not be extended elsewhere. It is "closed". In OO, you can extend already defined classes. Fo...

Problem with OO programming in javascript and ASP.NET AJAX

Hi, I'm trying to keep as much OO as possible, but ASP.NET AJAX seems to be doing something strange after returning from the server... function Person( personId ) { var id = personId; var firstName; var lastName; this.initializeStep1 = function() { PeopleServices.getFirstName(id, this.initializeStep2); } this.initializeStep2 = fu...

How do you deal with asp.net server callbacks within javascript objects?

I'm having a problem with using server callbacks to webmethods within an object in javascript... function myObject() { this.hello = "hello"; var id = 1; var name; this.findName = function() { alert(this.hello); //Displays "hello" myServices.getName( id, this.sayHello ); } this.sayHello...

How to create a method for an array class?

Sorry, I know this is programming 101, but I can't find any good documentation... I have an array, and I want to cast each member as an object and then call them by the name assigned (this would be so much simpler if javascript allowed for non-number index values). For instance: var things = ['chair', 'tv', 'bed']; var costs = ['10',...

Can someone summarise visibility choices for Java interfaces?

I have two questions really: 1) When would you use a package-private interface? 2) Is there a way to have a public interface which is closed for implementation outside its package? ...

What is the difference between the shape and structure of an object?

Title says it all. I see it used a lot in context of data. From ScottGu's post: One of the really powerful capabilities provided by LINQ and query syntax is the ability for you to define new classes that are separate from the data being queried, and to then use them to control the shape and structure of the data being re...

when do we create this type of object in C#...?

I have seen following type of scenario in some websites..can anybody help me when do we use this type scenario exactly...? class emp { public void add() { MessageBox.Show("Emp class"); } } class dept : emp { public void disp() { MessageBox.Show("dept class"); } } emp ee = new dept(); I just w...

How to model an OO style interface for C functions?

I have a C module which is created by the Real-time Workshop based on a Simulink Model. This modules provides three public functions: int init(); int calc(double *inputarray, double *outputarray); int term(); Based on the contents of the outputarray, I can model a class called OutputThing. I want to integrate those functions in a wra...

Deep vs. Flat Object Model

Which would you recommend - a deep objects hierarchy (where each object hold a reference to it child objects), or flat objects (where you provide services to retrieve child objects)? Let's assume that you are creating a database management application. You will have objects such as: Server Database Columns Views Which option would y...

Database access from everywhere in application

Hi, If I wanted to access a database in Delphi, I could add a datamodule to a project, configure it from my mainform and then access it anywhere in the application; a reference would be stored in a global variable. I know that in C# and other more modern OO languages global variables are frowned upon. So how can I access my database fr...

Advantages of prototype based OO over class based

Why is class based OO so popular instead of prototype based OO? Do they teach the latter in schools? Javascript is object based, but people use it mostly functionally, or via frameworks. I know that Sun has had some research on Self, but is there any other source of knowledge; preferably something that is accessible for self learned. I...

ORM classes with collections; trying to maintain focus on parent class rather than children.

Let's say I have a Farmer class, and a Farmer has a collection of Pigs. If I use an ORM like Hibernate, I can cascade updates to a Farmer's Pig collection, such that I can do something like this from my controller: Pig pig = new Pig("Charlie"); farmer.addPig(pig); farmerService.save(farmer); My farmer service doesn't know anything ab...

Extract data from PHP Object

I'm using the Facebook API and the class produces this object. object(User)#4 (5) { ["fbc_uid"]=> string(9) "324234324" ["fbc_first_name"]=> string(5) "James" ["fbc_last_name"]=> string(5) "Proud" ["fbc_name"]=> string(11) "James Proud" ["fbc_email"]=> NULL } How do I ...

Object of type 'System.Reflection.ParameterInfo' cannot be converted to type 'System.Int32'

I'm trying to write an extension method for objects that will dump the structure of the object to the debug output. I'm running in to a problem when the propertyInfo is indexed (GetIndexParameters().Length >0). I've tried using the following: object value = propInfo.GetValue(myObject, propInfo.GetIndexParameteres()); this results in...