oop

Where can I find some good tutorials to learn object orientated programming particularly for php?

I've been looking to improve my programming habits and I heard that OO is the way to go. Also I'd much prefer online tutorials over books. ...

Mysql Connection Class

Hi - I'm writing some php code, and I'm frequently accessing my MySQL database to read and update fields. My current code includes a class called dbconnnect, and I use it as follows: class edit_data extends dbconnect { //<some php code> parent::connect(); //<get info from database> parent::disconnect(); //<evaluate data> My questio...

Hierarchy & data structure in Java (or XML to Object conversion: best practices)

The problem: Let's say there is an XML file that contains both the data and the hierarchy of certain elements of interest to the application: <root> <node title="lvl1Node"> <node title="lvl2Node"> <node title="lvl3Node"></node> </node> </node> <node title="lvl1Node2"></node> <node title="lvl1Node3"> ...

What is the purpose of python's inner classes?

Python's inner/nested classes confuse me. Is there something that can't be accomplished without them? If so, what is that thing? ...

Use of alloc init instead of new (Objective-C)

Learning Objective-C and reading sample code, I notice that objects are usually created using this method: SomeObject *myObject = [[SomeObject alloc] init]; instead of: SomeObject *myObject = [SomeObject new]; Is there a reason for this, as I have read that they are equivalent? ...

Is the process of design slow?

I'm working on a project where a bunch of software (C++/OO) is being ported to a new hardware environment. A certain percentage of the software modules should be subjectively similar on the new hardware platform. A code review for some of these modules has shown that the port done is been done with a minimal effort or insight - the deve...

How did I break inheritance?

Refactored from bug_report_view.cc and bug_report_view.h, I extracted send_report(), report_phishing(), a few other smaller functions and BugReport::Cleanup into bug_report.cc and bug_report.h (my versions). Compiling now, I get: [...]bug_report.cc:196: error: no matching function for call to ‘URLFetcher::URLFetcher(std::wstring&, UR...

New .NET architecture concepts

I posted this community wiki in the hopes of creating a thread of expertise. My question is thus ... "Where do the experts go to learn about the newest .NET coding techniques?". I'm basically looking for the leading/bleeding edge of .NET architecture, design, development and theory. I know conferences and trade shows are probably the b...

OOP concepts in PHP with forms

I know how to create classes and objects, but I want to know how to integrate FORMS with OOP concepts in PHP. ...

Java Enums can have behavior?

In Java, an Enum can do the great things that Enums do, but can also have methods (behavior and logic). What advantage does that have over using a class using an enum? Simple examples to illustrate the point would also be welcome. ...

How to override method to invoke superclass' superclass method?

Part of me thinks that this shouldn't be possible (even if it is), but I'll ask anyway. Given the following class hierarchy (Grandparent and Parent are from a 3rd party and thus, not under my control), how would I override myMethod() in Child such that it bypasses the overridden implementation in Parent and invokes the one in Grandpare...

How to structure this interface/inheritance

I have a File class that has an Open() method. I have a subclass of File called TextFile that implements an IReadableFile interface, which requires the implementation of a Read() method. If I declare a variable myFile as IReadableFile, I can't call the Open() method on it. I want to be able to exercise the functionality of TextFil...

Scope of .NET's List(Of T).Reverse Method

I've got a simple function that takes a List parameter. While working with it, it copies it and reverses the copy using .NET's List(Of T).Reverse method. Private Function FindThing(ByVal Things As List(Of Thing)) As Thing Dim ReverseOrderThings As List(Of Thing) = Things ReverseOrderThings.Reverse() For Each t As Thing In R...

Egg-chicken problem in OOP way

Hi Guys, I have a chicken-egg problem. I would like too implement a system in PHP in a OOP way, in which two classes would play important roles: Database and Log. My idea was to build up the connection by the Database class, which would have public methods eg. runQuery(sUpdateQuery), doInsert(sInsert), etc. The Log class would writing l...

What is the point of a Data Transfer Object (DTO)?

Why should I use DTOs/Domain objects when I can just put all business classes in a class library, use them in the business logic, then also pass those same business objects on to boundary classes? UPDATE: All are great points, thanks for the help. A follow up question: Where do you typically place these DTOs? Alongside the Domain obj...

DB Design: Favor Abstraction or Foreign-Key Constraints ?

Say we have this scenario: Artist ==< Album ==< Track //ie, One Artist can have many albums, and one album can have many tracks In this case, all 3 entities have basically the same fields: ID Name A foreign of the one-many relationship to the corresponding children (Artist to Album and Album to Track A typical solution to the pr...

Composition vs Inheritance for Equality & Hashcode providers

When comparing entities and aggregate roots I use an ABC, which I borrowed from Oren Eini: Generic Entity Equality. For value objects I was equally ingenious. I used Jimmy Bogard’s Value Object ABC: Generic Value Object Equality Now my question is; should I be favouring inheriting these ABCs or should I perhaps be using the generic equa...

Introducing Brevity Into C# / Java

Background Currently, if I want to create a new object in C# or Java, I type something similar to the following: List<int> listOfInts = new List<int>(); //C# ArrayList<String> data = new ArrayList<String>(); //Java C# 3.0 sought to improve conciseness by implementing the following compiler trick: var listofInts = new List<i...

Which class structure is more desirable?

I'm not sure which of these two "patterns" is the best. Currently I use option A (in conjunction with a provider for implementing persistence), but I'm now erring towards B, especially in light of unit tests being able to use the "dependency injection" model. Option A: class ClassA { ClassA() { } Save(); static List<ClassA> G...

What is a better design?

I have the following class: class User { public function setName($value) { ... } public function setEmailAddress($value) { ... } public function setUsername($value) { ... } public function getName() { ... } public function getEmailAddress() { ... } public function getUsername() { ... } public function isGroupAdministrato...