Recently, I made a post about the developers I'm working with not using try catch blocks properly, and unfortuantely using try... catch blocks in critical situations and ignoring the exception error all together. causing me major heart ache. Here is an example of one of the several thousand sections of code that they did this (some code...
I'm constructing a method to take in an ArrayList(presumably full of objects) and then list all the fields(and their values) for each object in the ArrayList.
Currently my code is as follows:
public static void ListArrayListMembers(ArrayList list)
{
foreach (Object obj in list)
{
Type type = obj.GetType(...
I have a property called "IsSecureConnection" that is part of my object's interface. This makes sense for most implementations of the interface, however, in some implementations I would like to make the property ReadOnly.
Should I omit this property from the object's interface even though it is required by all of the implementations ...
Hi,
I have a form which is used to insert/display and update. In the edit mode (update), when I pass my BO back to the Controller, what is the best possible way to check if any of the property values were changed, in order to execute the update to the datastore?
textbox1.text = CustomerController.GetCustomerInformation(id).Name
A c...
Suppose I have a python object x and a string s, how do I set the attribute s on x? So:
>>> x = SomeObject()
>>> attr = 'myAttr'
>>> # magic goes here
>>> x.myAttr
'magic'
What's the magic? The goal of this, incidentally, is to cache calls to x.__getattr__().
...
Please enlighten me.
public class SomeObject{
private String strSomeProperty;
public SomeObject(String strSomeProperty){
this.strSomeProperty = strSomeProperty;
}
public void setSomeProperty(String strSomeProperty){
this.strSomeProperty = strSomeProperty;
}
public String getSomeProperty(){
retur...
I am trying to 'swap' two cells' contents, and their mappings. To do this, I need to drag and drop a reference to the cell as opposed to the string value itself. I can then use this reference to update a Dictionary as well as get the value. It allows allows me to do the swap as I will have a reference to the old cell to add the value nee...
I'm looking for ideas on how to implement audit trails for my objects in C#, for the current project,basically I need to:
1.Store the old values and new values of a given object.
2.Record creation of new objects.
3.Deletion of old object.
Is there any generic way of doing this,like using C# Generics,so that I don't have to write code f...
In the constructor of my class, I map the current object (this), along with its key (a string entered as a parameter in the constructor) into a static LinkedHashMap so I can reference the object by the string anywhere I might need it later.
Here's the code (if it helps):
public class DataEntry {
/** Internal global list of DataEntr...
Can you write object oriented code in C? Especially with regard to polymorphism.
See also: http://stackoverflow.com/questions/415452/object-orientation-in-c
...
I'm trying to grab an image from a web site using simpleXML and am getting a PHP error saying that I'm trying to call to a member function xpath() on a non-object.
Below are the lines I'm trying to use to get the image's source tag:
$xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img';
$html = new DOMDocument()...
I have two arrays in PHP. The first array ($author_array) is comprised of user_ids in a particular order, like so: (8, 1, 6)
The second array ($user_results) is comprised of an array of objects like so:
Array
(
[0] => stdClass Object
(
[ID] => 1
[user_login] => user1
)
[1] => stdClass Obj...
So for viewing a current object's state at runtime, I really like what the Visual Studio Immediate window gives me. Just doing a simple
? objectname
Will give me a nicely formatted 'dump' of the object.
Is there an easy way to do this in code, so I can do something similar when logging?
...
A long time ago I saw this trick in Ruby. Instead of doing (for example)
if array1.empty? and array2.empty? and array3.empty?
You could call all of the objects at once and append the operation at the end, kind of like
if %w(array1 array2 array3).each { |a| a.empty? }
But I think it was simpler than that... or, it could be that. I r...
Hi Guys,
I am new to the REST architecural design, however I think I have the basics of it covered.
I have a problem with returning objects from a RESTful call. If I make a request such as http://localhost/{type A}/{id} I will return an instance of A from the database with the specified id.
My question is what happens when A contains ...
Imagine the following code:
return from a in DBContext.Acts
join artist in DBContext.Artists
on a.ArtistID equals artist.ID into art
from artist in art.DefaultIfEmpty()
select new Shared.DO.Act {
ID = a.ID,
Name = a.Name,
Artist = new Shared.DO.Artist {
...
Just for review, can someone quickly explain what prevents this from working (on compile):
private HashSet Data;
...
public DataObject[] getDataObjects( )
{
return (DataObject[]) Data.toArray();
}
...and what makes this the way that DOES work:
public DataObject[] getDataObjects( )
{
return (DataObject[]) Data.toArray( new D...
In working with objects and interfaces what is the best practice for writing to the database? There is a plethora of opinions regarding the object design but I am unclear about the database end. A simple example:
Suppose a Contact base class that contains the common fields such as contact name (Bill, Fred, Sally) and a location (home, ...
I am trying to write a life simulation in python with a variety of animals. It is impossible to name each instance of the classes I am going to use because I have no way of knowing how many there will be.
So, my question:
How can I automatically give a name to an object?
I was thinking of creating a "Herd" class which could be all the...
Good morning,
I am working with an object which has sub objects with in (see example below), I am attempting to bind a List to the datagrid. When I bind the List<>, in the cell that contains the subObject I see the following Value ... "namespace.subObject" ... the string values display correctly.
Ideally I would like to see the "Descri...