public class Song {
public string Genre { get; protected set; }
public string Name { get; protected set; }
public string Band { get; protected set; }
public Song(string name, string band, string genre) {
Name = name;
Genre = genre;
Band = band;
}
}
public interface IMusicVisistor
{
void V...
Is it bad practice to concatenate objects when used in this context:
$this->template->head .= new View('custom_javascript')
This is the way i normally add extra css/js stuff to specific pages. I use an MVC structure where my basic html template has a $head variable which I set in my main Website_controller. I have used this approach f...
I'm currently writing SDK documentation for one of our products, but for obvious reasons I don't want to talk about the essentials of OOP. Does anyone know any good online teaching material that explain (aimed at absolute beginners) concepts such as classes, inheritance, constructors, instances etc.? Preferably urls that are likely to su...
This is very basic question from programming point of view but as I am in learning phase, I thought I would better ask this question rather than having a misunderstanding or narrow knowledge about the topic.
So do excuse me if somehow I mess it up.
Question:
Let's say I have class A,B,C and D now class A has some piece of code which...
I've been writing a system that at runtime generates some templates, and then generates some objects based on those templates. I had the idea that the templates could be extensions of the Class class, but that resulted in some magnificent errors:
VerifyError: Error #1107: The ABC data is corrupt, attempt to read out of bounds.
What I'...
in code igniter you can type:
$query = $this->db->query("YOUR QUERY");
foreach ($query->result() as $row)
{
echo $row->title;
echo $row->name;
echo $row->body;
}
i guess that the query method returns the object it's part of. am i correct?
if i am, how do you type the line where it returns the object?
so what i wonder is ho...
I recently learned a lot about MVC design pattern which is a very interesting concept. I would assume there are a lot more design patterns out there, and I thought it would be great for people to share some.
Here's my contribution, MVC design pattern:
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
...
Hi SO.
I am learning a lot about design patterns when I am building my own system for my projects. And I want to ask you about a design question that I can't find an answer to.
Currently I am building a little Chat-server using sockets, with multiple Clients. Right now I have three classes:
Person-class which holds information like n...
Hi,
I have an abstract class with some methods,including an abstract method(Execute()).This method is overridden in child class.Now, an event is raised(somewhere in application),and for this event there is a handler in base class.And,in this handler,I call Execute.
Now, the method of chilobject is executed.I am bit confused,how this wor...
I am trying to create a UserDon object, and trying to generate the get and set methods programmatically ( based on Pro Javascript book by John Resig page 37 ), and am testing this on Firefox 3.5
The problem is: in function UserDon, "this" refers to the window object instead of the UserDon object.
So after calling var userdon = new Use...
I came across this slide: http://www.slideshare.net/stoyan/javascript-patterns#postComment
at page 35:
Option 5 + super + constructor reset
function inherit(C, P) {
var F = function(){};
F.prototype = P.prototype;
C.prototype = new F();
C.uber = P.prototype;
C.prototype.constructor = C; // WHY ???
}
I don't get ...
I have recently encountered some issues with merely passing references to objects/enemies in a game I am making, and am wondering if I am using the wrong approach.
The main issue I have is disposing of enemies and objects, when other enemies or players may still have links to them.
For example, if you have a Rabbit, and a Wolf, the Wol...
public abstract class Request
{
public class Parameters
{
//Threre are no members here
//But there should be in inherited classes
}
public Request()
{
parameters = new Parameters();
}
public Parameters parameters;
}
Two questions:
How do I make it so I can add stuff to the constructor but t...
I want to create an array of objects, so what I did was to create a library but I can't figure out how to actually dynamically create instances of it in a loop and store each instance in an array.
Can anyone tell me please?
...
Is it bad policy to have lots of "work" classes(such as Strategy classes), that only do one thing?
Let's assume I want to make a Monster class. Instead of just defining everything I want about the monster in one class, I will try to identify what are its main features, so I can define them in interfaces. That will allow to:
Seal the c...
i've been programming for a while, but have never had a formal computer science education. i would like to know if there is a resource that goes over the key programming concepts like construct, polymorphism etc, that would be applicable to different languages. also it would be highly helpful if the resource would give examples.
...
I know that in OOP you want every object (from a class) to be a "thing", eg. user, validator etc.
I know the basics about MVC, how they different parts interact with each other.
However, i wonder if the models in MVC should be designed according to the traditional OOP design, that is to say, should every model be a database/table/row (...
i have a class that extends another.
when i iterate the current object i get all properties, even those from the superclass.
i only want to iterate through the current object. how could i do that?
foreach($this as $key => $value) {
echo $key . ': ' . $value;
}
...
I have seen many answers on stackoverflow, but I didn't find an answer that is matching mine.
Apart from all those difference, Does it make sense if we say an abstract class abstracts the implementation of behaviour while an interface abstracts the type which implements the behaviour.
...
I understand it is a very basic concept in the oops. But still I cannot get my head around. I understood why member variables are private, so class user cannot abuse it by setting up invalid values.
But how can this apply to the methods ?
...