Hi all
I know that Java has beautiful inbuilt support for the HashMaps or HashTables.
Does anybody have knowledge that what kind of hashing functions or techniques are employed by Java language?
Is it possible to tweak those functions to be able to make them more specific to one's application in order to improve performance and redu...
What do you think about using private static methods?
Personally, I prefer using a static private method to non-static as long as it does not require access to any instance fields.
But I heard that this practice violates OOP principles.
Edit: I am wondering from style prospective of view, not performance.
...
Something I've been taught when I first started with Object Oriented programming languages.
When declaring a field in a class, don't initialize it yet, do that in the constructor.
In C#:
public class Test
{
private List<String> l;
public Test()
{
l = new List<String>();
}
}
But when someone recently asked me why to do t...
I am working on some legacy code and have come across something that I'm not sure of. We have a class y that is declared inside of another class x. Class y is only ever used inside of class x but my question is why wouldn't you create a separate class file and put class y in there instead of declaring it inside of class x? Isn't this vio...
I had a geek fight with someone over what the strategy pattern really is and I need a little expert help (read: definitive proof).
We both agree that the strategy pattern allows for the guts of a class (e.g., the behavior) to be swapped out at runtime while maintaining the same interface. However, her contention is that "For [the algori...
A friend of mine has just posited that protected methods (yes, methods) constitute a code smell. That is, they're indicative of potential bad programming practice.
My gut says he's wrong, but I'm struggling to come up with a good example of where they're a good, legitimate solution. For example, I might be tempted to put the protected m...
Well the title says it all really.
I know that you cannot specify a constructor in an interface in .Net, but why can we not?
It would be really useful for my current project to be able to specify that an 'engine' must be passed in with the constructor, but as I cant, I have to suffice with an XML comment on the class.
...
Keeping classes loosely coupled is an important aspect of writing code that is easy to understand, modify, and debug--I get that. As a newbie, though, just about anytime I get beyond the most simple examples I struggle.
I understand, more or less, how I can encapsulate strings, integers, and simple data types in classes of their own. W...
Remember the old class hierarchy posters that used to come w/Delphi?
I'm wanting a full class hierarchy browser for ALL my Delphi classes, including the custom ones I've built and installed on the palette, plus third-party components. Ideally easily searchable by class name (including "whole word only" searches, so partial matches don'...
Is the C++ term "Container" simply synonymous with the Java term "Collection" ?
...
Even with a ton of PHP frameworks out there to choose from, I know many people prefer a minimal, personal set of libraries. What is your method when it comes to 'rolling your own' framework for PHP applications, and how does it vary depending on the type/scope of a project?
What does your script look like for a typical page? What is yo...
I will explain the question by example:
In zend framework, when you want to add a functionality to the view class, you can use what is called a Helper class.
A helper class is a class that has one method (Same as name of class) that becomes available in each of the views (by reflection the helper method is wrapped by a view method)
It is...
Maybe this is obvious, but I don't know how to declare class properties in Objective-C.
I need to cache per-class a dictionary and wonder how put it in the class.
...
I have two parallel inheritance chains:
Vehicle <- Car
<- Truck <- etc.
VehicleXMLFormatter <- CarXMLFormatter
<- TruckXMLFormatter <- etc.
My experience has been that parallel inheritance hierarchies can become a maintenance headache as they grow.
How do I avoid a parallel inheritance hierarchy without b...
Hello Everyone,
Fortunately, I know how to fetch data from the database, That's not a problem.
For my object oriented application I would have a table with users / persons.
I also have a person class.
The case:
I would like to show to the end user a list with all the persons. What is the correct way to show do this?
using mysql_fe...
A question about the flow of information in an object oriented construction, e.g. from controller to repository.
Should the objects passed always be in the model or should we allow smaller parts of information to travel?
What would you recommend? What factors decide the approach?
E.g. something like
Controller:
string alias = "a...
I have been searching for short and good examples to demonstrate OO features of a language as an introduction to fellow programmers. By "good", I mean, they can be run and output something rather meaningful not foobar stuff.
For instance, you can demonstrate most control flow constructs by a mandelbrot set example or functional aspects ...
I have a situation utilizing class table inheritance where the base object (which is abstract) is extended by specific types of the object.
For example, Person --> User --> Prospect
However, in some instances like with Prospect, sometimes it extends User and sometimes it doesn't. I can't reverse the relationship because User !== Prospe...
How smart is Garbage Collection when it comes to nested references?
Take this code for example:
Public Class SomeClass
Private m_SomeOtherClass(Me)
End Class
I know that GC works by looking at how many references remain, and any object without any references ends up getting dumped. So in this case, where there's a reference comi...
I need to create an application that displays data from a number of different sources (real-time data feeds and static data from a database). Primarily the app needs to cover these requirements:
Display the data in a grid, with realtime updates (to the existing data and to add new rows)
Format data accoringly (if x is less than y then ...