oop

How can i prevent the loading of index function with __construct in CodeIgniter?

Hello, i am building admin area for my app with CodeIgniter, i created a base Admin Controller in the library named: MY_Admin_Base that extends the CI Controller. and there i checking in the DB if the admin has access to the method. class MY_Admin_Base extends Controller { function __construct() { parent::Controller();...

Prototypes in JavaScript

In the JavaScript the same thing you can do in many different ways. Consider the examples: 1: function Circle(radius) { return { "r" : radius, "area" : function(){ return Circle.pi * this.r * this.r; } } } Circle.pi = 3.14159; var a = Circle(10); alert(a.area()); 2: function Circle(radius) { this.r = radius; } Cir...

Help Setting Up Perl Module Structure

I'm having trouble figuring out how to structure Perl modules in an object oriented way so I can have one parent module with a number of submodules and only the specific submodules that are needed would be loaded by a calling script. For example I want to be able to make method calls like so: use Example::API; my $api = Example::API...

when I create an object of a class, does it execute ALL methods inside the class or just methods called?

I am curious, if I create a class of many methods (functions as PHP still call them) which many of them are not used and I create an object, does it create memory for all methods even if most methods aren't being used? I'm doing PHP OOP coding. ...

Organize my domain objects in DDD while using ado entity framework

I have these 2 types of Users: Parents and Kids, both are Users, and have the same properties, but different methods. I Created Base User class and 2 class: Parent And Kid, both inherit form User base class, and each class have some different methods. User class is partial class, because the entity framework model has the same class bec...

C#: Monitoring non-dynamic method calls when working with child classes inheriting from DynamicObject

Let's say I have a class which inherits from DynamicObject: public class DynamicBase : DynamicObject { public override bool TryGetMember(GetMemberBinder binder, out object result) { //Yadda yadda yadda } //same for TrySetMember } and then I have a child class which inherits from DynamicBase: public class ChildCl...

Using my database class with other classes in my project

I have a custom database class that I wrote myself, and I also have a user class and a site class. The MySQL class has methods like this: connect query clean fetch The user class: register login logout resetPass The site class: updateTopics addTopic addPost addReply etc. These classes need to interface with a database, which i...

Interface reference variables

I am going over some OO basics and trying to understand why is there a use of Interface reference variables. When I create an interface: public interface IWorker { int HoneySum { get; } void getHoney(); } and have a class implement it: public class Worker : Bee, IWorker { int honeySum = 15; ...

Object References basics

I a new at OO programming and trying to clear up a few things. When you instatiate a class and create an object, Ive seen the following: class Program { static void Main(string[] args) { MyClassA a = new MyClassA(); MyClassA b = a; MyClassA c = b; c.DoSomething(); ...

Treat events as objects

C# is still not OO enough? Here I'm giving a (maybe bad) example. public class Program { public event EventHandler OnStart; public static EventHandler LogOnStart = (s, e) => Console.WriteLine("starts"); public class MyCSharpProgram { public string Name { get; set; } public event EventHandler OnStart; publ...

Please guide me over this concept of oops

I was faced this question while one of recent interview : class1 { virtual getname(); {//code here..} } class2:class1 { overrides getname(); {//code here..} } class3:class2 { public new getname(); {//code here..} } class4 { class1 obj=new class3(); obj.getname(); } now in class4 which class's method will call ? wh...

read-only properties in PHP?

Is there a way to make a read-only property of an object in PHP? I have an object with a couple arrays in it. I want to access them as I normally would an array echo $objObject->arrArray[0]; But I don't want to be able to write to those arrays after they're constructed. It feels like a PITA to construct a local variable: $arrArray =...

Proper usage of MySQLi

Can anyone instruct me on the proper way to use the MySQLi extension in PHP? I have always used procedural MySQL functions before and want to make the change but am finding the examples on PHP.net and other sites way too complicated. There seems to be multiple methods to do the same thing. I want to use it in the following method: funct...

When does it pay off to use S4 methods in R programming

Hi all, I program regularly in R in a professional context, and I write packages for clients or co-workers as well. Some of the programmers here have a Java background and insist on doing everything the object-oriented way, using S4 methods. My experience on the other hand is that S4 implementations often perform worse and cause a lot m...

num_rows method not bringing back number of selected rows

This is the code: $q = $this->db->prepare("SELECT id FROM `users` WHERE username=? AND password=? LIMIT 1"); $q->bind_param('ss', $username, $password); $q->execute(); printf('Rows returned: %i', $q->num_rows); I am using MySQLi to try and check a users login credentials. Everything works and the query gets executed and data is retur...

trouble with php object inheritance

I am building a page through a series of include files. Many (not all) of the include files are classes of various things that I need stored as objects. For instance, one of my pages is: class site { var $siteid; var $sitename; function __construct($id, $name) { $this->siteid = $id; $this->sitename = $na...

Design question - resolving circular dependency between objects

I got myself into a circular dependency between two classes, and I'm trying to come up with a clean solution. Here's the basic structure: class ContainerManager { Dictionary<ContainerID, Container> m_containers; void CreateContainer() { ... } void DoStuff(ContainerID containerID) { m_containers[containerID].DoStuff(); } } ...

Object Oriented Programming principles

Hi y'all, I was wondering, I recently read an article that spoke of the ills of using the singleton pattern siting the disadvantage of global variable occurrence and rightly that the singleton violates alot of the rules we learn from OOP school, single responsibility principle, programming to interfaces and abstract classes and not to c...

What's the best design to follow for this API in this case?

I'm building an API that post a given message to different platforms (Twitter, FaceBook...). The problem is that for each platform I may change the wrapper that allow me to post the message. For example, in C# I can post a message on twitter using the yedda API or the CsharpTwitt API, for FaceBook I'll use others APIs... Hence, I have ...

Date Created - should this value be set in the BL or DAL?

Date Created a specific example I'm interested in - but there are other bits of data that fall into the same category: data which you'd want to capture about any vaguely important entity. Where best to do this: business logic (BL) or Data Access layer (DAL)? Until now I've relied on SQL Server's getdate() to populate the date created f...