|
here a couple:1
2 , 3
and google will give a lot of others
|
|
|
|
|
LINQ to XML[^] I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Your post is too long to read thoroughly, so prior apologies if I have misunderstood what you are asking for.
IMO:
1. XML is not suited to, nor is it meant for database use, it is a structured way of storing data.
2. If you must use XML, reasearch serialization on here or Google. It allows you to to convert XML files into object instances without all that TextReader stuff.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
thanks for the opinion, It seemed the easiest to work with database wise. I could never understand sql connection and reading and writing data no matter what i've read. It's a pain really because a real database would be more useful
|
|
|
|
|
antrock101 wrote: I could never understand sql connection and reading and writing data no matter what i've read.
This is a great opportunity to learn. From your post it looks like you will end up doing more work by trying to use XML than a database.
http://www.connectionstrings.com/[^] has listings of the most common connection strings. The connection and other SQL objects have about the same level of complexity as the XML stuff, so you'll be able to get to grips with it. Additionally there is LINQ to SQL and LINQ to entities that can help make the database world onto the code world.
Also XML is NOT a database and shouldn't be used as one, you have to do all the work making sure the data integrity is kept. Many projects fail because, although initially easier, using XML is much harder work in the longer term for everything except simpler, non-relational data.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
the actual connection isn't an issue as visual has an in built connector i think, however i cant find tutorial on reading and writing the data in the database table without just dragging it onto a form
|
|
|
|
|
i want to turn on the webcam by clicking a button btturnwebcam then i want the picture to be shown in a picturebox webcampic then i want to take a photo by clicking anther button btcapture so how do i do this ? i have to note here that i have already imported the webcamcapture tool
|
|
|
|
|
suppose a float f and if i am intrested only in using this float but having only 2 digits after the dot so what i want to do is to delete the remaining digits .. so how do i do this?
|
|
|
|
|
1) You could use Math.Round(number,2);
2) You could use the decimal type
3) If the number is in a textbox replace it with numericUpDown and specify the number of digits
|
|
|
|
|
MDL=>Moshu wrote: If the number is in a textbox replace it with numericUpDown and specify the number of digits
one can paste anything into a editable Control, so that won't cut it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
true.
But my understanding of the question was "how to use just 2 digits"
and not "how to force just 2 digit number in a control".
Anyway, as usual good point
|
|
|
|
|
Hi
I'm in the process of developing an application that's mainly going to be used in an old age home to enable the older people to easily access and use information. A big part of the system is finished already, enabling them to Google, connect to Skype and access Gmail accounts. What I want to include still, is to enable these people to easily register on Facebook, and access the various information on there, such as photos of relatives etc. Is it possible to enable this system to connect automatically to the various facebook accounts, and display photos etc. inside the application without having to go to the actual Facebook site using a web browser? So basically, complete Facebook integration is my goal. Any ideas as to where I can start will also be appreciated.
Thanks in advance
|
|
|
|
|
There is a new Facebook toolkit that is now available on codeplex[^].Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
|
Please write full sentences, abbreviations can make things confusing. It is also unclear what you are asking for, this is a C# forum, but it looks like you have posted an SQL question.
Please clarify.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
Just guessing that this is about SQL syntax: try here[^] If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Imagine you have the following code.
public void X()
{
A();
B();
C();
}
Assuming that A, B, and C etc. are private function members, how would you write a unit test for this?
One way is to make them protected instead of private, but then you are changing the application code. Is there a way to do it without modifying the code above?
Visual Studio can also setup private accessors, but I think they're quite ugly. Or are they they best option?
|
|
|
|
|
Member 4487083 wrote: One way is to make them protected instead of private, but then you are changing the application code.
This is bad, you shouldn't change your code specifically for testing. When writing test code, you might discover shortfalls in the code, and of course the code should be changed in that case, but not just because you need to test.
Member 4487083 wrote: Is there a way to do it without modifying the code above?
You can call by reflection. (see last point)
Member 4487083 wrote: Visual Studio can also setup private accessors, but I think they're quite ugly. Or are they they best option?
I don't know if they are the best, that's a matter of opinion I suppose. They are a big improvement on doing it refelctively.
Hope this helps!Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
keefb wrote: you shouldn't change your code specifically for testing
I don't quite agree. One should design for testability, i.e. take precautions so the class is testable (testability is one of the goals, same as correctness, completeness, performance, maintainability, ...); if you have overlooked testability while designing, then you'll have to modify the class later on.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Luc Pattyn wrote: I don't quite agree
Which is why I wrote this:
When writing test code, you might discover shortfalls in the code, and of course the code should be changed in that case, but not just because you need to test.
Which was (possibly very unclear) shorthand for the reasons you wrote in your replying post
[Edit]
I've just read your thing about why Q&A Sucks. I totally agree.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
modified on Sunday, February 14, 2010 12:01 PM
|
|
|
|
|
Depends what tool you are using for unit testing. With VS, right-click and create unit tests for each method A, B, and C. Create a unit test for X also if it is dependent on results from any of the other methods. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Here are a couple of solutions, none of them is perfect though, as you basically want to extend an existing class or access all its members, even the private ones, without changing the class, and without allowing others to access them.
1.
change the private methods to public ones.
2.
add one method for testing purposes, give it one or more parameters, and let it dispatch to the methods that need testing.
3.
add your test code to the same class; partial classes are helping here.
4.
use reflection to access everything that isn't public.
5.
create a new class that holds the test code, and add a copy of the original class in to it. You need to chamge the class name and hence the constructor(s) for this.
6.
my personal preference: change all private attributes to protected ones; then derive a class that simply adds the test code and can access everything; you probably would keep the test class in a separate assembly which you do not distribute.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Luc Pattyn wrote: my personal preference: change all private attributes to protected ones; then derive a class that simply adds the test code and can access everything; you probably would keep the test class in a separate assembly which you do not distribute.
That's quite interesting because everybody else is saying that this is a bad idea. I think it can be quite neat in some places, but I wouldn't want to fill the main application with lots of unnecessary protecteds.
|
|
|
|
|
Luc Pattyn wrote: change all private attributes to protected ones
that was exagerated, it should read: change private attributes to protected ones as required...
Yes, making everything protected (or public) is not highly regarded as it opens the door more than may be required by the app itself.
I listed some possibilities and already said they all have some drawback; do you have a better solution?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I would never change a private method to public or anything else for testing. I'd always test it through calls to the public[1] members of the class because that's the way that they were designed to be used. If you make them public and test them directly then you have access to them in ways that the other classes and modules don't and you can stress them in ways that won't be possible once deployed. When unit testing a class I access it only in ways it was designed to be used and if code private that means that it was not designed to be used by anything other than the other code in the class.
Take the following class:
public class TestClass
{
private void PrivateMethod(bool someBool)
{
if (someBool)
{
Console.WriteLine("Reachable Code");
}
else
{
Console.WriteLine("Dead Code");
}
}
public void PublicMethod(double x)
{
double calculationResult = Math.Abs(x);
PrivateMethod (calculationResult >= 0.0);
}
}
The private method has different behavior based on its parameters. If you make that public and test it directly then you can stress both cases but that's not how the code was designed! If you examine the code you'll see that the only place it's called from is from the one public method and that method will always pass it a value of true . What this means is that private method doesn't need to have different behaviors, it doesn't need to check its input and it doesn't even need any input parameters. The parameter, if statement and else block are all dead code and should be removed. At least this is what it looks like at first glance; what if the fact that the method can only be passed one value a bug? What if the calculation is wrong? If you make the private method public just for the sake of testing then this question might never be asked. Granted, this is a contrived example that shows a minor inefficiency but it highlights how easy it is to hide bugs private code if you tweak for testing.
If you have a class where everything is private then what's the point of the class? If you have private code that isn't callable in one way or another from any public methods then what's the point of the code? If code can't be executed then it shouldn't exist, otherwise it should only be accessed in the manner in which it was designed to be accessed whether it's in testing or deployment.
In the test class above I would test the private method by writing test cases that enter whatever public methods are required to fully exercise as much of the private method as possible.
Of course, that's just my methodology. YMMV.
[1] "public" in this post is used as shorthand for any accessibility level that allows the method to be called from another class regardless of whether that class is internal to the assembly, an inherited child or using public attributes.
[EDIT] corrected example code
modified on Monday, February 15, 2010 7:06 AM
|
|
|
|