oop

call another class's function inside a class

Hello there i have 2 classes for DB for language i want to use my language things in the DB so it outputs the result ex : class db_control{ var $db_connection, $lang_var; //create the function for the connection function db_connect(){ //define some variables global $db_host, $d...

Totally failed in OOP/MVC

Hello all! Ok, it's my fault. I've never ever learned programming at a school and that's why i'm always ending up in a spaghetti code. I've always curious about different patterns and tried to understand them at least in a basic level. MVC is my worst fear and i think i'll be never able to use it's advantages because of i don't underst...

How to make my programming designs better?

I'm currently stuck how I should make designing skills as a programmer better. I've seen over a dozen questions about (algorithmic) programming challenges. Defining and verifying a good design isn't as trivial. You can objectively measure how good an algorithm is, but not the design used to implement that algorithm. I do see problems wi...

Writing an class/struct that changes frequently

Summary: I have a struct that is read/written to file. This struct changes frequently, and this causes my read() function to get complex. I need to find a good way to handle change while keeping the bug count low. Optimally, code should be make it easy for one to spot the changes between versions. I have thought through a couple of pa...

Does the logic behind objects matter?

When working on the early stages of a console-based Python remake of snakes, someone submitted a patch to spawn food at random locations. The code defined a Food class which worked fine, but the logic behind it seemed a little weird. I think we should delete the food once it's been consumed, then create another one. However, this person...

Why are many developers opposed to using the "protected" modifier in OOP?

A co-worker of mine is taking an Introduction to Object Oriented Programming class and was asked a discussion question by his professor: Why are many developers opposed to using the "protected" modifer on/within classes? When the question was brought up at lunch, my co-workers and I couldn't think of reasons why someone might be op...

Easy way to pass DB object into class that is extended numerous times

Hey guys, Consider the following PHP code: <?php require_once("myDBclass.php"); class a { private $tablename; private $column; function __construct($tableName, $column) { $this->tableName = $tablename; $this->column = $column; } function insert() { global $db; $db->query("IN...

Evidence for sealed class performance benefit.

My team is wrestling with the sealed class debate internally and I would like to simplify the debate down to a matter of design and get the performance myth off the debate agenda. Can anyone post some code that demonstrates a performance boost introduced by declaring a class as sealed? At 20 million virtual method calls per second I can...

Craigslist Automated Posting API ?

i was looking through craigslist bulk posting section and it requires an rss feed to be sent to a server to automatically post an add the site is found at http://www.craigslist.org/about/bulk_posting_interface i have looked up and down for a sample of a php class but cannot find out. anyone know of any class that exists? thanks ...

How to load data with class composition ?

Hi All, Here are my classes : class PriceScale -int ID -float bookingFees -Product product -List<PricePeriod> periods Class Product -int ID -string name -List<PriceScale> priceScales class PricePeriod -DateTime begin -DateTime end -float price -PriceScale scale As you can see I strictly applied business rules "A product as many pri...

Where to put general functions in OOP?

For illustration purposes let us say I'm building a simple blog application and have a class called Blog: Class Blog(){ __constructor(){ connectToDatabase(); } } Class BlogPost($id) extends Blog { public $title; public $body; etc. } The blogpost class can be instantiated as an object representing a particular...

difference betwenn abstract class and interface

Possible Duplicate: Interface vs Base class Hello all, I am not understanding difference between abstract class and interface, could you tell me please when I need to use which art of type. Thanks a lot and take care, Ragims ...

PHP OOP Theory - Error checking inside or outside of the class?

I'm transitioning to using OOP for all my projects, historically everything I've built has been pretty small and OOP didn't seem to be an efficient choice, but now with large projects it is. However more recently I've been coming across more and more "best practice" questions that I have and I can't find the answer for. For example, ima...

Does this method violate SOLID or has code smell?

Does this give any code smell or violate SOLID principles? public string Summarize() { IList<IDisplayable> displayableItems = getAllDisplayableItems(); StringBuilder summary = new StringBuilder(); foreach(IDisplayable item in displayableItems) { if(item is Human) summary.Append("The person is " + item.GetInfo()); else ...

Control Form from other Classes and other main Problems

I'm not that good in OOP or even C# but I want to try to keep my code as clean as possible. Lets say we've got something like that within the Namespace "GoogleCalendarNotificator": public partial class MainForm : Form { private object calendarData; public MainForm() { InitializeComponent(); ...

OOP in VB.NET - Child, Parent, Parents

I'm trying to do something here with VB that I guess I'm not understanding how to do it exactly. Sorry I'm not that good at OOP. I have a number of things I'm creating and they have two values - parent name and child name (yes, actual people!). So it would be like this: Public Class Child Public Property ParentName As String P...

Some doubts about what Factory does

Hi, I'm not really sure to understand completely the factory pattern. Let's say I have a class Customer which has basically the following methods: CreateCustomer - static, creates a customer from scratch and adds it to the database, LoadCustomer - static, loads an instance of a Customer from the database, KillCustomer - not static, r...

Using the MySQL link returned by mysql_connect() as a global variable?

Hi, Background: We have a class which is used for accessing the mysql database. The methods within this class form a new mysql connection if a link isnt supplied as a parameter. The way we've used the class in the system (not the database class) is to declare a database object and call the appropriate method and let the object scope ...

How do i access a class instance's parent in PHP ?

The only object oriented programming experience I have is from C#, so PHP is throwing me some curve balls I could use some help with. I have a class I use for all my pages, the "pagebase" if you will. It handles the lowest level html structure. That class is inherited by several other classes. Those classes are the different page types ...

Liskov Substitution Principle and the directionality of the original statement

I came across the original statement of the Liskov Substitution Principle on Ward's wiki tonight: What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is subs...