I've got a f(x) that returns a collection of user controls. .Net lets me just treat the f(x) name as the collection. Is there something wrong with doing so?
ex)
Private Function GetCcB() As Collection(Of Reports_ucColumn)
Dim cc As New Collection(Of Reports_ucColumn)
cc.Add(Me.ucColumn0)
cc.Add(Me.ucColumn1)
cc.Add(Me...
I have several classes that conceptually belong to one tier. They have no common properties which is why they have no need to inherit from some base class.
I also have a few methods that deal with these classes. Some of them are templates of the following style:
public SomeClass
{
public void SomeMethod<T> (T argument) where T : Ba...
If you have a class A that is an aggregate of class B and C, is it better for A
to store ID's for B and C
to load and store the entire object for B and C (edit, store by reference to object B/C, i.e. instantiate objects B and C as opposed to storing id's for B and C.
store the ID's and provide methods to pull methods B and C
I'm assu...
I'm kind of new in PHP. For some reason in other types of programming languages like JAVA I have no problem with using setters and getters for every single variable, but when I'm programming in PHP probably because it is so flexible it feels kind of like a waste of time. It feels simpler to just set the class attributes as public most of...
The thing is that you have classes and then you have the database data. When you create an object how do you set the objects properties to contain the data in the database ?
I saw something like this and I'm wondering if this is really the best way to do it. I'm sure this is a fairly common issue, but I don't know what are the most acce...
How would I list all the public variables in an instantiated Object given that we do not know the variable names in the first place?
Scenario
A class may have a function declared like:
function addVar($name, $val) {
$this->$name = $val;
}
I want a list of $names that were ever added to the object instance dynamically.
...
As I always understood it, any change to the programs state (or anything to do with IO) is a side effect. It does not matter, whether the change occurs in a global variable or in a private field of the object the method is called on. It follows that all methods which do not return anything either do nothing at all or have a side effect. ...
Googling "What kind of applications is DDD suitable for?" gave me the following answer:
Probably 95% of all software applications fall into the “not so good for using DDD” categories. (see the article)
So what is all the fuss about?!?
The application I am working on is mainly data-centric but still contains some business logic an...
I have seen a number of different topics on StackOverFlow discussing the differences between Procedural and Object-Oriented Programming. The question is: If the program uses an object can it still be considered procedural?
...
My c++ SOA app has a concept of "session" that is used exchange data between services. In example its used for checking legality of some service A operations before executing session B which commits or rollback changes. Whatever.
I have 2 types of session modes: normal and what-if. Going further, I have different session, session for le...
Hello,
I've been trying to solve this for ages (3 days) now and I just cannot figure it out. I will try to explain the problem comprehensively because it is a bit more complex.
My school assignement is to create a simple text game using OOP in C# Visual Studio 2008 (should be built on a library the teacher provided for us). It should o...
I am writing a class that is linked to an external resource. One of the methods is a delete method that destroys the external resource. No further method calls should be made on that object. I was thinking of setting a flag and die'ing inside of all of the methods if the flag is set, but is there a better, easier way? Something invol...
Is this possible? I am creating a single base factory function to drive factories of different types (but have some similarities) and I want to be able to pass arguments as an array to the base factory which then possibly creates an instance of a new object populating the arguments of the constructor of the relevant class via an array.
...
There is a general rule of OO design that you should model is-a relationships using inheritance and has-a relationships using containment/aggregation and forwarding/delegation. This is further narrowed by the admonishment from the GoF that you should generally favor containment over inheritance, suggesting, perhaps, that if you could mak...
This code in a GUI application compiles and runs:
procedure TForm1.Button1Click(Sender: TObject);
begin
Self := TForm1.Create(Owner);
end;
(tested with Delphi 6 and 2009)
why is Self writable and not read-only?
in which situations could this be useful?
Edit:
is this also possible in Delphi Prism? (I think yes it is, see here)
...
I have a process which has a "notify" method which receives as a parameter the base class of the message type. I'd like to do different processing based on the derived type of message. Does this mean I need to add a method called "process" or something similar to the message type, and invoke it using polymorphism? Is it better to add a "...
While working on my hobby projects i split code in to background operations and gui operations. So i end up having library objects that does the actual work and gui objects that represent menus, frames and such. The thing that bugs me every time is that i end up having lots of objects that has to know about other objects. Such as toolba...
When unit-testing objects which have a composition relationship with another object (a "has-a" relationship), as I understand it, you can only really mock the composed objects if you are using dependency injection of some sort. Hence, code of the following kind make unit-testing very difficult and might therefore be considered a bad thi...
In javascript, every object is at the same time instance and class. To do inheritance, you can use any object instance as a prototype.
In python, C++, etc.. there are classes, and instances, as separate concepts. In order to do inheritance, you have to use the base class to create a new class, which can then be used to produce derived i...
I have recently programmed a console application and I've experienced a lot of pain in designing it in many aspects, particularly in C#, given its pure OO paradigm. Questions I have faced include anything from how to pass the options to how to return problems to the entry point class, among many, many others.
My question is: would any o...