
rjonas
Members-
Posts
19 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by rjonas
-
I agree that it's important to refactor. I'd also recommend this book. If you have to comment code to make it readable, it's probably not written in the best way. Comments have problems in that they are difficult to maintain. If you need to fix a problem urgently at a later stage, you're unlikely to find the time to update the comments as well. If you're using NUnit or similar, as PlausiblyDamp suggests, the unit tests are the best place for comments, and can act as comments themselves as they explain what the code should do. They will break if they are not kept up to date.
-
This article describes .net scalability in a favourable light to J2EE, but with any article of this type, you have to ask questions as to why the author wrote it. www.object watch.com/FinalJ2EEandDotNet.doc I'd suggest looking at your application and think about what might cause problems as your application scales. If your application does a lot of mathematical calculations, perhaps a language such as C++ that offers more control at a lower level will be better for you. If database access is likely to be the issue, then the critical decision is whether to go Oracle or SQL Server or something else, not .net/j2ee. (edited - you'll have to remove a space from the link, as the original falls foul of a profanity checker)
-
The Eyetrack study explains how people's eyes move over a web page and how to improve its usability by putting the most important parts of your page in certain areas. Regards Richard
-
Connecting to the database and best practices.
rjonas replied to mike55's topic in Database / XML / Reporting
I open and close the connection each time, wrapping it in a c# using block, using exactly the same connection string each time. Connection pooling works behind the scenes to optimise performance, and if opening and closing connections is kept close to where the data is being used, any problems with connections are easier to find and debug. -
Hi George, Do you know whether your email recipients can receive emails in HTML format, and whether they are likely to have images enabled in their email client? If so, you could send your email in HTML format, and include your image using an <img> tag that references a file on your web server? Regards Richard
-
Connecting to the database and best practices.
rjonas replied to mike55's topic in Database / XML / Reporting
I try and use parameters, to avoid the possibility of SQL injection attacks. It's good practice as well to assume your client will be compromised (it's easy to reverse engineer a .net application) and someone will write an application to connect to your database, bypassing your client completely. To reduce the damage that could be done if a malicious application called your stored procedures with their own parameters, it might be worth validating things on the SQL side of things as well as the client and rejecting anything that looks suspicious. Regards Richard -
Does the web service attempt to perform any user authentication, and could this be failing due to it running under the system user account rather than as a normal user? Can you easily test the part of the windows service that calls the web service as a standalone application running as the current user, and does this work? Regards Richard
-
Hi, You can convert this to a type of Money, and then to a Varchar using a style of 1. select convert(varchar(50),convert(money,fieldname),1) from... The style of 1 gives 2 digits after the decimal point and inserts a comma between every 3 digits before the decimal point. There is a more detailed description of all the different styles here. Regards Richard
-
I'd suggest your decision to do this should depend on the following 1) Are you likely to want to change your database, or the structure of the tables in it? If so, putting the logic into a class will make it easier to do this and mean you only need to change code in one place when you make database changes. 2) Do you do processing in the application, rather than the database. E.g. if you wanted to add an address to your DB that isn't formatted correctly, would you process this in the DB or in code before it gets that far. If you want to process this in code, you might want a separate class. 3) Are the "business concepts" the application understands different from the underlying database tables. If they are, having a separate class would make writing other parts of your application easier. I'd recommend the book "Patterns of Enterprise Application Architecture" by Martin Fowler if you want to read more about different ways of structuring your classes and the arguments for each. Richard Jonas http://www.btinternet.com/~rjonas
-
To have one or multiple databases, that is the question...
rjonas replied to mike55's topic in Database / XML / Reporting
Are you ever going to have to understand how many customers have used certain features of your application? If there's a feature that's only being used by a few customers it might not be worth developing in the next version of your application, whereas if a feature is being used by everyone it might be worth spending a lot more time on. It will be easier to find this sort of information out if you have one database and a field in each table describing which customer it relates to. Regards Richard Jonas Hertford, Herts, UK. http://www.btinternet.com/~rjonas -
What user are you running as from the scheduler? Is it possible this could this be a user that does not have access permission to write to your log file? Richard
-
We use a service from a company called sms2email (http://www.sms2email.com) to send SMS messages. (I've no connection with this company otherwise, and I'm sure others offer a similar service). We buy SMS credits from them, and our application loads a web page using 2 lines of code like the following: System.Net.WebClient client = new System.Net.WebClient(); client.DownloadFile("http://www.sms2email.com/sms/postmsg.php?username=myusername&password=mypassword&orig=Name to appear on SMS message&to_num=<phone number>&message="+message,"c:\\temp.txt"); Regards Richard
-
I haven't used this myself, so can't be certain if this would work, but would this be of any use -it's under the GPL so doesn't cost $3500. http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
-
Could your page work as follows: When the page loads (in the page_load event handler), check if there is a querysting. 1. If there is a query string, record a session variable containing the entire querystring, and carry on displaying the page. 2. If there is no query string, load the contents of the session variable (if it's present), and redirect back to the page (with the querystring appended). This should make the QueryString visible in the Address bar on the browser.
-
I'd have thought that it would be easier to write Tetris using an event-driven model rather than a main loop. Could you set up a timer event, say every 1/2 a second and have an event handler that moves the block down the screen. You could also have keyboard event handlers. When a key to move the block left or right is pressed, these would be triggered and it would store the key pressed, and when the timer event is next triggered the block would move left or right as well as down. As the game progressed and got faster, all you would need to do is to reduce the interval of the timer events.
-
Rick, If you're looking at creating Windows apps in C++ for your own use, then you might be best off looking at something like C++ Builder. This is supposed to combine the visual appoach of VB with the C++ language better than Visual C++. I think you should be able to get a trial or educational version of this very cheaply. However, comparatively fewer people use this comercially, and if you want to use C++, and work using C++ commercially when you finish studying, then you might be best looking at Visual C++, so you can say you have used this when you approach a future employer. You might find you spend a lot more time learning the "Visual" side of things (interfacing with the operating system) rather than the pure C++ that you have been doing with Linux. As computers are getting more powerful, it seems rarely necessary to use C++ with its low level control over the machine for 95% of things, and you might be better off spending time learning a higher level language like C#.
-
I'm not sure exactly how your proxy has been configured, but if you're not able to change the proxy settings, could you try and connect to the internet from a browser. When you're on the page that asks for a username and password, select "View Source". If this submits the username and password to a form, add a web control to your application that connects to a page that immediately submits the username and password in the same way. This might authenticate you with the proxy server and allow you to access the Internet without having to type these details in.
-
Sam, The code you have that runs quickly does not concatenate the strings. This takes a long time, as in most cases, the string will need to be copied from one area of memory to another. The time this takes is proportional to the length of the string. When you get to the 3000th record, the string is long and this time is not insignificant. The loop therefore takes time proportional to 3000 squared (so the time taken will increase drastically if you have more than 3000 records) The last example does not concatenate the strings, and takes time proportional to the number of records (not the number of records squared) If as Jake suggests you use StringBuilder and set its Capacity property to something larger than the total length of the string, it will not have to make a copy of the entire string each time, and should take a time proportional to the number of records, not the number of records squared. Alternatively, you could set up an array of characters and copy the strings to the appropriate point in the array yourself, converting it back to a string when all 3000 records had been processed. Richard
-
Problem with WebClient and downloading file from HTTPS site
rjonas replied to allend2010's topic in Network
I am not using an HTTPS connection, but I found that I needed to set username and password by setting Credentials, and set up a proxy, by calling System.et.GlobalProxySelection.Select. Try something like this: System.Net.WebClient client = new System.Net.WebClient(); System.Net.GlobalProxySelection.Select = new System.Net.WebProxy("myproxy.company.com:8080"); client.Credentials = new System.Net.NetworkCredential("username","password"); client.DownloadFile("http://passwordprotectedsite.com/file.txt","c:\\file.txt"); Hope this helps, Richard