php - If Singletons are bad then why is a Service Container good?

Service Locator is just the lesser of two evils so to say. The "lesser" boiling down to these four differences ( at least I can't think of any others right now ): Single Responsibility Principle Serv... Read More

c++ - Will an 'empty' constructor or destructor do the same thing as the generated one?

It will do the same thing (nothing, in essence). But it's not the same as if you didn't write it. Because writing the destructor will require a working base-class destructor. If the base class destru... Read More

c# - downcast and upcast

That is correct. When you do that you are casting it it into an employee object, so that means you cannot access anything manager specific. Downcasting is where you take a base class and then try an... Read More

java - How do I prevent the modification of a private field in a class?

If you can use a List instead of an array, Collections provides an unmodifiable list: public List<String> getList() { return Collections.unmodifiableList(list); }... Read More

oop - JavaScript override methods

Edit: It's now six years since the original answer was written and a lot has changed! If you're using a newer version of JavaScript, possibly compiled with a tool like Babel, you can use real classe... Read More

php - Laravel: Difference App::bind and App::singleton

It's exactly like that. A very simple proof is to test out the behavior. Since the Laravel Application simply extends Illuminate\Container\Container, we'll use just the container (in my case I even o... Read More

oop - Access parent's parent from javascript object

I simply added in first function parentThis = this; and use parentThis in subfunction. Why? Because in JavaScript, objects are soft. A new member can be added to a soft object by simple assignment (... Read More

architecture - How do you design object oriented projects?

The steps that I use for initial design (getting to a class diagram), are: Requirements gathering. Talk to the client and factor out the use cases to define what functionality the software should ha... Read More

oop - Polymorphism - Define In Just Two Sentences

Polymorphism allows the expression of some sort of contract, with potentially many types implementing that contract (whether through class inheritance or not) in different ways, each according to the... Read More

java - Should we @Override an interface's method implementation?

You should use @Override whenever possible. It prevents simple mistakes from being made. Example: class C { @Override public boolean equals(SomeClass obj){ // code ... } } This d... Read More