|
|
According to the original post, you need to go to lunch while VS is frozen.
Greetings - Jacek
|
|
|
|
|
I think VS was busy
It's an OO world.
public class Sander : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
Now we know that VS has it's own way to "take care of business". I heard that it never happens if you have both VS and Eclipse installed.
Greetings - Jacek
|
|
|
|
|
Good code or bad code? Runs during a form constructor (testUser is a class bool).
public class a : Form
{
bool testUser;
a()
{
testUser = Array.IndexOf(new string[] { "mrock", "kasante" }, Environment.UserName.ToLower()) != -1;
}
}
I think my SQL experience influenced me slightly on this one.
|
|
|
|
|
Looks OK for a test code. And it's easy to extend. It would be bad if it was in a released code.
Greetings - Jacek
|
|
|
|
|
It's not in test code - it just sets a bool to determine whether features still being tested are available or not.
|
|
|
|
|
SortaCore wrote: It's not in test code (...) features still being tested
With a "test code" I (imprecisely) meant a "code being tested" -- which is the case.
Greetings - Jacek
|
|
|
|
|
No, it's used in release code, not as part of testing code - it specifies whether to allow the user to use beta functionality, basically.
Sorry if I wasn't clear.
|
|
|
|
|
As stated, it's OK.
You could use a case-insensitive HashSet -- I would make it static in case the set of testers becomes large. And perhaps use the # if DEBUG directive.
If you find yourself copying this code to many forms, you could put it in a library method.
|
|
|
|
|
SortaCore wrote: testUser = Array.IndexOf(new string[] { "mrock", "kasante" }, Environment.UserName.ToLower()) != -1;
If you want to get a little tighter about it:
testUser = Array.Exists(new [] { "a", "b" }, t => t=="a");
First of all, you don't need string[] because the compiler can infer the array type.
Second, using "Exists" makes it clearer to the reader what you're doing, especially since you're not interested in the index, you just want to know of the value exists.
Lastly, the use of the predicate t => t == 'a' means you could do some fancier things if you wanted later on -- it's a more general purpose solution. (Where 'a' would actually be in your case Environment.UserName.ToLower()
Marc
|
|
|
|
|
We all understand what a "class" is and what an "instance" is. These terms have nice rigorous definitions. We are having a debate in school with one of the professors. Of course we have to follow there definition in that class but we are wondering what the real answer is. It seems like there are 3 possible answers.
1. An Object and Class mean the same thing.
2. An Object and Instance mean the same thing.
3. An Object is both a Class and Instance. Object is more of a higher order term that includes both.
After doing some web research it seems that over time the name has changed. Just referring to common usage. It started out in the 80's as the first choice. In the 90's things got confusing so they added the word class so they could deal with hierarchies of classes. After the turn of the century is looks like it moved mostly to the 2nd definition. Still it kind of still oscillates between 2 and 3. Some of us think we should not even use the word object because of the confusion and only use class and instance.
We are wondering what the rest of the world thinks now.
So many years of programming I have forgotten more languages than I know.
modified 14-Nov-13 14:53pm.
|
|
|
|
|
Don't think belong here, see the forum header description.
|
|
|
|
|
Where should it go? I could not find anything closer. I considered Design and Architecture but that seems to be more technical questions where this one is more general and philosophical. Looking at the other posts this group seemed more serious than Lounge.
It is kind of Weird and Wonderful how names change.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
I've always chosen the definition "an object is the instantiation of a class" or "an object is an instance of a class"...
Therefore a class is the mere definition, prototypes...
The instantiation is a relationship between the object and the class, it's an action that represents saving memory space and create a new object of that class there.
And the object is that already instantiated class in memory.
At least this is how we manage our programs in the company
|
|
|
|
|
The traditional answer is, "it depends what you're talking about"!
- In .NET, there is a type called System.Object[^]; I believe Java has a similar type. When referring to that type, you are referring to a class. [#1]
- When you refer to "an object", you are usually referring to an instance of a class. [#2]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well, I would say your first bullet point is not equivalent to the OP's #1 (i.e. a class in general). Instead in this context Object is a specific type, which would be an additional 4th definition.
Regarding you second bullet point I agree. Before .NET I always considered an object to be an instance.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
Back when I was in school, I fretted over what was a procedure and what was a function... and what is the difference, is one technically more correct than the other for any given language...
When I got a job, school didn't matter anymore.
|
|
|
|
|
I am suck in school and fretting trivial BS. At least this time is an MS (More of the Same).
Why? Because employers want it. I often wonder if they know what they want it for . Still, they pay extra money for it .
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
My 2c
A class defines the properties of some object.
An instance is a single individual instance of a class.
So you talk about a customer object, meaning any instance of the customer class.
Or you talk about a particular customer instance.
MVVM # - I did it My Way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011
.\\axxx
(That's an 'M')
|
|
|
|
|
An interesting twist on the word. I have seen it stated another way though rarely. The more general statement is an object is a set of one or more instances. I am not sure I like this definition. I would prefer to talk about classes and sub-classes.
A class is much more than just properties. It is also methods. Methods that can modify the properties. Methods that can extract other meanings from the properties.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
Actually, technically speaking, classes are methods and fields, and nothing else.
Properties are a compiler feature, after the compiler they don't exist anymore (take a look at compiled code in ILSpy). The properties are turned into get_PropertyName and set_PropertyName style methods.
So, getting to the core of the issue...
An object has two meanings, first it is a base class from which all .NET "things" derive (and why they can all be cast to object). The second meaning is everything is an "object" in the sense that they are something you can interact with.
So, everything is an object, and objects are anything in .NET.
Read this[^]
Right under where it would show the inheritance tree it says "All classes, structures, enumerations, and delegates.".
|
|
|
|
|
michaelbarb wrote: an object is a set of one or more instances
I don't like that at all!
I think it just depends on the circumstances which sounds more natural (to me);
"If we add this property to the Customer class"
"We'd need to save the Customer object to the database"
"That instance needs to be saved to the database"
So object is really more generic than instance.
michaelbarb wrote: A class is much more than just properties. It is also methods.
Sure, of course - I meant properties in a generic sense - Properties, methods, constructors, events, references interface implementations etc. etc. are all just properties of an object - like diameter, colour and the ability to bounce are all properties of a ball.
MVVM # - I did it My Way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011
.\\axxx
(That's an 'M')
|
|
|
|
|
Wrong forum.
Mostly 3. Definitely not 1 or 2.
In my opinion... "object" is not strictly a technical term, but a very high-level concept, analogous to "thing". Some object may be defined in some language as a class , a struct , a collection , whatever.
Like "data structure" on steroids.
|
|
|
|
|
Object is unit of storage in computer memory - it is simple concept that means it has size and address: that is all folks you need to know what object is. Most of us keep forgetting that we program box filled with wires, transistors, diodes etc.
Class is template of data type (includes both fields and functions) and it is programming abstraction of real world problem it attempts to solve.
Class that has been created or instantiated takes shape (becomes an object that you can "touch", talk to - meaning send and receive messages, move, delete etc.) in computer memory that the program can work with.
There should not be any confusion what object is among programmers. Unfortunately most programming books is using some weird concepts and examples regarding OOP which confuses everybody and it is not even funny.
|
|
|
|