oop

what is the difference between static class and normal class?

when i prefer static or normal class? Or what is the difference between them? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace staticmethodlar { class Program { static void Main(string[] args) { SinifA.method1(); } } static class SinifA ...

PHP oop build array

Hi! If I would need to build up an array with OOP based PHP, would this be the proper way to do it? class MyClass { $array = array(); function addElement($value) { $this->array[] = $value; } function fetch() { $return = $this->memcached->getMulti($this->array); return $return; }...

why can not create instance from any class out side of constructor?

why i generate instance outside of class. i give inheritance snifC to sinifD i need to create instance sinifC sinifc= new sinifC() in SinifD out side of constructor? public class sinifC { public void method3() { Console.WriteLine("Deneme3"); } } public class sinifD : sinifC { ...

PHP OOP: Chainable objects?

Hi everybody, I have tried to find a good introduction on chainable OOP objects in PHP, but without any good result yet. How can something like this be done? $this->className->add('1','value'); $this->className->type('string'); $this->classname->doStuff(); Or even: $this->className->add('1','value')->type('string')->doStuff(); Tha...

What is the best desing pattern to design the interface of an WebPage?

I am trying to build the interface of my WEB site using OOP. For this I need to have several objects like menu, thumbnails, contentBoxes joined together to form a complete layout. I know OOP is not used for presentation but I need to do it anyway. Can anyone help me on this? ...

PHP OOP: Parenting objects/functions?

Hi everyone, How is parenting functions in PHP done properly according to the following example? Can I make sure that my array isn't overwritten and the previous values inside array lost, on each addArray call? function arraybase() { $this->array = new ArrayObject(); return $this; } function addArray($value) { parent::$t...

PHP MVC: How to implement an effective Controller/View Association like ZendFramework guys do!

Hi, I am making my own PHP-MVC framework. i have a question regarding Controller and View Association. I love the way Zend framework uses view within Controller as follow: $this->view->data = 'Data here'; so it can be used in view as follow: echo $this->data; I am wondering how can i implement this association. I want to remove c...

Get class instance by class name string

Hi all, I noticed the function Object.factory(char[] className) in D. But it does not work like I hoped it would work; it does not work ;) An example: import std.stdio; class TestClass { override string toString() { return typeof(this).stringof; // TestClass } }; void main(string[] args) { auto i = Object.fac...

How to do OOP Based Web Design in PHP?

How to do OOP Based Web Design in PHP? May be you could link to me a post containing a tutorial or reference to Design Web in OOP Fashion? ...

What is the Rule of Thumb on Exposing Encapsulated Class Methods

Consider the following analogy: If we have a class: "Car" we might expect it to have an instance of "Engine" in it. As in: "The car HAS-A engine". Similarly, in the "Engine" class we would expect an instance of "Starting System" or "Cooling System" which each have their appropriate sub-components. By the nature of encapsulation, is it ...

Why is there a constructor method if you can assign the values to variables?

I'm just learning PHP, and I'm confused about what the purpose of the __construct() method? If I can do this: class Bear { // define properties public $name = 'Bill'; public $weight = 200; // define methods public function eat($units) { echo $this->name." is eating ".$units." units of food... <br />"; ...

Single Responsibility Principle usage how can i call sub method correctly?

i try to learn SOLID prencibles. i writed two type of code style. which one is : 1)Single Responsibility Principle_2.cs : if you look main program all instance generated from interface 1)Single Responsibility Principle_3.cs : if you look main program all instance genareted from normal class My question: which one is correct usage? whic...

Question about OOP and objects.

I have a school assignment: a Dog Show. My assignment is to create a website, where vistors can display results, and where Judges and Secretary can admin and CRUD. I have a small problem, one part of the assignment: the result should be based on two decisions from different judges, and after that checked by the secretary, before the re...

Using Zend_Db and multiple tables

I have a normalized database that stores locations of files on the internet. A file may have multiple locations spread across different sites. I am storing the urls in two parts (Site.UrlStart, FileLocation.UrlEnd). The UrlEnd is the part unique to that file (for the site). Simplified Db structure: I am using Zend_Db as my ORM (If it...

Why is my class method not visible when I implement an interface in my class?

i can not see MyLoad.TreeLoader(.... but why i can not see? i implemented iloader to TreeViewLoad. i should see TreeLoader why? namespace Rekursive { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) ...

How to signal object instantiation in a Collaboration/Communication Diagram?

I'd like to know how to translate the following line of code to a Collaboration Diagram: Food food = new Food("abc", 123); I know that I can call an Food's method using the following notation: MyStaticMethod() ----------------------> -------- | | | Food | |...

Why must use "out" instead of ref ?

i wrote some code blocks about ref -out declaration. i think that ref is most useful out. Ok. why i need to use out. i can use always ref everytime: namespace out_ref { class Program { static void Main(string[] args) { sinifA sinif = new sinifA(); int test = 100; sinif.MethodA(...

"Abstract static" method - how?

There are already several SO questions on why there is not abstract static method/field as such, but I'm wondering about how one would go about implementing the following psuedo-code: class Animal { abstract static int getNumberOfLegs(); // not possible } class Chicken inherits Animal { static int getNumberOfLegs() { return 2; ...

UML - Object Method Returns a Collection

How can I indicate that a method will return a collection of objects in UML? Is there a better way to explain the relationship than to have a collection class as a return type? ...

I'd like to learn a new (non-OOP) language.

For the past few years I've been dabbling in object-oriented languages like Python and Ruby, but the OOP concept never really meshed with me. Right now, I'm eager to learn something based on a different paradigm. ...