|
Hi Martin,
Thanks for your valuable comments. Actually my point was this : I love TDD, I WANT to use TDD, But in reality, I find it inapplicable other than algorithm projects. My Complains are against the TDD Framework that is available nowadays. I am glad that you also agreed that it is applicable to Algorithm based classes. But, Many Small project developers who are creating a Windows Application or Website by themselves, I dont know if they can practice TDD on those real world application where Algorithm part can be dominated by more UI related stuffs.
By the way, is it really not possible for microsoft to develop a TDD framwork which can test Private methods ? Maybe by using Reflections ? TDD could be very applicable if it allowed to test private methods.
Anyway, thanks for your insights. I highly appreciate for your time.
|
|
|
|
|
This really isn't the forum to post this question because it's more about your architecture and development process rather than C# itself. However, having said that, I'll attempt to answer some of your points.
The reason that you tend not to test private methods is because there should be no way to reach those methods other than through a public method; if somebody uses reflection to get to a method you intended to hide then really, it's their own lookout if things don't work the way they expect. The key point here, is that you test the public methods in such a way that you cover the private methods. If a private method cannot be reached, then you have code that cannot be executed - this is why code coverage is an important guideline in TDD.
TDD is not a be all/end all. If you write layered applications, TDD tends to be a reasonable fit; it's not perfect because you can fall into the trap of writing code to pass tests rather than writing code to satisfy a problem. As your development progresses, you find that you drop code that you wrote to simulate database access in favour of real database access (for instance). Where TDD really helps, is in asking you to think in terms of SOLID development - you can develop monolithic methods, but TDD tends to discourage this, and the idea that you can instantly tell if your code still runs when you change it. This, really helps once a project has gone live, as people move off the development into other areas - any changes can be instantly tested.
The important thing to remember is that TDD is not a magic bullet. Use it/don't use it. The important thing to rememember is that it's a tool available to you, and you should ignore it if it doesn't fit the problem.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: The important thing to rememember is that it's a tool available to you, and you should ignore it if it doesn't fit the problem.
---- This is a very good answer, Thank you very much for your time. I got some light from your reply.
|
|
|
|
|
You are welcome.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi,
i want to host a control like numeric up-down control in datagrid cell..hw can i do that?
|
|
|
|
|
|
When drawing an item and setting its bounds, is there a way to use fractions? For instance if I want to start at X=1.4 and Y=2.5 and have Width = 10.5 Height = 11.5.
|
|
|
|
|
Too lazy to look it up he?
|
|
|
|
|
You remind me of the robot from Moon. You always have some sort of emoticon at the end of your posts.
|
|
|
|
|
You;re looking for RectangleF , then you can use floats eg.
X = 1.4f
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi there,
I've googled and searched the discussion groups to try to get a listing of companies that sell user security applications that I can bolt onto an existing application that I have built and I can't seem to find anything. Don't know if I'm searhing for the wrong terms or no one has built anything for this purpose.
Anyone know of products that allow you to bolt on things like a login, form/ field/table level security for a C# windows application?
Thanks
|
|
|
|
|
jaydel123 wrote: Anyone know of products that allow you to bolt on things like a login, form/ field/table level security for a C# windows application?
Aladdin[^] springs to mind, but there are more solutions. I'm curious about what gets recommended by others
I are Troll
|
|
|
|
|
Hi there, thanks for the reply except that alladin is for SaaS applications and not windows (winforms) applications. I want to be able to give the user the application and one of the forms is a user maintenance form that will add and remove users to the application I have built. In the backend it is either creating a windows authenticated user or a SQL authenticated user with an encypted password. Then you tell the security application what forms the user can access and it's very easy to make security application access calls to see what forms the users should be able to open.
I'm talking more about once the software is licensed on the users system how to control access to the application with users and groups.
Thanks
|
|
|
|
|
Hi all,
Is there a straight forward way to remove leading zeros from a negative string:
ex. -00002 -> -2
Thanks.
|
|
|
|
|
Depends on what you're trying to do, but you can always use Integer.Parse or Integer.TryParse to convert it to an int, then just format it however you want with .ToString.
|
|
|
|
|
That worked great. Is there an easy way that I can see how much processing time the parsing is adding to the loop?
|
|
|
|
|
Do the processing without the parsing a bunch of times, take the average time. Compare that to the average time of doing the processing with the parsing.
|
|
|
|
|
|
sounds like you want a regex, replacing a minus and zero or more zeroes, by a minus sign.
|
|
|
|
|
Or repeatedly replace "-0" with "-" until there are none.
Or make substrings of the first character and all the rest, left trim the zeroes from the second part, and concatenate.
|
|
|
|
|
Have you tried
Convert.ToInt32(-00002);
This might get you rid of everything, even though the input is a negative number.
- jaypatel512
|
|
|
|
|
<rant>DON'T USE THE CONVERT CLASS!!!</rant>
Pretty much all it does is call the appropriate xxx.Parse method anyway, so if you know what class it is, just call its Parse method, Int32.Parse , as was already mentioned.
The only reasonable member of Convert is ChangeType .
|
|
|
|
|
|
Only when it's available.
Or, if you want the Exception to be thrown. Why avoid the Exception if you're just going to throw your own anyway?
|
|
|
|
|
PIEBALDconsult wrote: Only when it's available. thats what i said (if the method is there...)
Now why would you even consider raising/throwing an exception, thats just bad pratice. never use exception for you code-flow.
An exception should only be thrown, when it truly is an exception, like if your transfer data over the net and the cord gets unplugged, thats an exception.
Parsing data that is not correct, is not an exception.
Lets say in this case, you want to parse -002 to -2, and the value begin parsed, turns out to be "-002$" then its not an exception, then the value ("you should know"), you want to parse is incorrect, handle it. thats to correct way, I believe.
Furthermore, I believe the code engine will spin down for every exception it has to handle.
Just a short comparison:
for 1000 parsings
Parse: 4078 milliseconds
Try Parse: 0 milliseconds
I used this code to test:
Stopwatch sw = new Stopwatch();
sw.Start();
for (int i = 0; i < 1000; i++)
{
try { int demo = int.Parse("x"); }
catch (Exception) {}
}
sw.Stop();
Debug.WriteLine("Parse: " + sw.ElapsedMilliseconds);
sw.Reset();
sw.Start();
for (int i = 0; i < 1000; i++)
{
int demo;
int.TryParse("x", out demo);
}
sw.Stop();
Debug.WriteLine("Try Parse: " + sw.ElapsedMilliseconds);
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|