I am trying to inherit a non-static class by a static class.
public class foo
{ }
public static class bar : foo
{ }
And I get:
Static class cannot derive from type.
Static classes must derive from
object.
How can I derive it from object?
The code is in C#.
...
I'm looking for a journal which discusses OOP and modern programming technologies.
Can anyone recommend any?
...
Duplicate: http://stackoverflow.com/questions/56867/interface-vs-base-class
I have been getting deeper into the world of OOP, design patterns, and actionscript 3 and I am still curious how to know when to use an Abstract class (pseudo for AS3 which doesn't support Abstract classes) and an interface. To me both just serve as templates...
Hi, I would like to know what are the best practices for using asp.net DataBinding, in terms of maintainability.
I don't want the application to fall appart when I have to make changes to the database.
Should I databind completely in codebehind ? I am planning on using ObjectDataSources for the databinding. Is there something that is ...
Let's say I have a list of objects of the same type. I want to iterate over that list of objects and execute a "dangerous" method on each of them. If an exception occurs in that method, is it bad practice to have the method itself catch the exception and set an error property on the object?
Here's a quick example where the Start() m...
Given a class that is semantically supposed to be an object of a certain type, but also has multiple operations for operating on objects of its own type, what is the best way(pattern?) of organizing the class in this type of scenario? I find this to be a common occurrence when a developer creates objects but is thinking with a procedural...
The application I'm working on has a single class that maintains a database connection. All members of this class are static to enforce a singleton-like pattern, so the actual connection logic is performed in a static initializer block:
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
...
I have written a page here on using arrays as proper objects with their own methods instead of relying on helper classes like Arrays, Arrays and ArrayUtils.
ints.sort(); // instead of Arrays.sort(ints);
// instead of int[] onemore = ArrayUtils.add(ints, 8);
int[] onemore = ints.add(8);
I am sure I am not the first with this idea but...
I hope this isn't a duplicate...
What is the most solidly designed and implemented software system/framework/application that you've come across?
It seems like TDD, SOLID principles, OO design patterns, and things like that can be easily theorized on podcasts and blogs using really simple examples, but it's hard to imagine developing ...
All Objects in actionscript3.0 inherit from the Object class, but the actionscript3.0 compiler seems not to be smart enough to understand this.
take a look at the following code:
package{
public class TestOne{
public function TestOne(){
var t2: TestTwo = new TestTwo();
trace(t2.toString()); // COMPILE TIME ERRO...
I recently read an interesting comment on an OOP related question in which one user objected to creating a "Manager" class:
Please remove the word manager
from your vocabulary when talking
about class names. The name of the
class should be descriptive of its'
purpose. Manager is just another word
for dumping ground. Any
...
I am using multithreading in my C# code as follow:
Thread startThread;
public void NewThread()
{
ThreadStart starter = delegate { foo(); };
startThread = new Thread(starter);
startThread.Start();
}
private void foo()
{
//do some work
}
And then in my application I call NewThread()to run the new thread.
But now I am havi...
User Login functionality is very common to many applications. I would like to see how people implement this functionality in Object oriented way.
I have a User and I need to validate the userId and password against a system(this could be ldap, database, etc.). So what kind of classes and operations you would create to achieve this funct...
A typical problem in OO programming is the diamond problem. I have parent class A with two sub-classes B and C. A has an abstract method, B and C implement it. Now I have a sub-class D, that inherits of B and C. The diamond problem is now, what implementation shall D use, the one of B or the one of C?
People claim Java knows no diamond ...
I somehow must have overlooked the "tell, don't ask" OOP principle all these years because I just learned about it a couple days ago for the first time.
But the context was a discussion about validation code that had been moved out of an ASP.NET web form page and into a data/business object, and there was no "Validate()" method, just a ...
Given the following code:
Class User{
Task m_Task;
public function getTask("Do work") { return m_Task; }
}
Class Project{
Task m_Task;
public function getTask("Do work") { return m_Task; }
}
Class Task {
private m_Name;
public Task(name) { m_Name = name; }
}
Class Evil {
new Task = Error
}
In a language that does ...
If I add a new case class, does that mean I need to search through all of the pattern matching code and find out where the new class needs to be handled? I've been learning the language recently, and as I read about some of the arguments for and against pattern matching, I've been confused about where it should be used. See the followi...
Imagine these relationships:
1 A has many B's
1 B has many C's...
In reverse:
C has 1 B
B has 1A
By transitivity, C has 1 A
To model this relationship in DB, we have:
TableA
a_id
TableB
b_id
a_id (fk to TableA)
TableC
c_id
b_id (fk to TableB)
To model this relationship in OO, we have:
objA
objB
objC
And...
- objB has re...
I'm currently working on a simple game in Java with several different modes. I've extended a main Game class to put the main logic within the other classes. Despite this, the main game class is still pretty hefty.
After taking a quick look at my code the majority of it was Getters and Setters (60%) compared to the rest that is truly nee...
When designing a new object model I always start with the class diagram function in visual studio. Once I have drafted the first version, with a couple of tweaks based on gathering new info or a change in requirements I start working on the actual implementation.
As development gets busy and targets have to be met the diagram goes by t...