Say I have some code like
namespace Portal
{
public class Author
{
public Author() { }
private void SomeMethod(){
string myMethodName = "";
// myMethodName = "Portal.Author.SomeMethod()";
}
}
}
Can I find out the name of the method I am using? In my example I'ld like to programma...
In every form we derive from FormBaseControl, we have the following code. I'm sure there is a better way to type the controller object than this, but at the moment we have it included in every page. In the example below, base.Controller is of type BaseController, from which ExportController derives. I find duplication of this code in ...
I'm updating my code generator and have a choice between implementing a method stub as a Virtual Method in a base class or a partial method in the generated code. Is there any performance difference between the two?
...
I have class with internal property:
internal virtual StateEnum EnrolmentState
{
get { ..getter logic }
set { ..setter logic }
}
However I want to be able to access to this property outside of the assembly so I created method that simply returns this property:
public StateEnum GetCurrentState()
{
return EnrolmentState;
...
This is a C# question, but really could be language-agnostic
I have inherited a large object model (100+ types), with a hierarchy of objects that 'own' 0..n of other typed objects that all share a base (where there is a 'relatively' strict type hierarachy).
I want to start decoupling these objects though inheritance to put together an ...
I have a base class that has a private static member:
class Base
{
private static Base m_instance = new Base();
public static Base Instance
{
get { return m_instance; }
}
}
And I want to derive multiple classes from this:
class DerivedA : Base {}
class DerivedB : Base {}
class DerivedC : Base {}
However, at ...
class MyBase
{
protected object PropertyOfBase { get; set; }
}
class MyType : MyBase
{
void MyMethod(MyBase parameter)
{
// I am looking for:
object p = parameter.PropertyOfBase; // error CS1540: Cannot access protected member 'MyBase.PropertyOfBase' via a qualifier of type 'MyBase'; the qualifier must be of...
When designing a new system or getting your head around someone else's code, what are some tell tale signs that something has gone wrong in the design phase? Are there clues to look for on class diagrams and inheritance hierarchies or even in the code itself that just scream for a design overhaul, particularly early in a project?
...
If you had to write code that takes messages from a message queue and updates a table in a database, how would you go about structuring it in a good oo way. How would you structure it? The messages is XML data, one node per row in the table. The rows in the table could be updated, deleted or inserted.
...
Here is a VB.NET code snippet
Public Class OOPDemo
Private _strtString as String
Public Function Func(obj as OOPDemo) as boolean
obj._strString = "I can set value to private member using a object"
End Function
End Class
I thought we cannot access the private members using the object, but perhaps CLR allows us to ...
by default is a class:
private ?
internal ?
sealed ?
...
My software design experience only goes as far as SSADM with C, so when I started Java I knew I'd have to learn UML somewhere along the line, but alas, now that I need to use it I don't know much of it. The only book I have on the subject is strictly a Systems Analysis book and much of it is complete overkill for what I need; a simple in...
I have two running processes in Windows, and each process has a pipe to the other.
I want to serialize a complicated class and transmit it from one process to the other. I already have the serialization procedure worked out, and I understand that the pipes are sending binary streams. How should I go about sending my serialized data? I'm...
As you can see below, in the constructor I'm instantiating a validation object so I can validate a user's email in a set method. Is this architecture best practice or flawed? Can I avoid making my User class directly dependent on my Validation class?
Class User {
Private Email
//constructor
User() {
Validation = new Validation
}
S...
This question is coded in pseudo-PHP, but I really don't mind what language I get answers in (except for Ruby :-P), as this is purely hypothetical. In fact, PHP is quite possibly the worst language to be doing this type of logic in. Unfortunately, I have never done this before, so I can't provide a real-world example. Therefore, hypothet...
If an object has a property that is a collection, should the object create the collection object or make a consumer check for null? I know the consumer should not assume, just wondering if most people create the collection object if it is never added to.
...
I need to perform a complicated calculation. In my case it seemed most natural to create a Calculator class (abstracted using a strategy pattern).
To perform the calculation the class needs to accept about 20 inputs, some of which are optional, some of which could change in the future etc. Once the Calculate() method is called, about 20...
Can you write object oriented code in C? Especially with regard to polymorphism.
See also: http://stackoverflow.com/questions/415452/object-orientation-in-c
...
From what I have read best practice is to have classes based on an interface and loosely couple the objects, in order to help code re-use and unit test.
Is this correct and is it a rule that should always be followed?
The reason I ask is I have recently worked on a system with 100’s of very different objects. A few shared common inter...
Quite a while ago, I heard about Object databases. Cool concept and all. Now, with the event of ORMs everywhere, does anyone still use any of the Object oriented Databases systems? Are they relevant? Are they practical?
...