|
Thats what I thought, when I was planning it out. He got all snippy about the idea tho
Its for me alone anyway so I guess I shouldn't really care whether he approves or not anyway!
Cheers Guys
Cads
|
|
|
|
|
For all the reason Cristian said - you go ahead and make whatever decision you feel happy with - this is after all just a learning excercise for you!
However, consider this; Say you start using your bugtracking app as single user with an access database installed right there with the application itself, and somebody else wants to be able to add/edit/view bugs. Now do you:
a) Install him as another single-user with its own database. Beraing in mind you now have 2 databases filled with bugs. (Add another imaginary 100 users... it starts getting very fragmented)
b) Rewrite the app to use a centralised database and install both users (plus the 100 more) on the new app.
Anyway, im just pointing out some things to think about. As a learning exercise you might want to look into "Data Abstraction" which basically means that you build your app to be database agnostic and when the time comes to upscale from Access to SQLServer or SQLExpress or Oracle or whatever its as simple as a reconfiguration (rather than a recode).
|
|
|
|
|
Thats really not a bad idea that. Hmmm I didn't really consider doing something like that but it may prove useful to know how to do it in the future. It might not as well, but it wouldn't hurt to know would it? Will have a browse around t'net and try and get me some knowledge then, any articles you would reccomend I read?
I like the phrase "database agnostic" dunno why just had me chortling
|
|
|
|
|
Basically, any application that accesses a database, should seperate that database access to a seperate dll. you replace your data layer by changing the data source that dll uses, while maintaining the same public interface, so the new dll just plugs back into the old code base. In practice, I've always done this, and never had to rewrite an app to use a different data source, but it has other advantages, not least, is that if you don't use stored procs, your SQL is centralised in your code at least, making it less likely that you'll write more than one piece of code to perform the same SQL. It also lends itself to having a single connecton string that is reused by all your data base code.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Cads,
Don't let anyone tell you what to do or use in all aspects of life, and programming in particular.Just do or use what works for you. You can't telkl from the frontend what you're using. Hell, I wrote programs that use an excelsheet to store my data. Saves a lot of hassle. Just use access. It's a very good database ( well, it is classed as a database ) for storing simple values. I would only recommend a more professional database if you're planning on storing Megs and Megs of data and use complicated stored procedures. This isn't the case in your application so go for access. Another pro of using access is that it's just one file, where SQL or any other DB for that matter has to be installed, instances created, etc.etc. Lots of headaches and not user friendly. Stick with access.
|
|
|
|
|
Hi,
Can anyone tell me which one is faster Hashtable or Dictionary.
Regards,
nas
|
|
|
|
|
|
If you want to know which is quicker, why not write some tests. This is the best way for you to find out because you won't end up relying on what somebody else tells you, which could be wrong.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Maybe 50 lines (or less!) would provide you with insertion/retrieval times for both.
Just for fun, I used the System.Diagnostics.Stopwatch class to get the elapsed time on adding 10,000,000 ints to both a HashTable and a Dictionary<int,int> and found that the Dictionary was faster both for insertion and retrieval.
I just for-looped for the desired number of iterations and added the counter each time to the container. On the retrieval, I just did a [key] lookup and an assigment, something like:
myint = container[key];
On the hashtable part, I did a Convert.To.Int32() call. On the Dictionary, it *knew* it was an Int already, so I just did the assignment. So, that Convert call took some time. I went back and took out the Convert call to see what impact that was having - not much, actually. Maybe 100-150 milliseconds on average for the entire run.
Interestingly (at least to me), the Hashtable was slower on retrieval when I specified the initial capacity at construction than when I didn't. For 10,000,000 items, it took about 700 milliseconds or so longer for the entire run.
Of course, your mileage may vary and my test program was not an exhaustive one.
That was as fun diversion - back to work I go!
Have fun,
Matt
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
Matthew Cuba wrote: Interestingly (at least to me), the Hashtable was slower on retrieval when I specified the initial capacity at construction than when I didn't. For 10,000,000 items, it took about 700 milliseconds or so longer for the entire run.
This is probably something to do with the fact that Hashtables have to box/unbox their data (both key AND value), whereas a Dictionary is strongly-typed.
|
|
|
|
|
Jason Hanford-Smith wrote: This is probably something to do with the fact that Hashtables have to box/unbox their data (both key AND value), whereas a Dictionary is strongly-typed.
Not sure I follow you on this. It was my understanding that retrieval of an element from a Hashtable is O(1). In both instances (whether I set the initial capacity or not), I've added 10,000,000 items to the Hashtable. I expected it to take longer to hashtable.add to the one where I didn't specify an initial capacity, as the Add is O(n) if Count>Capacity (it is O(1) otherwise), but on retrieval... well, I'd expect similar box/unbox activity to be done on the Hashtable in both instances.
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
If you take a look at the definition for Add and Item in Hashtable you'll see:
<br />
public virtual Object this[Object key] <-- Item for you VB'ers<br />
public virtual void Add(Object key, Object value)<br />
Both getting from and adding to the Hashtable involves boxing or unboxing.
On the other hand, with Dictionary you have:
<br />
public TValue this[TKey key] <-- Item for you VB'ers<br />
public void Add(TKey key, TValue value)<br />
As you can see, this uses Generics and so does not involve a type conversion or boxing/unboxing penalty.
|
|
|
|
|
Yes, I believe I understand the idea that the Dictionary knows the type already and thus doesn't have the boxing/unboxing overhead.
But, my original question was "Why would the cumulative time to retrieve N items from a Hashtable that had been declared:
Hashtable ht = new Hashtable(N);
be longer than for one declared as follows:
Hashtable ht = new Hashtable();?"
That is what I was wondering. It would seem to me that since they are both Hashtables and both have N number of items in them, added in the same manner, the retrieval time would be very similar, but it wasn't. It actually took longer for the one where I specified the capacity upfront.
Incidentally, the time to retrieve for the Dictionary was essentially the same whether or not I specified an initial capacity or not.
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
Apologies, my mistake.
Looking at it further (using Reflector), the Hashtable does some interesting things with the load factor provided that will force an automatic resize if the number of "buckets" used comes close the the number of slots available.
To test this, how about having two Hashtables using to two different initial sizes and timing the add/retrieve speed of each up to the smaller count. The speeds should be the same.
I think you'll only see the degredation when you go beyond it... it'll keep expanding to the next nearest prime above two times the current count. Which sounds like a big jump, but you'd probably hit it again pretty quick on a 10,000,000 loop.
Hope some (any) of that made sense.
|
|
|
|
|
No problem whatsoever.
You made perfect sense. I'm going to play around with the suggestions you've made here and I appreciate the responses and info. It is all quite interesting.
Take care,
Matt
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
Hi.
I've written a small program in which are 150 pictureBoxes. After clicking the button, boxes locations are randomly changed. But everything is flickering. Is there a way to make it smooth?
A have set form style to double buffering.
It works fine when the program updates form every 10-30 changed boxes but then it lasts long. (code in comment in button1_Click).
Problem is that Box background is firstly drawn in form background color and after is drawn in PictureBox.BackColor.
Thanks for reply
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Flickering
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer, true);
this.UpdateStyles();
CreatePictureBoxes();
}
private void CreatePictureBoxes()
{
Random rand = new Random();
for (int i = 0; i < 150; i++)
{
PictureBox pictureBox = new PictureBox();
pictureBox.BackColor = Color.Red;
pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
pictureBox.Location = new Point(rand.Next(200), rand.Next(200));
pictureBox.Name = "pictureBox" + i;
pictureBox.Size = new System.Drawing.Size(20,20);
pictureBox.TabIndex = 0;
pictureBox.TabStop = false;
this.Controls.Add(pictureBox);
}
}
private void button1_Click(object sender, EventArgs e)
{
Random rand = new Random();
for (int i = 0; i < 150; i++)
{
if (Controls[i] != (Control)button1)
{
this.Controls[i].Location = new Point(rand.Next(200), rand.Next(200));
}
}
}
}
}
namespace Flickering
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(207, 234);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(71, 26);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 264);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
}
}
|
|
|
|
|
Without doubt, the picturebox is the most abused and misused control in winforms. You'd lower your overhead if you just draw the images on the form yourself, which may help with your problem.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
But I also need to handle mouse events on each box. Should I write it myself? Or is there any other suitable control?
As in the example I'd like to have only one-colored rectangles
|
|
|
|
|
Yes, the mouse events are easy, if you draw them from a collection of objects, and iterate over that collecton backwards to see what the mouse is over, you should find it easy enough to handle mouse events and direct them to the correct object.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have posted before about this question and now I'm offering money for a solution
I have been using the dotNet Framework to create an UPnP Control Point application, this application makes use of the Microsoft UPNPLib.
The problem I have is when I "Invoke an Action", because the UPnP device that I am invoking the action on is building up a big response that could take a while to be recieved by my application the action keeps timing out (at around 36 seconds) can someone tell me how to extend the timeout period?
If I receive a satisfactory solution I will transfer 30GBP via PayPal to a specified account.
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
Here people provide solutions totally free but if you are offering them money then i think no will give response to your query
1 from me
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Desperate times, Desperate measures. But thank you for pointing out that people provide solutions for free.
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
Any way if you are developing the web aaplication then in web.cofig
lthttpRuntime executionTimeout="180"gt
check more details for httpRuntime
-- modified at 8:13 Thursday 6th September, 2007
-- modified at 8:13 Thursday 6th September, 2007
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Its not a web application but thank you for the response
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
I haven't used UPnPLib, but it the solution to your problem may lie in changing the value of the SubDefaultTimeout key in HKLM\COMM\UPnP . See this[^] MSDN link.
If this solves your problem, please consider donating 30GBP to a charity of your choice.
/ravi
|
|
|
|
|