oop

How can a static class derive from an object?

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#. ...

Looking for Object-Oriented Programming journal

I'm looking for a journal which discusses OOP and modern programming technologies. Can anyone recommend any? ...

How do you decide between using an Abstract Class and an Interface?

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...

Best practices for DataBinding in asp.net for maintainability

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 ...

Is it bad practice for an object to catch its own exception and store the message in a property?

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...

OO Design - Separating Instance-specific functions from class-specific functions

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...

What's the best way to duplicate/extend a static class's functionality?

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 { ...

Arrays as proper objects

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...

Examples of great software design and implementation

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 ...

Why does the actionscript3.0 class heirachy fail (sometimes)?

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...

How do I break my procedural coding habits?

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 ...

Multithreading in C#: How can I pass a function name to another function to start a new thread?

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...

Object oriented Login functionality

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...

Can the Diamond Problem be really solved?

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 ...

Does "tell, don't ask" apply to user input validation?

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 ...

How to enforce a "has a" relationship and protect the object that "is had"

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 ...

Does Scala's pattern matching violate the Open/Closed Principle?

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...

2x one-to-many relationships in OO

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...

Java: Are Getters and Setters evil?

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...

How do you keep your object model diagram and code implementation in sync during the project life cycle ?

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...